From e15d12ad951df5046274a8d900c26deeacf22123 Mon Sep 17 00:00:00 2001 From: "lw@rock-chips.com" Date: Wed, 13 Jun 2012 18:53:31 +0800 Subject: [PATCH] modify al3006 active function --- drivers/input/sensors/lsensor/ls_al3006.c | 18 +++++++++++------- drivers/input/sensors/psensor/ps_al3006.c | 19 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/input/sensors/lsensor/ls_al3006.c b/drivers/input/sensors/lsensor/ls_al3006.c index 0700ff303d14..4b12770215c4 100755 --- a/drivers/input/sensors/lsensor/ls_al3006.c +++ b/drivers/input/sensors/lsensor/ls_al3006.c @@ -67,7 +67,10 @@ static int sensor_power_updown(struct i2c_client *client, int on) { if(!on) { - result = sensor_write_reg(client, CONFIG_REG, POWER_DOWN_MODE); + value = sensor_read_reg(client, CONFIG_REG); + value &= ~POWER_MODE_MASK; + value |= POWER_DOWN_MODE; + result = sensor_write_reg(client, CONFIG_REG, value); if(result) return result; } @@ -100,12 +103,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate) int result = 0; char value = 0; - sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg); + if(enable) + sensor_power_updown(client, 1); + + value = sensor_read_reg(client, sensor->ops->ctrl_reg); //register setting according to chip datasheet if(enable) { - if( (sensor->ops->ctrl_data & 0x03) == ONLY_PROX_EN ) + if( (value & 0x03) == ONLY_PROX_EN ) { value &= ~0x03; value |= ALL_PROX_ALS_EN; @@ -116,16 +122,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate) value |= ONLY_ALS_EN; } - sensor_power_updown(client, 1); } else { - if( (sensor->ops->ctrl_data & 0x03) == ONLY_ALS_EN ) + if( (value & 0x03) == ONLY_ALS_EN ) { value &= ~0x03; value |= ALL_IDLE; } - else if((sensor->ops->ctrl_data & 0x03) == ALL_PROX_ALS_EN ) + else if((value & 0x03) == ALL_PROX_ALS_EN ) { value &= ~0x03; value |= ONLY_PROX_EN; @@ -151,7 +156,6 @@ static int sensor_init(struct i2c_client *client) (struct sensor_private_data *) i2c_get_clientdata(client); int result = 0; char value = 0; - sensor_power_updown(client, 0); diff --git a/drivers/input/sensors/psensor/ps_al3006.c b/drivers/input/sensors/psensor/ps_al3006.c index 3e8f59e55b9b..b78e08dc8061 100755 --- a/drivers/input/sensors/psensor/ps_al3006.c +++ b/drivers/input/sensors/psensor/ps_al3006.c @@ -67,7 +67,10 @@ static int sensor_power_updown(struct i2c_client *client, int on) { if(!on) { - result = sensor_write_reg(client, CONFIG_REG, POWER_DOWN_MODE); + value = sensor_read_reg(client, CONFIG_REG); + value &= ~POWER_MODE_MASK; + value |= POWER_DOWN_MODE; + result = sensor_write_reg(client, CONFIG_REG, value); if(result) return result; } @@ -101,12 +104,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate) int result = 0; char value = 0; - sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg); + if(enable) + sensor_power_updown(client, 1); + + value = sensor_read_reg(client, sensor->ops->ctrl_reg); //register setting according to chip datasheet if(enable) { - if( (sensor->ops->ctrl_data & 0x03) == ONLY_ALS_EN ) + if( (value & 0x03) == ONLY_ALS_EN ) { value &= ~0x03; value |= ALL_PROX_ALS_EN; @@ -117,16 +123,15 @@ static int sensor_active(struct i2c_client *client, int enable, int rate) value |= ONLY_PROX_EN; } - sensor_power_updown(client, 1); } else { - if( (sensor->ops->ctrl_data & 0x03) == ONLY_PROX_EN ) + if( (value & 0x03) == ONLY_PROX_EN ) { value &= ~0x03; value |= ALL_IDLE; } - else if((sensor->ops->ctrl_data & 0x03) == ALL_PROX_ALS_EN ) + else if((value & 0x03) == ALL_PROX_ALS_EN ) { value &= ~0x03; value |= ONLY_ALS_EN; @@ -153,7 +158,7 @@ static int sensor_init(struct i2c_client *client) char value = 0; sensor_power_updown(client, 0); - + result = sensor->ops->active(client,0,0); if(result) { -- 2.34.1