[PATCH] iio: proximity: sx9360: use an int array for the sampling frequency range

From: Arnav Kapoor

Date: Wed Nov 04 2026 - 13:23:36 EST


sx9360_samp_freq_interval[] is an array of struct { int val; int val2; }
that read_avail() hands to the IIO core by casting it to int *. That
relies on the struct having no padding. Declare it as an array of
int[2], like other IIO drivers do for their available ranges, so the
layout is plain and the cast no longer drops const.

No functional change.

Suggested-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
Signed-off-by: Arnav Kapoor <kapoorarnav43@xxxxxxxxx>
---
This is the int array conversion Andy suggested while reviewing the
sampling frequency fix. It goes on top of that fix, commit d252425c1533
("iio: proximity: sx9360: fix sampling frequency write and available
range") in fixes-togreg, so it can wait until that reaches togreg.

Compile-tested only (W=1); I don't have SX9360 hardware.

drivers/iio/proximity/sx9360.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
index 2a9b37df8f62..def69a060c0b 100644
--- a/drivers/iio/proximity/sx9360.c
+++ b/drivers/iio/proximity/sx9360.c
@@ -181,10 +181,7 @@ static const struct iio_chan_spec sx9360_channels[] = {
* The interval is not linear, but given there is 2047 possible value,
* Returns the fake increment of (Max-Min)/2047
*/
-static const struct {
- int val;
- int val2;
-} sx9360_samp_freq_interval[] = {
+static const int sx9360_samp_freq_interval[][2] = {
{ 0, 238535 }, /* 4MHz / (8192 * 2047) */
{ 0, 238419 },
{ 488, 281250 }, /* 4MHz / 8192 */
@@ -376,7 +373,7 @@ static int sx9360_read_avail(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SAMP_FREQ:
*type = IIO_VAL_INT_PLUS_MICRO;
*length = ARRAY_SIZE(sx9360_samp_freq_interval) * 2;
- *vals = (int *)sx9360_samp_freq_interval;
+ *vals = (const int *)sx9360_samp_freq_interval;
return IIO_AVAIL_RANGE;
default:
return -EINVAL;

base-commit: 340d44bdf9db0f095f99845b5ad8628781d79b6f
--
2.53.0