Re: [PATCH v3 2/2] iio: adc: ad_sigma_delta: fix clear_pending_event for registerless devices

From: Jonathan Cameron

Date: Wed May 20 2026 - 08:32:25 EST


On Mon, 18 May 2026 12:55:33 +0000
"Sabau, Radu bogdan" <Radu.Sabau@xxxxxxxxxx> wrote:

> Hi everyone, I am responding to Sashiko's review here:
>
> > -----Original Message-----
> > From: Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@xxxxxxxxxx>
> > Sent: Monday, May 18, 2026 12:59 PM
>
> ...
>
> > + } else if (sigma_delta->info->has_registers) {
> > unsigned int status_reg;
> >
> > ret = ad_sd_read_reg(sigma_delta, AD_SD_REG_STATUS, 1,
> > &status_reg);
> > @@ -274,6 +279,8 @@ static int ad_sigma_delta_clear_pending_event(struct
> > ad_sigma_delta *sigma_delta
> > return ret;
> >
> > pending_event = !(status_reg & AD_SD_REG_STATUS_RDY);
> > + } else {
> > + return 0;
> > }
>
> He is right about this one, the heap corruption may not be fully solved as a
> registerless device with num_resetclks = 0 confiugred with rdy-gpios could
> still have data_read_len = 0 further if GPIO indicates a pending event.
>
> Perhaps I data_read_len == 0 should indeed be checked before attempting the
> dummy SPI transfer as suggested, right?
Indeed seems valid. Make sure to leave some comments around on the
'why' of the extra check

>
> >
> > if (!pending_event)
> > @@ -578,6 +585,7 @@ static int ad_sd_buffer_postenable(struct iio_dev
> > *indio_dev)
> >
> > err_unlock:
> > sigma_delta->keep_cs_asserted = false;
> > + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
>
> Also right about this one, it belongs in previous patch...
>
> > sigma_delta->bus_locked = false;
> > spi_bus_unlock(sigma_delta->spi->controller);
> > spi_unoptimize_message(&sigma_delta->sample_msg);
> >
> > --
> > 2.43.0
> >
>