]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00215797: max11801:don't update wrong ADC data when I2C is unavailable
authorRong Dian <b38775@freescale.com>
Thu, 5 Jul 2012 03:19:28 +0000 (11:19 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:34:58 +0000 (08:34 +0200)
If fail to communicate with I2C2 in any potential possibility,
driver doesn't update wrong ADC sample data into buf for battery.

Signed-off-by: Rong Dian <b38775@freescale.com>
drivers/input/touchscreen/max11801_ts.c

index 48ee3600a03bdb427e91bde276d72a58ff4d36f4..a1ac2d2042953126ac07b3abd10b10f55769b53e 100755 (executable)
@@ -106,6 +106,7 @@ struct max11801_data {
 };
 struct i2c_client *max11801_client;
 unsigned int max11801_workmode;
+u8 aux_buf[AUX_BUFSIZE];
 
 static int max11801_dcm_write_command(struct i2c_client *client, int command)
 {
@@ -115,7 +116,6 @@ static int max11801_dcm_write_command(struct i2c_client *client, int command)
 static u32 max11801_dcm_sample_aux(struct i2c_client *client)
 {
        u8 temp_buf;
-       u8 aux_buf[AUX_BUFSIZE];
        int ret;
        int aux = 0;
        u32 sample_data = 0;
@@ -124,15 +124,17 @@ static u32 max11801_dcm_sample_aux(struct i2c_client *client)
        mdelay(5);
        ret = i2c_smbus_read_i2c_block_data(client, FIFO_RD_AUX_MSB,
                                                1, &temp_buf);
-       aux_buf[0] = temp_buf;
        if (ret < 1)
                printk(KERN_DEBUG "FIFO_RD_AUX_MSB read fails\n");
+       else
+               aux_buf[0] = temp_buf;
        mdelay(5);
        ret = i2c_smbus_read_i2c_block_data(client, FIFO_RD_AUX_LSB,
                                                1, &temp_buf);
-       aux_buf[1] = temp_buf;
        if (ret < 1)
                printk(KERN_DEBUG "FIFO_RD_AUX_LSB read fails\n");
+       else
+               aux_buf[1] = temp_buf;
        aux = (aux_buf[0] << 4) +
                                        (aux_buf[1] >> 4);
        /*