[PATCH 7/8] usb: add fallback ->detect method for USB host drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux