From 5a76aa36bc444837d87470366b88facaba20c193 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Tue, 17 Apr 2012 15:21:17 +0800 Subject: [PATCH] touchscreen: rk29_i2c_goodix: alloc info_buf before request_irq --- drivers/input/touchscreen/rk29_i2c_goodix.c | 40 ++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/input/touchscreen/rk29_i2c_goodix.c b/drivers/input/touchscreen/rk29_i2c_goodix.c index f5469ed2bde7..6bd9bde71d7b 100755 --- a/drivers/input/touchscreen/rk29_i2c_goodix.c +++ b/drivers/input/touchscreen/rk29_i2c_goodix.c @@ -297,8 +297,13 @@ static void goodix_get_touch_info(struct rk_ts_data *ts,char *point_num,struct r u8 index; u8 temp =0; point_data[0] = READ_COOR_ADDR; //read coor address - + if(!ts||!info_buf) + { + printk("goodix ts or info_buf is null\n"); + return; + } + ret=goodix_i2c_read_bytes(ts->client, point_data, sizeof(point_data)/sizeof(point_data[0])); if(ret != 2) { @@ -377,20 +382,19 @@ return: static void rk_ts_work_func(struct work_struct *pwork) { int i =0; - //struct rk_touch_info *info_buf; char point_num; struct rk_ts_data *ts = container_of(to_delayed_work(pwork), struct rk_ts_data, ts_work); + if(!ts) { printk("container of rk_ts_data fail\n"); + return; + } + if(!info_buf) + { + printk("info_buf fail\n"); + return; } - -// info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL); -// if(!info_buf) - //{ -// printk(KERN_ALERT "alloc for rk_touch_info fail\n"); -// goto exit; - //} if(ts->get_touch_info) { @@ -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; register_early_suspend(&ts->early_suspend); #endif - + + info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL); + if(!info_buf) + { + printk(KERN_ALERT "alloc for rk_touch_info fail\n"); + goto err_input_register_device_failed; + } + ts->irq=gpio_to_irq(ts->irq_pin) ; //If not defined in client if (ts->irq) { @@ -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; } } - - info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL); - if(!info_buf) - { - printk(KERN_ALERT "alloc for rk_touch_info fail\n"); - goto err_input_register_device_failed; - } printk("Goodix TS probe successfully!\n"); return 0; @@ -861,6 +865,8 @@ static int rk_ts_remove(struct i2c_client *client) dev_notice(&client->dev,"The driver is removing...\n"); i2c_set_clientdata(client, NULL); input_unregister_device(ts->input_dev); + if(info_buf) + kfree(info_buf); kfree(ts); return 0; } -- 2.34.1