linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: xilinx-ams: Don't include ams_ctrl_channels in scan_mask
@ 2024-03-11 16:28 Sean Anderson
  2024-03-14 15:48 ` Jonathan Cameron
  0 siblings, 1 reply; 13+ messages in thread
From: Sean Anderson @ 2024-03-11 16:28 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Conall O'Griofa, linux-arm-kernel, linux-kernel,
	Lars-Peter Clausen, Sean Anderson

ams_enable_channel_sequence constructs a "scan_mask" for all the PS and
PL channels. This works out fine, since scan_index for these channels is
less than 64. However, it also includes the ams_ctrl_channels, where
scan_index is greater than 64, triggering undefined behavior. Since we
don't need these channels anyway, just exclude them.

Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---

 drivers/iio/adc/xilinx-ams.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
index a55396c1f8b2..4de7ce598e4d 100644
--- a/drivers/iio/adc/xilinx-ams.c
+++ b/drivers/iio/adc/xilinx-ams.c
@@ -414,8 +414,12 @@ static void ams_enable_channel_sequence(struct iio_dev *indio_dev)
 
 	/* Run calibration of PS & PL as part of the sequence */
 	scan_mask = BIT(0) | BIT(AMS_PS_SEQ_MAX);
-	for (i = 0; i < indio_dev->num_channels; i++)
-		scan_mask |= BIT_ULL(indio_dev->channels[i].scan_index);
+	for (i = 0; i < indio_dev->num_channels; i++) {
+		const struct iio_chan_spec *chan = &indio_dev->channels[i];
+
+		if (chan->scan_index < AMS_CTRL_SEQ_BASE)
+			scan_mask |= BIT_ULL(chan->scan_index);
+	}
 
 	if (ams->ps_base) {
 		/* put sysmon in a soft reset to change the sequence */
-- 
2.35.1.1320.gc452695387.dirty


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2024-06-08 14:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-11 16:28 [PATCH] iio: xilinx-ams: Don't include ams_ctrl_channels in scan_mask Sean Anderson
2024-03-14 15:48 ` Jonathan Cameron
2024-03-14 17:30   ` Sean Anderson
2024-03-15 13:18     ` O'Griofa, Conall
2024-03-15 17:47       ` Sean Anderson
2024-03-16 13:36         ` Jonathan Cameron
2024-03-18 15:18           ` Sean Anderson
2024-03-18 15:24             ` Jonathan Cameron
2024-03-18 15:28               ` Sean Anderson
2024-03-19 13:42                 ` Jonathan Cameron
2024-06-07 17:42                   ` Sean Anderson
2024-06-08 14:03                     ` Jonathan Cameron
2024-03-19 12:00         ` O'Griofa, Conall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).