diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/light/cm3217.c | 18 |
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; } |