{\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
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
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
(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
{\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
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
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
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