Re: [PATCH v3] iio: cros_ec: Use platform sensor_num to unregister FIFO callback
From: Joshua Crofts
Date: Fri Nov 06 2026 - 04:32:53 EST
On Fri, 6 Nov 2026 07:19:04 +0000
Satyam Gupta <sgsatyam@xxxxxxxxxx> 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>
> ---
> Changes in v3:
> - Pass dev instead of pdev to devm_add_action_or_reset() and drop the
> unused pdev local variable (Tzung-Bi).
> - Move the note about out-of-tree triggers and how the issue was found
> below '---' (Tzung-Bi).
>
No, don't send a new version of a patch as a reply to the
previous version, it may break tooling like b4 for example.
--
Joshua Crofts