input: misc: mpu: fix nvi_pwr_mgmt_1_war
David Yu [Sun, 8 Sep 2013 03:20:36 +0000 (12:20 +0900)]
Interrupt is not generated after nvi_accl_enable intermittently.
Not reading i2c after i2c write failure fixes the issue.

Bug 1362994

Change-Id: Icf97b39e740f14d8d76519116e73a38c7f08eed0
Signed-off-by: David Yu <davyu@nvidia.com>
Signed-off-by: Robert Collins <rcollins@nvidia.com>
Reviewed-on: http://git-master/r/271849
(cherry picked from commit 7fe774334a1a255fbc37710a89b6f2656a3881d2)
Reviewed-on: http://git-master/r/280964
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Gabby Lee <galee@nvidia.com>

drivers/input/misc/mpu/inv_gyro.c

index e21e73e..972f67d 100644 (file)
@@ -683,12 +683,13 @@ static int nvi_pwr_mgmt_1_war(struct inv_gyro_state_s *inf)
        int err;
 
        for (i = 0; i < POWER_UP_TIME; i++) {
-               inv_i2c_single_write(inf, inf->reg->pwr_mgmt_1, 0);
-               val = -1;
-               err = inv_i2c_read(inf, inf->reg->pwr_mgmt_1, 1, &val);
-               if (!val)
-                       break;
-
+               err = inv_i2c_single_write(inf, inf->reg->pwr_mgmt_1, 0);
+               if (err > 0) {
+                       val = -1;
+                       err = inv_i2c_read(inf, inf->reg->pwr_mgmt_1, 1, &val);
+                       if (err > 0 && !val)
+                               break;
+               }
                mdelay(1);
        }
        inf->hw.pwr_mgmt_1 = val;