From: Arnav Kapoor <kapoorarnav43@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Gwendal Grignou" <gwendal@chromium.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Arnav Kapoor" <kapoorarnav43@gmail.com>
Subject: [PATCH] iio: proximity: sx9360: use an int array for the sampling frequency range
Date: Wed, 4 Nov 2026 23:26:04 +0530 [thread overview]
Message-ID: <20261104175608.205872-1-kapoorarnav43@gmail.com> (raw)
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
next reply other threads:[~2026-11-04 17:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 17:56 Arnav Kapoor [this message]
2026-11-04 21:56 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104175608.205872-1-kapoorarnav43@gmail.com \
--to=kapoorarnav43@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gwendal@chromium.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®