summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/usb.c26
-rw-r--r--common/usb_hub.c2
2 files changed, 27 insertions, 1 deletions
diff --git a/common/usb.c b/common/usb.c
index 20c614cbcb0..6283f3992c7 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -148,6 +148,32 @@ int usb_stop(void)
return 0;
}
+/******************************************************************************
+ * Detect if a USB device has been plugged or unplugged.
+ */
+int usb_detect_change(void)
+{
+ int i, j;
+ int change = 0;
+
+ for (j = 0; j < USB_MAX_DEVICE; j++) {
+ for (i = 0; i < usb_dev[j].maxchild; i++) {
+ struct usb_port_status status;
+
+ if (usb_get_port_status(&usb_dev[j], i + 1,
+ &status) < 0)
+ /* USB request failed */
+ continue;
+
+ if (le16_to_cpu(status.wPortChange) &
+ USB_PORT_STAT_C_CONNECTION)
+ change++;
+ }
+ }
+
+ return change;
+}
+
/*
* disables the asynch behaviour of the control message. This is used for data
* transfers that uses the exclusiv access to the control and bulk messages.
diff --git a/common/usb_hub.c b/common/usb_hub.c
index af39c76f7fa..be01f4f257d 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -79,7 +79,7 @@ static int usb_get_hub_status(struct usb_device *dev, void *data)
data, sizeof(struct usb_hub_status), USB_CNTL_TIMEOUT);
}
-static int usb_get_port_status(struct usb_device *dev, int port, void *data)
+int usb_get_port_status(struct usb_device *dev, int port, void *data)
{
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port,