Re: [PATCH v3] iio: cros_ec: Use platform sensor_num to unregister FIFO callback
From: Jonathan Cameron
Date: Sat Nov 14 2026 - 17:34:51 EST
On Mon, 9 Nov 2026 01:42:25 +0000
Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
> On Fri, Nov 06, 2026 at 07:19:04AM +0000, Satyam Gupta wrote:
> > cros_ec_sensors_core_register() registers the FIFO callback for the
> > sensor number found in the platform data. The matching cleanup action,
> > cros_ec_sensors_core_clean(), reads the number back from
> > st->param.info.sensor_num instead.
> >
> > st->param is the EC host command buffer. Drivers fill it in under
> > cmd_lock before each command, while the cleanup action reads it without
> > that lock. It is also set only for physical sensors. If the field holds
> > another value when the device is unbound, the cleanup clears the wrong
> > slot and leaves the callback in place, still pointing to the iio_dev
> > that is about to be freed.
> >
> > Use the platform data in the cleanup action too, and pass the struct
> > device pointer directly to devm_add_action_or_reset(), so it always
> > unregisters the slot that cros_ec_sensors_core_register() registered.
> >
> > Fixes: aa984f1ba4a4 ("iio: cros_ec: Register to cros_ec_sensorhub when EC supports FIFO")
> > Signed-off-by: Satyam Gupta <sgsatyam@xxxxxxxxxx>
>
> Other than the fact that it wasn't sent independently, the patch itself
> looks good to me.
>
> Reviewed-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>
Applied to the fixes-togreg branch of iio.git and marked for stable
thanks.
Jonathan