Re: [PATCH v3] iio: cros_ec: Use platform sensor_num to unregister FIFO callback
From: Tzung-Bi Shih
Date: Sun Nov 08 2026 - 20:42:46 EST
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>