modify al3006 active function
authorlw@rock-chips.com <lw@rock-chips.com>
Wed, 13 Jun 2012 10:53:31 +0000 (18:53 +0800)
committerlw <lw@rock-chips.com>
Wed, 13 Jun 2012 10:54:24 +0000 (18:54 +0800)
drivers/input/sensors/lsensor/ls_al3006.c
drivers/input/sensors/psensor/ps_al3006.c

index 0700ff303d141bb1d4958b7d7b5db6b8470fde49..4b12770215c4616ea6c5048c95a1fc3e102b8f4a 100755 (executable)
@@ -67,7 +67,10 @@ static int sensor_power_updown(struct i2c_client *client, int on)
        {\r
                if(!on)\r
                {\r
-                       result = sensor_write_reg(client, CONFIG_REG, POWER_DOWN_MODE);\r
+                       value = sensor_read_reg(client, CONFIG_REG);\r
+                       value &= ~POWER_MODE_MASK;\r
+                       value |= POWER_DOWN_MODE;\r
+                       result = sensor_write_reg(client, CONFIG_REG, value);\r
                        if(result)\r
                                return result;\r
                }\r
@@ -100,12 +103,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate)
        int result = 0;\r
        char value = 0;\r
 \r
-       sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg);\r
+       if(enable)      \r
+       sensor_power_updown(client, 1);\r
+\r
+       value = sensor_read_reg(client, sensor->ops->ctrl_reg);\r
        \r
        //register setting according to chip datasheet          \r
        if(enable)\r
        {       \r
-               if( (sensor->ops->ctrl_data & 0x03) == ONLY_PROX_EN )\r
+               if( (value & 0x03) == ONLY_PROX_EN )\r
                {\r
                        value &= ~0x03;\r
                        value |= ALL_PROX_ALS_EN;\r
@@ -116,16 +122,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate)
                        value |= ONLY_ALS_EN;\r
                }\r
 \r
-               sensor_power_updown(client, 1);\r
        }\r
        else\r
        {\r
-               if( (sensor->ops->ctrl_data & 0x03) == ONLY_ALS_EN )\r
+               if( (value & 0x03) == ONLY_ALS_EN )\r
                {\r
                        value &= ~0x03;\r
                        value |= ALL_IDLE;\r
                }\r
-               else if((sensor->ops->ctrl_data & 0x03) == ALL_PROX_ALS_EN )\r
+               else if((value & 0x03) == ALL_PROX_ALS_EN )\r
                {\r
                        value &= ~0x03;\r
                        value |= ONLY_PROX_EN;\r
@@ -151,7 +156,6 @@ static int sensor_init(struct i2c_client *client)
            (struct sensor_private_data *) i2c_get_clientdata(client);  \r
        int result = 0;\r
        char value = 0;\r
-\r
        \r
        sensor_power_updown(client, 0);\r
        \r
index 3e8f59e55b9be0b77524d261e74df260fdab1763..b78e08dc80611e2b64d893093962b5b239ef4897 100755 (executable)
@@ -67,7 +67,10 @@ static int sensor_power_updown(struct i2c_client *client, int on)
        {\r
                if(!on)\r
                {\r
-                       result = sensor_write_reg(client, CONFIG_REG, POWER_DOWN_MODE);\r
+                       value = sensor_read_reg(client, CONFIG_REG);\r
+                       value &= ~POWER_MODE_MASK;\r
+                       value |= POWER_DOWN_MODE;\r
+                       result = sensor_write_reg(client, CONFIG_REG, value);\r
                        if(result)\r
                                return result;\r
                }\r
@@ -101,12 +104,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate)
        int result = 0;\r
        char value = 0;\r
 \r
-       sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg);\r
+       if(enable)      \r
+       sensor_power_updown(client, 1);\r
+\r
+       value = sensor_read_reg(client, sensor->ops->ctrl_reg);\r
        \r
        //register setting according to chip datasheet          \r
        if(enable)\r
        {       \r
-               if( (sensor->ops->ctrl_data & 0x03) == ONLY_ALS_EN )\r
+               if( (value & 0x03) == ONLY_ALS_EN )\r
                {\r
                        value &= ~0x03;\r
                        value |= ALL_PROX_ALS_EN;\r
@@ -117,16 +123,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate)
                        value |= ONLY_PROX_EN;\r
                }\r
                \r
-               sensor_power_updown(client, 1);\r
        }\r
        else\r
        {\r
-               if( (sensor->ops->ctrl_data & 0x03) == ONLY_PROX_EN )\r
+               if( (value & 0x03) == ONLY_PROX_EN )\r
                {\r
                        value &= ~0x03;\r
                        value |= ALL_IDLE;\r
                }\r
-               else if((sensor->ops->ctrl_data & 0x03) == ALL_PROX_ALS_EN )\r
+               else if((value & 0x03) == ALL_PROX_ALS_EN )\r
                {\r
                        value &= ~0x03;\r
                        value |= ONLY_ALS_EN;\r
@@ -153,7 +158,7 @@ static int sensor_init(struct i2c_client *client)
        char value = 0;\r
        \r
        sensor_power_updown(client, 0);\r
-       \r
+               \r
        result = sensor->ops->active(client,0,0);\r
        if(result)\r
        {\r