Skip to contentSkip to conversation

iio: adc: nxp-sar-adc: notify trigger on channel read error in buffer ISR

PATCH In review Stepan Ionichev 3 participants 3 messages May 17 – May 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: nxp-sar-adc: notify trigger on channel read error in buffer ISR

nxp_sar_adc_isr_buffer() bails on the first channel-read failure without calling iio_trigger_notify_done(), so a single I/O error leaves the trigger's use_count stuck and the buffer flow wedged until rebind.

Route the error exit through a 'done:' label that always calls iio_trigger_notify_done().

Fixes 4434072a893e ("iio: adc: Add the NXP SAR ADC support for the s32g2/3 platforms")
---
 drivers/iio/adc/nxp-sar-adc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/nxp-sar-adc.c +2 -1
index 9d9f2c76b..ed004812c 100644
@@ -341,7 +341,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
 		ret = nxp_sar_adc_read_data(info, info->buffered_chan[i]);
 		if (ret < 0) {
 			nxp_sar_adc_read_notify(info);
-			return;
+			goto done;
 		}
 
 		info->buffer[i] = ret;
@@ -352,6 +352,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
 	iio_push_to_buffers_with_ts(indio_dev, info->buffer, sizeof(info->buffer),
 				    iio_get_time_ns(indio_dev));
 
+done:
 	iio_trigger_notify_done(indio_dev->trig);
 }
 
Signature · 1 line
2.43.0
reviewer
#1 lore raw
Quoted 29 lines · Stepan Ionichev

nxp_sar_adc_isr_buffer() bails on the first channel-read failure without calling iio_trigger_notify_done(), so a single I/O error leaves the trigger's use_count stuck and the buffer flow wedged until rebind.

Route the error exit through a 'done:' label that always calls iio_trigger_notify_done().

Fixes 4434072a893e ("iio: adc: Add the NXP SAR ADC support for the s32g2/3 platforms")
---
 drivers/iio/adc/nxp-sar-adc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/nxp-sar-adc.c +1 -1
index 9d9f2c76b..ed004812c 100644
@@ -341,7 +341,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
 		ret = nxp_sar_adc_read_data(info, info->buffered_chan[i]);
 		if (ret < 0) {
 			nxp_sar_adc_read_notify(info);
-			return;
+			goto done;
 		}
 
 		info->buffer[i] = ret;

drivers/iio/adc/nxp-sar-adc.c static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev) · line 358

Quoted 7 lines
drivers/iio/adc/nxp-sar-adc.c +1 -0
@@ -352,6 +352,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
 	iio_push_to_buffers_with_ts(indio_dev, info->buffer, sizeof(info->buffer),
 				    iio_get_time_ns(indio_dev));
 
+done:
 	iio_trigger_notify_done(indio_dev->trig);
 }
 

This is fine. Although we are already duplicating the call to nxp_sar_adc_read_notify(). So could be OK to just call iio_trigger_notify_done() and return too. Let's see if anyone else has an opinion.

maintainer
#2 lore raw
Quoted 33 lines · On Sun, 17 May 2026 12:07:33 -0500 David Lechner <[email protected]> wrote:
Quoted 32 lines · Stepan Ionichev

nxp_sar_adc_isr_buffer() bails on the first channel-read failure without calling iio_trigger_notify_done(), so a single I/O error leaves the trigger's use_count stuck and the buffer flow wedged until rebind.

Route the error exit through a 'done:' label that always calls iio_trigger_notify_done().

Fixes 4434072a893e ("iio: adc: Add the NXP SAR ADC support for the s32g2/3 platforms")
---
 drivers/iio/adc/nxp-sar-adc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/nxp-sar-adc.c +1 -1
index 9d9f2c76b..ed004812c 100644
@@ -341,7 +341,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
 		ret = nxp_sar_adc_read_data(info, info->buffered_chan[i]);
 		if (ret < 0) {
 			nxp_sar_adc_read_notify(info);
-			return;
+			goto done;
 		}
 
 		info->buffer[i] = ret;
@@ -352,6 +352,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
 	iio_push_to_buffers_with_ts(indio_dev, info->buffer, sizeof(info->buffer),
 				    iio_get_time_ns(indio_dev));
 
Quoted 9 lines

drivers/iio/adc/nxp-sar-adc.c static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev) · line 358

Quoted 4 lines
drivers/iio/adc/nxp-sar-adc.c +1 -0
+done:
 	iio_trigger_notify_done(indio_dev->trig);
 }
 

This is fine. Although we are already duplicating the call to nxp_sar_adc_read_notify(). So could be OK to just call iio_trigger_notify_done() and return too. Let's see if anyone else has an opinion.

Similar questions arise for this one to the rohm one I just reviewed
- does this actually help us? What is the trigger, and is it going to be in a state where it will ever refire if an error occurs in here? Here we aren't dealing in bus issues, it's a state machine issue (either software bug or hardware in wrong state) if we hit these error paths.

That info needs to be in the commit description and again to me this is a hardening change rather than a fix (with need to backport etc).

Jonathan

Quoted 1 line