Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 89b898c

Browse files
Sean Andersonjic23
authored andcommitted
iio: xilinx-ams: Don't include ams_ctrl_channels in scan_mask
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: d5c7062 ("iio: adc: Add Xilinx AMS driver") Signed-off-by: Sean Anderson <sean.anderson@linux.dev> Link: https://lore.kernel.org/r/20240311162800.11074-1-sean.anderson@linux.dev Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 8f40af3 commit 89b898c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/iio/adc/xilinx-ams.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,12 @@ static void ams_enable_channel_sequence(struct iio_dev *indio_dev)
414414

415415
/* Run calibration of PS & PL as part of the sequence */
416416
scan_mask = BIT(0) | BIT(AMS_PS_SEQ_MAX);
417-
for (i = 0; i < indio_dev->num_channels; i++)
418-
scan_mask |= BIT_ULL(indio_dev->channels[i].scan_index);
417+
for (i = 0; i < indio_dev->num_channels; i++) {
418+
const struct iio_chan_spec *chan = &indio_dev->channels[i];
419+
420+
if (chan->scan_index < AMS_CTRL_SEQ_BASE)
421+
scan_mask |= BIT_ULL(chan->scan_index);
422+
}
419423

420424
if (ams->ps_base) {
421425
/* put sysmon in a soft reset to change the sequence */

0 commit comments

Comments
 (0)