]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
iio: light: us5182d: Fix enable status inconcistency
authorAdriana Reus <adriana.reus@intel.com>
Mon, 14 Dec 2015 12:24:45 +0000 (14:24 +0200)
committerJonathan Cameron <jic23@kernel.org>
Tue, 22 Dec 2015 18:00:51 +0000 (18:00 +0000)
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>
drivers/iio/light/us5182d.c

index 256c4bc12d2193cce9ddd473e467e25d01986cd7..f24b687bd152c2534b6ebd42eb4ae3d585c61523 100644 (file)
@@ -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;
@@ -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;