diff mbox series

[1/3] iio: light: opt3001: add missing full-scale range value

Message ID 20240905-add_opt3002-v1-1-a5ae21b924fb@axis.com (mailing list archive)
State Changes Requested
Headers show
Series iio: light: opt3001: add support for TI's opt3002 light sensor | expand

Commit Message

Emil Gedenryd Sept. 5, 2024, 10:20 a.m. UTC
The opt3001 driver uses predetermined full-scale range values to
determine what exponent to use for event trigger threshold values.
The problem is that one of the values specified in the datasheet is
missing from the implementation, causing a big gap in settable values.

Add missing full-scale range array value.

Signed-off-by: Emil Gedenryd <emil.gedenryd@axis.com>
---
 drivers/iio/light/opt3001.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jonathan Cameron Sept. 7, 2024, 5:28 p.m. UTC | #1
On Thu, 5 Sep 2024 12:20:45 +0200
Emil Gedenryd <emil.gedenryd@axis.com> wrote:

> The opt3001 driver uses predetermined full-scale range values to
> determine what exponent to use for event trigger threshold values.
> The problem is that one of the values specified in the datasheet is
> missing from the implementation, causing a big gap in settable values.
> 
> Add missing full-scale range array value.
> 
> Signed-off-by: Emil Gedenryd <emil.gedenryd@axis.com>
I assume this has more of an impact in that if you write values beyond this one
the index will be off by one and the value written to the register
will be incorrect?

Please clarify if that is the case and also add a fixes tag
to the commit that introduced this bug.

Thanks,

Jonathan

> ---
>  drivers/iio/light/opt3001.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
> index 887c4b776a86..176e54bb48c3 100644
> --- a/drivers/iio/light/opt3001.c
> +++ b/drivers/iio/light/opt3001.c
> @@ -138,6 +138,10 @@ static const struct opt3001_scale opt3001_scales[] = {
>  		.val = 20966,
>  		.val2 = 400000,
>  	},
> +	{
> +		.val = 41932,
> +		.val2 = 800000,
> +	},
>  	{
>  		.val = 83865,
>  		.val2 = 600000,
>
Emil Gedenryd Sept. 9, 2024, 7:15 a.m. UTC | #2
On Sat, 2024-09-07 at 18:28 +0100, Jonathan Cameron wrote:
> On Thu, 5 Sep 2024 12:20:45 +0200
> Emil Gedenryd <emil.gedenryd@axis.com> wrote:
> 
> > The opt3001 driver uses predetermined full-scale range values to
> > determine what exponent to use for event trigger threshold values.
> > The problem is that one of the values specified in the datasheet is
> > missing from the implementation, causing a big gap in settable values.
> > 
> > Add missing full-scale range array value.
> > 
> > Signed-off-by: Emil Gedenryd <emil.gedenryd@axis.com>
> I assume this has more of an impact in that if you write values beyond this one
> the index will be off by one and the value written to the register
> will be incorrect?
> 
> Please clarify if that is the case and also add a fixes tag
> to the commit that introduced this bug.
> 
> Thanks,
> 
> Jonathan
Hi Jonathan,
You are correct regarding the behaviour. Thanks for the suggestion 
on how to clarify the message, I'll update it as well as add a fixes 
tag when I submit a new version either later today or tomorrow.

Best regards,
Emil
> 
> > ---
> >  drivers/iio/light/opt3001.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
> > index 887c4b776a86..176e54bb48c3 100644
> > --- a/drivers/iio/light/opt3001.c
> > +++ b/drivers/iio/light/opt3001.c
> > @@ -138,6 +138,10 @@ static const struct opt3001_scale opt3001_scales[] = {
> >  		.val = 20966,
> >  		.val2 = 400000,
> >  	},
> > +	{
> > +		.val = 41932,
> > +		.val2 = 800000,
> > +	},
> >  	{
> >  		.val = 83865,
> >  		.val2 = 600000,
> > 
>
diff mbox series

Patch

diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
index 887c4b776a86..176e54bb48c3 100644
--- a/drivers/iio/light/opt3001.c
+++ b/drivers/iio/light/opt3001.c
@@ -138,6 +138,10 @@  static const struct opt3001_scale opt3001_scales[] = {
 		.val = 20966,
 		.val2 = 400000,
 	},
+	{
+		.val = 41932,
+		.val2 = 800000,
+	},
 	{
 		.val = 83865,
 		.val2 = 600000,