From: Marco Felsch <m.felsch@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] of: platform: return -EPROBE_DEFER when ensuring probe with driver missing
Date: Sat, 17 Feb 2024 00:02:37 +0100 [thread overview]
Message-ID: <20240216230237.7fk6luetjyu7nwbo@pengutronix.de> (raw)
In-Reply-To: <20240216220649.2328345-1-a.fatoum@pengutronix.de>
Hi Ahmad,
On 24-02-16, Ahmad Fatoum wrote:
> -ENODEV is a bad choice for an error code for of_device_ensure_probed.
>
> The function is either called from board code or from driver frameworks,
> which usually just propagate the error code with unintended
> consequences:
>
> - A board driver probe function returning -ENODEV is silently skipped
>
> - A driver framework function returning -ENODEV is often interpreted
> to mean that an optional resource is not specified (e.g. in DT).
>
> In both cases, the user isn't provided an error message and wrong
> behavior can crop up later. In my case, the XHCI driver would time out,
> because phy_get propagated of_device_ensure_probed's -ENODEV, which was
> understood to mean that no PHY is needed and not that the PHY is
> specified in the DT, but no driver was bound to it.
>
> Instead of -ENODEV, let's thus return -EPROBE_DEFER. This can be
> propagated up to the driver core, which on a deep probe system (the only
> ones where of_device_ensure_probed is not a no-op) will print a fat red
> error message. We could achieve the same with some other error code, but
This big fat error should indicate that something went really wrong.
> -EPROBE_DEFER is what a non-deep-probe system would return when probes
> are deferred indefinitely, so symmetry in the deep probe case fits well.
Albeit I get your point, I'm not very happy to return this error code
here since the whole idea of deep-probe was to get rid of EPROBE_DEFER.
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/of/platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 060fa3458bd2..664af49d268f 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -504,7 +504,7 @@ int of_device_ensure_probed(struct device_node *np)
> * requirements are fulfilled if 'dev->driver' is not NULL.
> */
> if (!dev->driver)
> - return -ENODEV;
> + return -EPROBE_DEFER;
What about a new error code, e.g. ENODRV which is only used once in this
function? Additional we can add an error message like:
pr_err("No driver found for %pO\n, np); since we know that the driver is
missing.
If you want to stick with -EPROBE_DEFER you need at least adapt the
above comment and the function doc.
Regards,
Marco
>
> return 0;
> }
> --
> 2.39.2
>
>
>
next prev parent reply other threads:[~2024-02-16 23:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 22:06 Ahmad Fatoum
2024-02-16 22:06 ` [PATCH 2/2] phy: freescale: imx8mq-usb: make i.MX8MP support more explicit Ahmad Fatoum
2024-02-16 23:02 ` Marco Felsch [this message]
2024-02-17 9:16 ` [PATCH 1/2] of: platform: return -EPROBE_DEFER when ensuring probe with driver missing Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240216230237.7fk6luetjyu7nwbo@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox