mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: proximity: sx9360: use an int array for the sampling frequency range
@ 2026-11-04 17:56 Arnav Kapoor
  2026-11-04 21:56 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Arnav Kapoor @ 2026-11-04 17:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Nuno Sá,
	Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, linux-iio,
	linux-kernel, Arnav Kapoor

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@intel.com>
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
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


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

* Re: [PATCH] iio: proximity: sx9360: use an int array for the sampling frequency range
  2026-11-04 17:56 [PATCH] iio: proximity: sx9360: use an int array for the sampling frequency range Arnav Kapoor
@ 2026-11-04 21:56 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2026-11-04 21:56 UTC (permalink / raw)
  To: Arnav Kapoor
  Cc: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Gwendal Grignou, linux-iio, linux-kernel

On Wed, Nov 04, 2026 at 11:26:04PM +0530, Arnav Kapoor wrote:
> 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.

LGTM,

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

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-11-04 21:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 17:56 [PATCH] iio: proximity: sx9360: use an int array for the sampling frequency range Arnav Kapoor
2026-11-04 21:56 ` Andy Shevchenko

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®