The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] iio: light: al3010: fix incorrect scale for the highest gain range
@ 2026-07-02  5:29 Vidhu Sarwal
  2026-07-02  9:44 ` Andy Shevchenko
  2026-07-04 11:52 ` [PATCH v2] " Vidhu Sarwal
  0 siblings, 2 replies; 6+ messages in thread
From: Vidhu Sarwal @ 2026-07-02  5:29 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel, Shuah Khan, linux-kernel-mentees, Vidhu Sarwal

al3010_scales[] encodes the highest gain range as {0, 1187200}.
For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than
1000000, so the scale 1.1872 should instead be represented as
{1, 187200}.

Since write_raw() compares the value from userspace against this
table, writing  1.1872 scale never matches the malformed
entry and returns -EINVAL. As a result, the highest gain range cannot
be selected. Reading the scale in that state also reports the malformed
value.   

Fixes: c36b5195ab70 ("iio: light: add Dyna-Image AL3010 driver")
Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
---
 drivers/iio/light/al3010.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/al3010.c b/drivers/iio/light/al3010.c
index d603b4a6b8e8..cc39f8af4ea3 100644
--- a/drivers/iio/light/al3010.c
+++ b/drivers/iio/light/al3010.c
@@ -42,7 +42,7 @@ enum al3xxxx_range {
 };
 
 static const int al3010_scales[][2] = {
-	{0, 1187200}, {0, 296800}, {0, 74200}, {0, 18600}
+	{1, 187200}, {0, 296800}, {0, 74200}, {0, 18600}
 };
 
 static const struct regmap_config al3010_regmap_config = {
-- 
2.53.0


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

* Re: [PATCH] iio: light: al3010: fix incorrect scale for the highest gain range
  2026-07-02  5:29 [PATCH] iio: light: al3010: fix incorrect scale for the highest gain range Vidhu Sarwal
@ 2026-07-02  9:44 ` Andy Shevchenko
  2026-07-02 17:33   ` Jonathan Cameron
  2026-07-04 11:52 ` [PATCH v2] " Vidhu Sarwal
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2026-07-02  9:44 UTC (permalink / raw)
  To: Vidhu Sarwal
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel, Shuah Khan, linux-kernel-mentees

On Thu, Jul 02, 2026 at 10:59:13AM +0530, Vidhu Sarwal wrote:
> al3010_scales[] encodes the highest gain range as {0, 1187200}.
> For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than
> 1000000, so the scale 1.1872 should instead be represented as
> {1, 187200}.
> 
> Since write_raw() compares the value from userspace against this
> table, writing  1.1872 scale never matches the malformed
> entry and returns -EINVAL. As a result, the highest gain range cannot
> be selected. Reading the scale in that state also reports the malformed
> value.   

Trailing spaces in the last line of the above paragraph.

> 
> Fixes: c36b5195ab70 ("iio: light: add Dyna-Image AL3010 driver")
> Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>

...

>  static const int al3010_scales[][2] = {
> -	{0, 1187200}, {0, 296800}, {0, 74200}, {0, 18600}
> +	{1, 187200}, {0, 296800}, {0, 74200}, {0, 18600}

While at it, add a trailing comma.

>  };

Otherwise LGTM, thanks.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] iio: light: al3010: fix incorrect scale for the highest gain range
  2026-07-02  9:44 ` Andy Shevchenko
@ 2026-07-02 17:33   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-07-02 17:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Vidhu Sarwal, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel, Shuah Khan, linux-kernel-mentees

On Thu, 2 Jul 2026 12:44:54 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Jul 02, 2026 at 10:59:13AM +0530, Vidhu Sarwal wrote:
> > al3010_scales[] encodes the highest gain range as {0, 1187200}.
> > For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than
> > 1000000, so the scale 1.1872 should instead be represented as
> > {1, 187200}.
> > 
> > Since write_raw() compares the value from userspace against this
> > table, writing  1.1872 scale never matches the malformed
> > entry and returns -EINVAL. As a result, the highest gain range cannot
> > be selected. Reading the scale in that state also reports the malformed
> > value.     
> 
> Trailing spaces in the last line of the above paragraph.
> 
> > 
> > Fixes: c36b5195ab70 ("iio: light: add Dyna-Image AL3010 driver")
> > Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>  
> 
> ...
> 
> >  static const int al3010_scales[][2] = {
> > -	{0, 1187200}, {0, 296800}, {0, 74200}, {0, 18600}
> > +	{1, 187200}, {0, 296800}, {0, 74200}, {0, 18600}  
> 
> While at it, add a trailing comma.
Can we take opportunity to move to IIO (well my) preferred formatting
	{ 1, 187200 }, { 0, 296800 }, { 0, 74200 }, { 0, 18600 },  

Thanks,

Jonathan

> 
> >  };  
> 
> Otherwise LGTM, thanks.
> 


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

* [PATCH v2] iio: light: al3010: fix incorrect scale for the highest gain range
  2026-07-02  5:29 [PATCH] iio: light: al3010: fix incorrect scale for the highest gain range Vidhu Sarwal
  2026-07-02  9:44 ` Andy Shevchenko
@ 2026-07-04 11:52 ` Vidhu Sarwal
  2026-07-04 12:13   ` Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Vidhu Sarwal @ 2026-07-04 11:52 UTC (permalink / raw)
  To: jic23
  Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, skhan,
	linux-kernel-mentees, Vidhu Sarwal

al3010_scales[] encodes the highest gain range as {0, 1187200}.
For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than
1000000, so the scale 1.1872 should instead be represented as
{ 1, 187200 }.

Since write_raw() compares the value from userspace against this
table, writing the advertised 1.1872 scale never matches the malformed
entry and returns -EINVAL. As a result, the highest gain range cannot
be selected. Reading the scale in that state also reports the malformed
value.

Fixes: c36b5195ab70 ("iio: light: add Dyna-Image AL3010 driver")
Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
---
v2:
- Remove trailing whitespace in commit message and Add trailing comma after last array element (Andy)
- Use IIO preferred brace spacing (Jonathan)

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

diff --git a/drivers/iio/light/al3010.c b/drivers/iio/light/al3010.c
index d603b4a6b8e8..ca1d7fd6defb 100644
--- a/drivers/iio/light/al3010.c
+++ b/drivers/iio/light/al3010.c
@@ -42,7 +42,7 @@ enum al3xxxx_range {
 };
 
 static const int al3010_scales[][2] = {
-	{0, 1187200}, {0, 296800}, {0, 74200}, {0, 18600}
+	{ 1, 187200 }, { 0, 296800 }, { 0, 74200 }, { 0, 18600 },
 };
 
 static const struct regmap_config al3010_regmap_config = {
-- 
2.53.0


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

* Re: [PATCH v2] iio: light: al3010: fix incorrect scale for the highest gain range
  2026-07-04 11:52 ` [PATCH v2] " Vidhu Sarwal
@ 2026-07-04 12:13   ` Andy Shevchenko
  2026-07-04 23:06     ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2026-07-04 12:13 UTC (permalink / raw)
  To: Vidhu Sarwal
  Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel, skhan,
	linux-kernel-mentees

On Sat, Jul 04, 2026 at 05:22:45PM +0530, Vidhu Sarwal wrote:
> al3010_scales[] encodes the highest gain range as {0, 1187200}.
> For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than
> 1000000, so the scale 1.1872 should instead be represented as
> { 1, 187200 }.
> 
> Since write_raw() compares the value from userspace against this
> table, writing the advertised 1.1872 scale never matches the malformed
> entry and returns -EINVAL. As a result, the highest gain range cannot
> be selected. Reading the scale in that state also reports the malformed
> value.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] iio: light: al3010: fix incorrect scale for the highest gain range
  2026-07-04 12:13   ` Andy Shevchenko
@ 2026-07-04 23:06     ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-07-04 23:06 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Vidhu Sarwal, dlechner, nuno.sa, andy, linux-iio, linux-kernel,
	skhan, linux-kernel-mentees

On Sat, 4 Jul 2026 15:13:42 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Sat, Jul 04, 2026 at 05:22:45PM +0530, Vidhu Sarwal wrote:
> > al3010_scales[] encodes the highest gain range as {0, 1187200}.
> > For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than
> > 1000000, so the scale 1.1872 should instead be represented as
> > { 1, 187200 }.
> > 
> > Since write_raw() compares the value from userspace against this
> > table, writing the advertised 1.1872 scale never matches the malformed
> > entry and returns -EINVAL. As a result, the highest gain range cannot
> > be selected. Reading the scale in that state also reports the malformed
> > value.  
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 

For future reference, please never send a new version in reply to an earlier
version. It both gets very confusing as threads develop and also puts your
patches way back in the maintainers inbox, which often slows down getting them
applied.

Applied and marked for stable 

thanks, Jonathan

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

end of thread, other threads:[~2026-07-04 23:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02  5:29 [PATCH] iio: light: al3010: fix incorrect scale for the highest gain range Vidhu Sarwal
2026-07-02  9:44 ` Andy Shevchenko
2026-07-02 17:33   ` Jonathan Cameron
2026-07-04 11:52 ` [PATCH v2] " Vidhu Sarwal
2026-07-04 12:13   ` Andy Shevchenko
2026-07-04 23:06     ` Jonathan Cameron

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