summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDavid Yu <davyu@nvidia.com>2014-01-20 17:55:23 +0900
committerHarry Hong <hhong@nvidia.com>2014-01-20 16:57:46 -0800
commit3f147956a63973f8e3d2d2707f64b93e1e952477 (patch)
tree83a83b74ad433d09543919ed20e5aaf68f7bf049 /drivers
parent5c516f04999c8c6a23e42af2ab645f610edae0d0 (diff)
staging: iio: cm3217: fix i2c no ack
When power button is repeatedly pressed fast, i2c no ack error occurs due to unbalanced regulator on/off. tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 tegra-i2c tegra11-i2c.0: no acknowledge from address 0x10 [ERR][CM3217 error] I2C_TxData retry over 10 [ERR][CM3217 error]_cm3217_I2C_Write_Byte: I2C_TxData fail Change-Id: I55495221340ffa3aa796f4d932daca9e4cadc640 Signed-off-by: David Yu <davyu@nvidia.com> Reviewed-on: http://git-master/r/357632 Reviewed-by: Harry Hong <hhong@nvidia.com> Tested-by: Harry Hong <hhong@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/iio/light/cm3217.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/staging/iio/light/cm3217.c b/drivers/staging/iio/light/cm3217.c
index c8abb6a3524a..739282c4c845 100644
--- a/drivers/staging/iio/light/cm3217.c
+++ b/drivers/staging/iio/light/cm3217.c
@@ -3,7 +3,7 @@
* Copyright (C) 2011 Capella Microsystems Inc.
* Author: Frank Hsieh <pengyueh@gmail.com>
*
- * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -358,12 +358,15 @@ static int lightsensor_enable(struct cm3217_info *lpi)
int ret = 0;
uint8_t cmd = 0;
- als_power(1);
-
mutex_lock(&lpi->enable_lock);
+ if (lpi->als_enable)
+ goto out;
+
D("[LS][CM3217] %s\n", __func__);
+ als_power(1);
+
cmd = (CM3217_ALS_IT_2_T | CM3217_ALS_BIT5_Default_1 |
CM3217_ALS_WDM_DEFAULT_1);
ret = _cm3217_I2C_Write_Byte(ALS_W_CMD1_addr, cmd);
@@ -374,6 +377,7 @@ static int lightsensor_enable(struct cm3217_info *lpi)
queue_delayed_work(lpi->lp_wq, &report_work, lpi->polling_delay);
lpi->als_enable = 1;
+out:
mutex_unlock(&lpi->enable_lock);
return ret;
@@ -386,6 +390,9 @@ static int lightsensor_disable(struct cm3217_info *lpi)
mutex_lock(&lpi->disable_lock);
+ if (!lpi->als_enable)
+ goto out;
+
D("[LS][CM3217] %s\n", __func__);
cmd = (CM3217_ALS_IT_2_T | CM3217_ALS_BIT5_Default_1 |
@@ -401,10 +408,11 @@ static int lightsensor_disable(struct cm3217_info *lpi)
cancel_delayed_work(&report_work);
lpi->als_enable = 0;
- mutex_unlock(&lpi->disable_lock);
-
als_power(0);
+out:
+ mutex_unlock(&lpi->disable_lock);
+
return ret;
}