Re: [PATCH 2/2] iio: st_sensors: Fix null pointer on defer_probe error
From: Andy Shevchenko
Date: Mon Jul 25 2022 - 17:25:04 EST
On Sun, Jul 24, 2022 at 7:01 PM Matti Lehtimäki
<matti.lehtimaki@xxxxxxxxx> wrote:
>
> dev_err_probe() calls __device_set_deferred_probe_reason()
> on -EPROBE_DEFER error. The device pointer to driver core private
> structure is not yet initialized at this stage for the iio device causing
> a null pointer error. Use parent device instead.
the parent device pointer
...
> pdata->vdd = devm_regulator_get(parent, "vdd");
> if (IS_ERR(pdata->vdd))
> - return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd),
> + return dev_err_probe(indio_dev->dev.parent, PTR_ERR(pdata->vdd),
> "unable to get Vdd supply\n");
Why not use the 'parent' variable?
...
> pdata->vdd_io = devm_regulator_get(parent, "vddio");
> if (IS_ERR(pdata->vdd_io))
> - return dev_err_probe(&indio_dev->dev, PTR_ERR(pdata->vdd_io),
> + return dev_err_probe(indio_dev->dev.parent, PTR_ERR(pdata->vdd_io),
Ditto.
> "unable to get Vdd_IO supply\n");
--
With Best Regards,
Andy Shevchenko