* [PATCH] iio: proximity: sx9310: fix semtech,proxraw-strength = <0>
@ 2026-11-07 14:35 Arnav Kapoor
2026-11-15 0:52 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Arnav Kapoor @ 2026-11-07 14:35 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, Stephen Boyd,
linux-iio, linux-kernel, Arnav Kapoor
The binding allows semtech,proxraw-strength values of 0, 2, 4 and 8,
where 0 turns the PROXRAW filter off and the others select a strength of
1 - 1/N, i.e. register codes 1 to 3.
sx9310_get_default_reg() converts the property with ilog2(raw). For 0,
ilog2() returns -1, which FIELD_PREP() masks to 3 in the 2-bit RAWFILT
field. A board that asks for the filter to be off therefore gets the
strongest filter, the same as semtech,proxraw-strength = <8>.
Keep 0 as register code 0.
Fixes: 5b19ca2c78a0 ("iio: sx9310: Set various settings from DT")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
No in-tree DT uses semtech,proxraw-strength = <0> (sc7180-trogdor-lazor
uses 8), so this only affects out-of-tree boards. I checked the
mapping with a userspace copy of the ilog2()/FIELD_PREP() conversion:
0 and 8 both give RAWFILT = 3 before this patch, 0 gives 0 after it.
Compile-tested only (W=1); I don't have SX9310 hardware.
drivers/iio/proximity/sx9310.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
index 2585b9c6fb69..a39277237d39 100644
--- a/drivers/iio/proximity/sx9310.c
+++ b/drivers/iio/proximity/sx9310.c
@@ -855,7 +855,8 @@ sx9310_get_default_reg(struct device *dev, int idx,
if (ret) {
raw = FIELD_GET(SX9310_REG_PROX_CTRL5_RAWFILT_MASK,
reg_def->def);
- } else {
+ } else if (raw) {
+ /* 0 means off; 2, 4 and 8 are codes 1 to 3. */
raw = ilog2(raw);
}
base-commit: 340d44bdf9db0f095f99845b5ad8628781d79b6f
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] iio: proximity: sx9310: fix semtech,proxraw-strength = <0>
2026-11-07 14:35 [PATCH] iio: proximity: sx9310: fix semtech,proxraw-strength = <0> Arnav Kapoor
@ 2026-11-15 0:52 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-11-15 0:52 UTC (permalink / raw)
To: Arnav Kapoor
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, Stephen Boyd,
linux-iio, linux-kernel
On Sat, 7 Nov 2026 20:05:20 +0530
Arnav Kapoor <kapoorarnav43@gmail.com> wrote:
> The binding allows semtech,proxraw-strength values of 0, 2, 4 and 8,
> where 0 turns the PROXRAW filter off and the others select a strength of
> 1 - 1/N, i.e. register codes 1 to 3.
>
> sx9310_get_default_reg() converts the property with ilog2(raw). For 0,
> ilog2() returns -1, which FIELD_PREP() masks to 3 in the 2-bit RAWFILT
> field. A board that asks for the filter to be off therefore gets the
> strongest filter, the same as semtech,proxraw-strength = <8>.
>
> Keep 0 as register code 0.
>
> Fixes: 5b19ca2c78a0 ("iio: sx9310: Set various settings from DT")
> Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
I've applied this one to the testing branch of iio.git.
I note you've sent quite a few patches touching this same driver.
That's all good, but if you can group them into series that would
be even better! It makes sure I at least merge them on the
same tree!
Thanks,
Jonathan
> ---
> No in-tree DT uses semtech,proxraw-strength = <0> (sc7180-trogdor-lazor
> uses 8), so this only affects out-of-tree boards. I checked the
> mapping with a userspace copy of the ilog2()/FIELD_PREP() conversion:
> 0 and 8 both give RAWFILT = 3 before this patch, 0 gives 0 after it.
>
> Compile-tested only (W=1); I don't have SX9310 hardware.
>
> drivers/iio/proximity/sx9310.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
> index 2585b9c6fb69..a39277237d39 100644
> --- a/drivers/iio/proximity/sx9310.c
> +++ b/drivers/iio/proximity/sx9310.c
> @@ -855,7 +855,8 @@ sx9310_get_default_reg(struct device *dev, int idx,
> if (ret) {
> raw = FIELD_GET(SX9310_REG_PROX_CTRL5_RAWFILT_MASK,
> reg_def->def);
> - } else {
> + } else if (raw) {
> + /* 0 means off; 2, 4 and 8 are codes 1 to 3. */
> raw = ilog2(raw);
> }
>
>
> base-commit: 340d44bdf9db0f095f99845b5ad8628781d79b6f
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-15 0:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 14:35 [PATCH] iio: proximity: sx9310: fix semtech,proxraw-strength = <0> Arnav Kapoor
2026-11-15 0:52 ` 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®