mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: light: cm32181: return zero after writing calibscale
@ 2026-07-31 13:20 Giorgi Tchankvetadze
  2026-07-31 14:11 ` Joshua Crofts
  2026-08-01 15:24 ` David Lechner
  0 siblings, 2 replies; 4+ messages in thread
From: Giorgi Tchankvetadze @ 2026-07-31 13:20 UTC (permalink / raw)
  To: Kevin Tsai, Jonathan Cameron
  Cc: David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel, Giorgi Tchankvetadze

From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>

The write_raw callback is documented to return 0 on success or a
negative error code.  However, the IIO_CHAN_INFO_CALIBSCALE case
returns 'val' (the user-supplied value) instead of 0.

Fix it by returning 0 on success, matching the behavior of other
calibscale implementations in the subsystem.

Fixes: 971672c0b3cc ("iio: add Capella CM32181 ambient light sensor driver.")
Signed-off-by: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
---
 drivers/iio/light/cm32181.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index 2590fc8fd154..b32a94028f09 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -368,7 +368,7 @@ static int cm32181_write_raw(struct iio_dev *indio_dev,
 	switch (mask) {
 	case IIO_CHAN_INFO_CALIBSCALE:
 		cm32181->calibscale = val;
-		return val;
+		return 0;
 	case IIO_CHAN_INFO_INT_TIME:
 		ret = cm32181_write_als_it(cm32181, val2);
 		return ret;
-- 
2.52.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: light: cm32181: return zero after writing calibscale
  2026-07-31 13:20 [PATCH] iio: light: cm32181: return zero after writing calibscale Giorgi Tchankvetadze
@ 2026-07-31 14:11 ` Joshua Crofts
  2026-08-02  1:46   ` Jonathan Cameron
  2026-08-01 15:24 ` David Lechner
  1 sibling, 1 reply; 4+ messages in thread
From: Joshua Crofts @ 2026-07-31 14:11 UTC (permalink / raw)
  To: Giorgi Tchankvetadze
  Cc: Kevin Tsai, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel, Giorgi Tchankvetadze

On Fri, 31 Jul 2026 17:20:48 +0400
Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> wrote:

> From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> 
> The write_raw callback is documented to return 0 on success or a
> negative error code.  However, the IIO_CHAN_INFO_CALIBSCALE case
> returns 'val' (the user-supplied value) instead of 0.
> 
> Fix it by returning 0 on success, matching the behavior of other
> calibscale implementations in the subsystem.
> 
> Fixes: 971672c0b3cc ("iio: add Capella CM32181 ambient light sensor driver.")
> Signed-off-by: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> ---

LGTM.

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: light: cm32181: return zero after writing calibscale
  2026-07-31 13:20 [PATCH] iio: light: cm32181: return zero after writing calibscale Giorgi Tchankvetadze
  2026-07-31 14:11 ` Joshua Crofts
@ 2026-08-01 15:24 ` David Lechner
  1 sibling, 0 replies; 4+ messages in thread
From: David Lechner @ 2026-08-01 15:24 UTC (permalink / raw)
  To: Giorgi Tchankvetadze, Kevin Tsai, Jonathan Cameron
  Cc: Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel, Giorgi Tchankvetadze

On 7/31/26 8:20 AM, Giorgi Tchankvetadze wrote:
> From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> 
> The write_raw callback is documented to return 0 on success or a
> negative error code.  However, the IIO_CHAN_INFO_CALIBSCALE case
> returns 'val' (the user-supplied value) instead of 0.
> 
> Fix it by returning 0 on success, matching the behavior of other
> calibscale implementations in the subsystem.
> 
> Fixes: 971672c0b3cc ("iio: add Capella CM32181 ambient light sensor driver.")
> Signed-off-by: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> ---
>  drivers/iio/light/cm32181.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
> index 2590fc8fd154..b32a94028f09 100644
> --- a/drivers/iio/light/cm32181.c
> +++ b/drivers/iio/light/cm32181.c
> @@ -368,7 +368,7 @@ static int cm32181_write_raw(struct iio_dev *indio_dev,
>  	switch (mask) {
>  	case IIO_CHAN_INFO_CALIBSCALE:
>  		cm32181->calibscale = val;
> -		return val;
> +		return 0;
>  	case IIO_CHAN_INFO_INT_TIME:
>  		ret = cm32181_write_als_it(cm32181, val2);
>  		return ret;

While we are looking at this, it looks like we can follow this up
with another patch to return cm32181_write_als_it() directly and
drop the ret local variable.

There are also a couple of switch statements where we could move
the return -EINVAL into a default: case as we usually do in IIO.
(A separate patch for this as well.)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: light: cm32181: return zero after writing calibscale
  2026-07-31 14:11 ` Joshua Crofts
@ 2026-08-02  1:46   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-08-02  1:46 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Giorgi Tchankvetadze, Kevin Tsai, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel, Giorgi Tchankvetadze

On Fri, 31 Jul 2026 16:11:27 +0200
Joshua Crofts <joshua.crofts1@gmail.com> wrote:

> On Fri, 31 Jul 2026 17:20:48 +0400
> Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> wrote:
> 
> > From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> > 
> > The write_raw callback is documented to return 0 on success or a
> > negative error code.  However, the IIO_CHAN_INFO_CALIBSCALE case
> > returns 'val' (the user-supplied value) instead of 0.
> > 
> > Fix it by returning 0 on success, matching the behavior of other
> > calibscale implementations in the subsystem.
> > 
> > Fixes: 971672c0b3cc ("iio: add Capella CM32181 ambient light sensor driver.")
> > Signed-off-by: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> > ---  
> 
> LGTM.
> 
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> 


Applied to the testing branch of iio.git and marked for stable.

Thanks,

Jonathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-02  1:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-31 13:20 [PATCH] iio: light: cm32181: return zero after writing calibscale Giorgi Tchankvetadze
2026-07-31 14:11 ` Joshua Crofts
2026-08-02  1:46   ` Jonathan Cameron
2026-08-01 15:24 ` David Lechner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®