misc: mpu3050: Allow accelerometer to enter suspend during LP
Daniel Solomon [Tue, 22 Nov 2011 01:33:10 +0000 (17:33 -0800)]
The KXTF9's control reg PC1 bit was being set for both
suspend and resume config structs in kxtf9_set_odr().
This caused the accelerometer to be turned on during both
suspend and resume.

Bug 902379

Cherry-picked From: http://git-master/r/#change,65983
Signed-off-by: Daniel Solomon <daniels@nvidia.com>

Change-Id: If0a17af5b4538008dbf4d4f8b2d280f8d3981e3f
Reviewed-on: http://git-master/r/69260
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Daniel Solomon <daniels@nvidia.com>
Tested-by: Daniel Solomon <daniels@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
Reviewed-by: Robert Collins <rcollins@nvidia.com>

drivers/misc/mpu3050/accel/kxtf9.c

index e2490af..938cd57 100644 (file)
@@ -263,9 +263,6 @@ static int kxtf9_set_odr(void *mlsl_handle,
                bits = 0;
        }
 
-       if (odr != 0)
-               config->ctrl_reg1 |= 0x80;
-
        config->reg_odr = bits;
        kxtf9_set_dur(mlsl_handle, pdata,
                config, apply, config->dur);
@@ -498,6 +495,8 @@ static int kxtf9_config(void *mlsl_handle,
                        struct ext_slave_platform_data *pdata,
                        struct ext_slave_config *data)
 {
+       int retval;
+       long odr;
        struct kxtf9_private_data *private_data = pdata->private_data;
        if (!data->data)
                return ML_ERROR_INVALID_PARAMETER;
@@ -509,10 +508,15 @@ static int kxtf9_config(void *mlsl_handle,
                                        data->apply,
                                        *((long *)data->data));
        case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return kxtf9_set_odr(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
+               odr = *((long *)data->data);
+               if (odr != 0)
+                       private_data->resume.ctrl_reg1 |= 0x80;
+
+               retval = kxtf9_set_odr(mlsl_handle, pdata,
+                               &private_data->resume,
+                               data->apply,
+                               odr);
+               return retval;
        case MPU_SLAVE_CONFIG_FSR_SUSPEND:
                return kxtf9_set_fsr(mlsl_handle, pdata,
                                        &private_data->suspend,