diff mbox series

iio: vncl4000: Fix early return in vcnl4200_set_power_state

Message ID 19efdcd597b21ece9ad0ff894b6566d2ef4e2c02.1581066317.git.agx@sigxcpu.org (mailing list archive)
State New, archived
Headers show
Series iio: vncl4000: Fix early return in vcnl4200_set_power_state | expand

Commit Message

Guido Günther Feb. 7, 2020, 9:12 a.m. UTC
Don't return early unconditionally.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

---
I've not added a 'Fixes:' line since this is not part of Linus tree yet.
Tested proximity and ambient light on a vcnl4040 and checked the driver
suspends/resumes correctly and puts out valid data right after resume.  

 drivers/iio/light/vcnl4000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matt Ranostay Feb. 7, 2020, 7:45 p.m. UTC | #1
On Fri, Feb 7, 2020 at 1:12 AM Guido Günther <agx@sigxcpu.org> wrote:
>
> Don't return early unconditionally.
>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>

>
> ---
> I've not added a 'Fixes:' line since this is not part of Linus tree yet.
> Tested proximity and ambient light on a vcnl4040 and checked the driver
> suspends/resumes correctly and puts out valid data right after resume.
>
>  drivers/iio/light/vcnl4000.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 3b71c7d538af..38fcd9a26046 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -149,7 +149,7 @@ static int vcnl4200_set_power_state(struct vcnl4000_data *data, bool on)
>         if (ret < 0)
>                 return ret;
>
> -       return i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, val);
> +       ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, val);
>         if (ret < 0)
>                 return ret;
>
> --
> 2.23.0
>
Jonathan Cameron Feb. 8, 2020, 2:17 p.m. UTC | #2
On Fri,  7 Feb 2020 10:12:09 +0100
Guido Günther <agx@sigxcpu.org> wrote:

> Don't return early unconditionally.
> 
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
I've merged this down into the original patch.

Thanks,

Jonathan


> 
> ---
> I've not added a 'Fixes:' line since this is not part of Linus tree yet.
> Tested proximity and ambient light on a vcnl4040 and checked the driver
> suspends/resumes correctly and puts out valid data right after resume.  
> 
>  drivers/iio/light/vcnl4000.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 3b71c7d538af..38fcd9a26046 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -149,7 +149,7 @@ static int vcnl4200_set_power_state(struct vcnl4000_data *data, bool on)
>  	if (ret < 0)
>  		return ret;
>  
> -	return i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, val);
> +	ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, val);
>  	if (ret < 0)
>  		return ret;
>
Guido Günther Feb. 10, 2020, 3:41 p.m. UTC | #3
Hi Jonathan,
I've been extending iio-sensor-proxy to handle iio based proximity
sensors:

    https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/merge_requests/298

The API to applications shall not export the raw value but rather tell
if an object is near by:

   https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/merge_requests/298/diffs#67dff3849420abc19453e1998b8904bbaee6f13c_67_79

So in the simplest case we'd have to set a level above which an object
is considered close:

My intitial intent was to expose that via DT but looking around in iio
drivers i couldn't see any driver doing that (i missed
iio_read_mount_matrix) and noticed that the mount matrix is given via
systemd/udev's hwdb:

    https://github.com/systemd/systemd/pull/14845

Since matching on hwdb is done via modalias we wouldn't be able to have
different values on different boards without DMI/smbios:

   https://github.com/systemd/systemd/pull/14845/files#diff-37fdc5406b715a9996bdcd3d8e439e16R539

The matching rule is explained here:

     https://github.com/systemd/systemd/blob/master/hwdb.d/60-sensor.hwdb#L12

So would specifying this via DT and then exporting via sysfs be an
acceptable solution? That is inventing something like
iio_read_close_level. The value would not be used by the driver itself
but only exposed to userspace.
Cheers,
 -- Guido
diff mbox series

Patch

diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 3b71c7d538af..38fcd9a26046 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -149,7 +149,7 @@  static int vcnl4200_set_power_state(struct vcnl4000_data *data, bool on)
 	if (ret < 0)
 		return ret;
 
-	return i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, val);
+	ret = i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, val);
 	if (ret < 0)
 		return ret;