mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: mfe@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/6] driver: make struct bus_type::probe optional
Date: Wed, 28 Feb 2024 17:05:14 +0100	[thread overview]
Message-ID: <20240228160518.1589193-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240228160518.1589193-1-a.fatoum@pengutronix.de>

Newly introduce soc_bus_type doesn't define .probe, which would crash
once a driver is registered on that bus. Do as Linux does and defer
to the driver probe function if there's no bus probe function and
treat non-existence of either as a successful probe.

This has the added benefit that it will allow us to drop very simple bus
probe functions that just call the driver probe and do nothing else.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/base/driver.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index babc08f8b6b2..b2d428b70550 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -137,7 +137,12 @@ int device_probe(struct device *dev)
 
 	list_add(&dev->active, &active_device_list);
 
-	ret = dev->bus->probe(dev);
+	if (dev->bus->probe)
+		ret = dev->bus->probe(dev);
+	else if (dev->driver->probe)
+		ret = dev->driver->probe(dev);
+	else
+		ret = 0;
 
 	depth--;
 
-- 
2.39.2




  reply	other threads:[~2024-02-28 16:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 16:05 [PATCH 1/6] driver: make struct bus_type::match optional Ahmad Fatoum
2024-02-28 16:05 ` Ahmad Fatoum [this message]
2024-02-28 16:05 ` [PATCH 3/6] treewide: remove bus probe functions that just call driver probe Ahmad Fatoum
2024-02-28 16:05 ` [PATCH 4/6] usb: otg: maintain list of USB OTG controllers Ahmad Fatoum
2024-02-28 16:05 ` [PATCH 5/6] usb: otg: turn global otg device into device alias Ahmad Fatoum
2024-02-28 16:05 ` [PATCH 6/6] usb: print number of skipped OTG controllers when scanning Ahmad Fatoum
2024-02-29  8:10 ` [PATCH 1/6] driver: make struct bus_type::match optional Sascha Hauer

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=20240228160518.1589193-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=mfe@pengutronix.de \
    /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