From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 7/8] usb: add fallback ->detect method for USB host drivers
Date: Fri, 29 Jan 2021 17:11:15 +0100 [thread overview]
Message-ID: <20210129161116.9971-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20210129161116.9971-1-a.fatoum@pengutronix.de>
We already maintain a list of USB host controllers, so we can use that
to implement a generic detect callback. Currently, all drivers define
their own, which uses driver-specific means to arrive at the struct
usb_host and then call usb_host_detect().
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/usb/core/usb.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index ea244d4bcf6c..938a28e030bf 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -88,11 +88,25 @@ static inline void usb_host_release(struct usb_host *host)
slice_release(&host->slice);
}
+static int usb_hw_detect(struct device_d *dev)
+{
+ struct usb_host *host;
+
+ list_for_each_entry(host, &host_list, list) {
+ if (dev == host->hw_dev)
+ return usb_host_detect(host);
+ }
+
+ return -ENODEV;
+}
+
int usb_register_host(struct usb_host *host)
{
list_add_tail(&host->list, &host_list);
host->busnum = host_busnum++;
slice_init(&host->slice, dev_name(host->hw_dev));
+ if (!host->hw_dev->detect)
+ host->hw_dev->detect = usb_hw_detect;
return 0;
}
--
2.30.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-01-29 16:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 16:11 [PATCH 1/8] commands: usbgadget: remove deprecated s option from help text Ahmad Fatoum
2021-01-29 16:11 ` [PATCH 2/8] asm-generic: define fallback memcpy and memset for device I/O Ahmad Fatoum
2021-02-02 19:03 ` Sascha Hauer
2021-02-02 19:41 ` Ahmad Fatoum
2021-02-04 10:12 ` Sascha Hauer
2021-01-29 16:11 ` [PATCH 3/8] ARM: <asm/io.h>: define macros for I/O memcpy/memset Ahmad Fatoum
2021-01-29 16:11 ` [PATCH 4/8] asm-generic: io.h: remove wrong use of IOMEM Ahmad Fatoum
2021-02-01 8:57 ` Sascha Hauer
2021-02-01 8:59 ` Ahmad Fatoum
2021-01-29 16:11 ` [PATCH 5/8] ppc: <asm/io.h>: remove duplicate definition Ahmad Fatoum
2021-01-29 16:11 ` [PATCH 6/8] printk: port over Linux print_hex_dump_bytes/print_hex_dump_debug Ahmad Fatoum
2021-01-29 16:11 ` Ahmad Fatoum [this message]
2021-01-29 16:11 ` [PATCH 8/8] usb: host: ehci: remove duplicated usb_host_detect() calls Ahmad Fatoum
2021-02-01 9:07 ` [PATCH 1/8] commands: usbgadget: remove deprecated s option from help text 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=20210129161116.9971-7-a.fatoum@pengutronix.de \
--to=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