Skip to content

Commit

Permalink
iio: light: us5182d: Fix enable status inconcistency
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Adriana Reus authored and Jonathan Cameron committed Dec 22, 2015
1 parent 7d2c2ac commit 58e9042
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions drivers/iio/light/us5182d.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,12 @@ static int us5182d_als_enable(struct us5182d_data *data)
int ret;
u8 mode;

if (data->power_mode == US5182D_ONESHOT)
return us5182d_set_opmode(data, US5182D_ALS_ONLY);
if (data->power_mode == US5182D_ONESHOT) {
ret = us5182d_set_opmode(data, US5182D_ALS_ONLY);
if (ret < 0)
return ret;
data->px_enabled = false;
}

if (data->als_enabled)
return 0;
Expand All @@ -260,8 +264,12 @@ static int us5182d_px_enable(struct us5182d_data *data)
int ret;
u8 mode;

if (data->power_mode == US5182D_ONESHOT)
return us5182d_set_opmode(data, US5182D_PX_ONLY);
if (data->power_mode == US5182D_ONESHOT) {
ret = us5182d_set_opmode(data, US5182D_PX_ONLY);
if (ret < 0)
return ret;
data->als_enabled = false;
}

if (data->px_enabled)
return 0;
Expand Down

0 comments on commit 58e9042

Please sign in to comment.