* [PATCH] iio: light: apds9306: fix max_scale_nano values
@ 2025-01-12 0:08 Javier Carrasco
2025-01-16 11:34 ` Subhajit Ghosh
2025-01-18 12:24 ` Jonathan Cameron
0 siblings, 2 replies; 3+ messages in thread
From: Javier Carrasco @ 2025-01-12 0:08 UTC (permalink / raw)
To: Subhajit Ghosh, Jonathan Cameron, Lars-Peter Clausen
Cc: linux-iio, linux-kernel, Jonathan Cameron, stable, Javier Carrasco
The two provided max_scale_nano values must be multiplied by 100 and 10
respectively to achieve nano units. According to the comments:
Max scale for apds0306 is 16.326432 → the fractional part is 0.326432,
which is 326432000 in NANO. The current value is 3264320.
Max scale for apds0306-065 is 14.09721 → the fractional part is 0.09712,
which is 97120000 in NANO. The current value is 9712000.
Update max_scale_nano initialization to use the right NANO fractional
parts.
Cc: stable@vger.kernel.org
Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/iio/light/apds9306.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
index 69a0d609cffc91cc3daba160f309f511270be385..5ed7e17f49e76206609aba83c85e8144c536d17d 100644
--- a/drivers/iio/light/apds9306.c
+++ b/drivers/iio/light/apds9306.c
@@ -108,11 +108,11 @@ static const struct part_id_gts_multiplier apds9306_gts_mul[] = {
{
.part_id = 0xB1,
.max_scale_int = 16,
- .max_scale_nano = 3264320,
+ .max_scale_nano = 326432000,
}, {
.part_id = 0xB3,
.max_scale_int = 14,
- .max_scale_nano = 9712000,
+ .max_scale_nano = 97120000,
},
};
---
base-commit: 577a66e2e634f712384c57a98f504c44ea4b47da
change-id: 20241218-apds9306_nano_vals-d880219a82f2
Best regards,
--
Javier Carrasco <javier.carrasco.cruz@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: light: apds9306: fix max_scale_nano values
2025-01-12 0:08 [PATCH] iio: light: apds9306: fix max_scale_nano values Javier Carrasco
@ 2025-01-16 11:34 ` Subhajit Ghosh
2025-01-18 12:24 ` Jonathan Cameron
1 sibling, 0 replies; 3+ messages in thread
From: Subhajit Ghosh @ 2025-01-16 11:34 UTC (permalink / raw)
To: Javier Carrasco, Jonathan Cameron, Lars-Peter Clausen
Cc: linux-iio, linux-kernel, Jonathan Cameron, stable
On 12/1/25 10:38, Javier Carrasco wrote:
> The two provided max_scale_nano values must be multiplied by 100 and 10
> respectively to achieve nano units. According to the comments:
>
> Max scale for apds0306 is 16.326432 → the fractional part is 0.326432,
> which is 326432000 in NANO. The current value is 3264320.
>
> Max scale for apds0306-065 is 14.09721 → the fractional part is 0.09712,
> which is 97120000 in NANO. The current value is 9712000.
>
> Update max_scale_nano initialization to use the right NANO fractional
> parts.
>
> Cc: stable@vger.kernel.org
> Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> drivers/iio/light/apds9306.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
> index 69a0d609cffc91cc3daba160f309f511270be385..5ed7e17f49e76206609aba83c85e8144c536d17d 100644
> --- a/drivers/iio/light/apds9306.c
> +++ b/drivers/iio/light/apds9306.c
> @@ -108,11 +108,11 @@ static const struct part_id_gts_multiplier apds9306_gts_mul[] = {
> {
> .part_id = 0xB1,
> .max_scale_int = 16,
> - .max_scale_nano = 3264320,
> + .max_scale_nano = 326432000,
> }, {
> .part_id = 0xB3,
> .max_scale_int = 14,
> - .max_scale_nano = 9712000,
> + .max_scale_nano = 97120000,
> },
> };
>
>
> ---
> base-commit: 577a66e2e634f712384c57a98f504c44ea4b47da
> change-id: 20241218-apds9306_nano_vals-d880219a82f2
>
> Best regards,
Hi Javier,
You are correct.
From iio_gts_linearize() function in industrialio-gts-helper.c
*lin_scale = (u64)scale_whole * (u64)scaler + (u64)(scale_nano / (NANO / scaler));
where "scaler" equals NANO (1000000000UL)
I tested it, no issues. The values did not deviate much as this is nano scale.
Tested-by: subhajit.ghosh@tweaklogic.com
Regards,
Subhajit Ghosh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: light: apds9306: fix max_scale_nano values
2025-01-12 0:08 [PATCH] iio: light: apds9306: fix max_scale_nano values Javier Carrasco
2025-01-16 11:34 ` Subhajit Ghosh
@ 2025-01-18 12:24 ` Jonathan Cameron
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2025-01-18 12:24 UTC (permalink / raw)
To: Javier Carrasco
Cc: Subhajit Ghosh, Lars-Peter Clausen, linux-iio, linux-kernel,
Jonathan Cameron, stable
On Sun, 12 Jan 2025 01:08:11 +0100
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:
> The two provided max_scale_nano values must be multiplied by 100 and 10
> respectively to achieve nano units. According to the comments:
>
> Max scale for apds0306 is 16.326432 → the fractional part is 0.326432,
> which is 326432000 in NANO. The current value is 3264320.
>
> Max scale for apds0306-065 is 14.09721 → the fractional part is 0.09712,
> which is 97120000 in NANO. The current value is 9712000.
>
> Update max_scale_nano initialization to use the right NANO fractional
> parts.
>
> Cc: stable@vger.kernel.org
> Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
This just missed last pull request for this cycle.
I've locally advanced my fixes branch to include all the material that will
merge in next couple of weeks, but for now can't push it out without making
a mess of linux-next (it will be in wrong place in the sequence)
So applied, but you can't see it yet!
Jonathan
> ---
> drivers/iio/light/apds9306.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
> index 69a0d609cffc91cc3daba160f309f511270be385..5ed7e17f49e76206609aba83c85e8144c536d17d 100644
> --- a/drivers/iio/light/apds9306.c
> +++ b/drivers/iio/light/apds9306.c
> @@ -108,11 +108,11 @@ static const struct part_id_gts_multiplier apds9306_gts_mul[] = {
> {
> .part_id = 0xB1,
> .max_scale_int = 16,
> - .max_scale_nano = 3264320,
> + .max_scale_nano = 326432000,
> }, {
> .part_id = 0xB3,
> .max_scale_int = 14,
> - .max_scale_nano = 9712000,
> + .max_scale_nano = 97120000,
> },
> };
>
>
> ---
> base-commit: 577a66e2e634f712384c57a98f504c44ea4b47da
> change-id: 20241218-apds9306_nano_vals-d880219a82f2
>
> Best regards,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-18 12:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-12 0:08 [PATCH] iio: light: apds9306: fix max_scale_nano values Javier Carrasco
2025-01-16 11:34 ` Subhajit Ghosh
2025-01-18 12:24 ` Jonathan Cameron
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®