On Thu, May 22, 2025 at 9:15 AM Maud Spierings maud_spierings@hotmail.com wrote:
I have found a fix but I don't know if it is correct to do. This deals with the deferred probe correctly, no longer panics and registers the device properly. This is the patch I have come up with:
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 1b4287991d00a..494206f8de5b0 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -231,7 +231,7 @@ int st_sensors_power_enable(struct iio_dev *indio_dev) ARRAY_SIZE(regulator_names), regulator_names); if (err)
return dev_err_probe(&indio_dev->dev, err,
return dev_err_probe(parent, err, "unable to enable supplies\n"); return 0;
It's the right fix.
If you look in drivers/iio/accel/st_accel_i2c.c clearly the driver enables the power before calling st_accel_common_probe() which is where devm_iio_device_register() is finally called and the IIO struct device get initialized.
And that's not all: st_sensors_init_sensor is also called before the iio device is present, so this:
} else dev_info(&indio_dev->dev, "Full-scale not possible\n");
and this:
dev_info(&indio_dev->dev, "set interrupt line to open drain mode on pin %d\n", sdata->drdy_int_pin);
is also unacceptable.
I hope there are not more...
They also need to use indio_dev->dev.parent, or a local copy of that struct device *, so please fix them too in the same patch.
I tried to chase down a Fixes: candidate but this misunderstanding goes way back and such prints were introduced several times.
I would just tag on Cc: stable@vger.kernel.org and be done with it.
Thanks for drilling into this!
Yours, Linus Walleij