Re: [PATCH v3 1/2] soc: imx8m: Probe the SoC driver as platform driver

From: Arnd Bergmann
Date: Sat Sep 28 2024 - 10:09:42 EST


On Fri, Sep 27, 2024, at 22:27, Saravana Kannan wrote:
> On Fri, Sep 27, 2024 at 2:55 PM Marek Vasut <marex@xxxxxxx> wrote:
>> >
>> > I'm glad it's working for you, but I think there might still be a race
>> > that you are just lucky enough to not hit. I think you still need to
>> > fix up drivers/base/soc.c to return -EPROBE_DEFER when
>> > soc_device_match() is called but soc_bus_type has no devices
>> > registered. That way any drivers that try to use that API will defer
>> > probe until this device gets to probe.
>>
>> soc_device_match() returns a pointer to soc_device_attribute or NULL, do
>> you have some other function in mind ?
>
> No, I'm talking about the same function. I'm asking to change it to
> return ERR_PTR(-EPROBE_DEFER) instead
> of NULL if no soc device has been registered yet.
>
> And you'll also go change all the drivers that use that API and are on
> the IMX boards supported by this soc driver, to handle the
> -EPROBE_DEFER correctly.
>
> And this error will only get returned for boards that do async probing
> and using a platform device to register the soc device. So it's
> not going to break everyone if you do this change.

I don't like it when an interface can return both NULL an
ERR_PTR(), that just makes it too easy to be used incorrectly.

Changing it to always return ERR_PTR() on an error is still
risky, e.g. when a new driver gets merged that did get the
same treewide API change, so if we do that, this should
probably also change either the function name or the prototype.

Arnd