@@ -34,8 +34,7 @@ static int dev_release(struct inode *, struct file *);
34
34
static ssize_t dev_read (struct file * , char * , size_t , loff_t * );
35
35
static ssize_t dev_write (struct file * , const char * , size_t , loff_t * );
36
36
37
- static void prepare_calc (void );
38
- static void calc (int first , int second , operation_t op );
37
+ static void calc (void );
39
38
40
39
static struct file_operations fops = {
41
40
.open = dev_open ,
@@ -100,30 +99,17 @@ static ssize_t dev_write(struct file *filep,
100
99
size_of_message = strlen (message );
101
100
printk (KERN_INFO "CALC: Received %d -> %s\n" , size_of_message , message );
102
101
103
- if (size_of_message >= 3 ) {
104
- prepare_calc ();
105
- }
102
+ calc ();
106
103
return len ;
107
104
}
108
105
109
- static void handle_case (int * first_num_stop , int * sec_num_start , int i )
110
- {
111
- if (first_num_stop && * first_num_stop == 0 ) {
112
- * first_num_stop = i - 1 ;
113
- }
114
-
115
- if (sec_num_start && * sec_num_start == 0 ) {
116
- * sec_num_start = i + 1 ;
117
- }
118
- }
119
-
120
- static void prepare_calc (void )
106
+ static void calc (void )
121
107
{
122
108
struct expr_var_list vars = {0 };
123
109
struct expr * e = expr_create (message , strlen (message ), & vars , NULL );
124
110
if (!e ) {
125
111
printk (KERN_ALERT "Syntax error" );
126
- return 1 ;
112
+ return ;
127
113
}
128
114
129
115
result = expr_eval (e );
0 commit comments