touchscreen: rk29_i2c_goodix: alloc info_buf before request_irq
author黄涛 <huangtao@rock-chips.com>
Tue, 17 Apr 2012 07:21:17 +0000 (15:21 +0800)
committer黄涛 <huangtao@rock-chips.com>
Tue, 17 Apr 2012 07:21:17 +0000 (15:21 +0800)
drivers/input/touchscreen/rk29_i2c_goodix.c

index f5469ed2bde7635f0b54dd94f9adb11a841f9527..6bd9bde71d7bba76ff7d82c2c59a6def3ef6b80f 100755 (executable)
@@ -297,8 +297,13 @@ static void goodix_get_touch_info(struct rk_ts_data *ts,char *point_num,struct r
        u8 index;\r
        u8 temp =0;\r
        point_data[0] = READ_COOR_ADDR;         //read coor address\r
-\r
        \r
+       if(!ts||!info_buf)\r
+       {\r
+               printk("goodix ts or info_buf is null\n");\r
+               return;\r
+       }\r
+\r
        ret=goodix_i2c_read_bytes(ts->client, point_data, sizeof(point_data)/sizeof(point_data[0]));\r
        if(ret != 2)    \r
        {\r
@@ -377,20 +382,19 @@ return:
 static void  rk_ts_work_func(struct work_struct *pwork)\r
 {      \r
        int i =0;\r
-       //struct rk_touch_info *info_buf;\r
        char point_num;\r
        struct rk_ts_data *ts = container_of(to_delayed_work(pwork), struct rk_ts_data, ts_work);\r
+\r
        if(!ts)\r
        {\r
                printk("container of rk_ts_data fail\n");\r
+               return;\r
+       }\r
+       if(!info_buf)\r
+       {\r
+               printk("info_buf fail\n");\r
+               return;\r
        }\r
-       \r
-//     info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL);\r
-//     if(!info_buf)\r
-       //{\r
-//             printk(KERN_ALERT "alloc for rk_touch_info fail\n");\r
-//             goto exit;\r
-       //}\r
 \r
        if(ts->get_touch_info)\r
        {\r
@@ -794,7 +798,14 @@ static int rk_ts_probe(struct i2c_client *client, const struct i2c_device_id *id
        ts->early_suspend.resume = rk_ts_late_resume;\r
        register_early_suspend(&ts->early_suspend);\r
 #endif\r
-       \r
+\r
+       info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL);\r
+       if(!info_buf)\r
+       {\r
+               printk(KERN_ALERT "alloc for rk_touch_info fail\n");\r
+               goto err_input_register_device_failed;\r
+       }\r
+\r
        ts->irq=gpio_to_irq(ts->irq_pin)        ;               //If not defined in client\r
        if (ts->irq)\r
        {\r
@@ -816,13 +827,6 @@ static int rk_ts_probe(struct i2c_client *client, const struct i2c_device_id *id
                        goto err_input_register_device_failed;\r
                }\r
        }\r
-\r
-       info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL);\r
-       if(!info_buf)\r
-       {\r
-               printk(KERN_ALERT "alloc for rk_touch_info fail\n");\r
-               goto err_input_register_device_failed;\r
-       }\r
        printk("Goodix TS probe successfully!\n");\r
        return 0;\r
 \r
@@ -861,6 +865,8 @@ static int rk_ts_remove(struct i2c_client *client)
        dev_notice(&client->dev,"The driver is removing...\n");\r
        i2c_set_clientdata(client, NULL);\r
        input_unregister_device(ts->input_dev);\r
+       if(info_buf)\r
+               kfree(info_buf);\r
        kfree(ts);\r
        return 0;\r
 }\r