aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Reus <adriana.reus@intel.com>2015-12-14 07:24:45 -0500
committerJonathan Cameron <jic23@kernel.org>2015-12-22 13:00:51 -0500
commit58e9042f5f130bf3f9043cf75aa2632fc12140e6 (patch)
treeeb807062bd1266bcff18fb2c44535a96fd3581b7
parent7d2c2acac577959dbbddefefa91d1ba1b80460b3 (diff)
iio: light: us5182d: Fix enable status inconcistency
When setting als only or proximity only modes make sure that we mark the other component as disabled. This fix is in preparation of adding event support because that will make it possible to switch between one-shot and continuous modes and not tracking these correctly may cause faulty behaviour (e.g wrongfully considering px enabled and not setting an appropriate mode in the chip). Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/light/us5182d.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
index 256c4bc12d21..f24b687bd152 100644
--- a/drivers/iio/light/us5182d.c
+++ b/drivers/iio/light/us5182d.c
@@ -238,8 +238,12 @@ static int us5182d_als_enable(struct us5182d_data *data)
238 int ret; 238 int ret;
239 u8 mode; 239 u8 mode;
240 240
241 if (data->power_mode == US5182D_ONESHOT) 241 if (data->power_mode == US5182D_ONESHOT) {
242 return us5182d_set_opmode(data, US5182D_ALS_ONLY); 242 ret = us5182d_set_opmode(data, US5182D_ALS_ONLY);
243 if (ret < 0)
244 return ret;
245 data->px_enabled = false;
246 }
243 247
244 if (data->als_enabled) 248 if (data->als_enabled)
245 return 0; 249 return 0;
@@ -260,8 +264,12 @@ static int us5182d_px_enable(struct us5182d_data *data)
260 int ret; 264 int ret;
261 u8 mode; 265 u8 mode;
262 266
263 if (data->power_mode == US5182D_ONESHOT) 267 if (data->power_mode == US5182D_ONESHOT) {
264 return us5182d_set_opmode(data, US5182D_PX_ONLY); 268 ret = us5182d_set_opmode(data, US5182D_PX_ONLY);
269 if (ret < 0)
270 return ret;
271 data->als_enabled = false;
272 }
265 273
266 if (data->px_enabled) 274 if (data->px_enabled)
267 return 0; 275 return 0;