Re: [PATCH v2] iio: cros_ec: Use platform sensor_num to unregister FIFO callback

From: Tzung-Bi Shih

Date: Thu Nov 05 2026 - 22:10:29 EST


On Thu, Nov 05, 2026 at 01:20:57PM +0000, Satyam Gupta wrote:
> No in-tree driver changes the field after probe, so mainline is not
> known to hit this. The ChromeOS RGB light sensor support does: it
> changes the field while a command is in flight, and unbinding the
> device then leaves a stale callback. Found by an AI code review agent.

I think this paragraph can be moved after "---" so that it isn't part of
the commit message.

> static void cros_ec_sensors_core_clean(void *arg)
> {
> struct platform_device *pdev = (struct platform_device *)arg;
> - struct cros_ec_sensorhub *sensor_hub =
> - dev_get_drvdata(pdev->dev.parent);
> - struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> - struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
> - u8 sensor_num = st->param.info.sensor_num;
> + struct device *dev = &pdev->dev;
> + struct cros_ec_sensorhub *sensor_hub = dev_get_drvdata(dev->parent);
> + struct cros_ec_sensor_platform *pdata = dev_get_platdata(dev);
>
> - cros_ec_sensorhub_unregister_push_data(sensor_hub, sensor_num);
> + cros_ec_sensorhub_unregister_push_data(sensor_hub, pdata->sensor_num);

So now `pdev` is only used to carry `dev`. How about just passing `dev`
to this function in [1] so that it can be simplified?

[1] https://elixir.bootlin.com/linux/v7.3/source/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c#L394