summaryrefslogtreecommitdiffstats
path: root/include/usb.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-03-25 12:22:01 -0600
committerSimon Glass <sjg@chromium.org>2015-04-18 11:11:20 -0600
commit79b5888729b65e7040d6a964f0015fc2c21b2385 (patch)
tree3497e7a22e622a32b7f3257682456087b17e409c /include/usb.h
parentcad4291cd053f8eaa404e47ab289a6169c19ae93 (diff)
downloadblackbird-obmc-uboot-79b5888729b65e7040d6a964f0015fc2c21b2385.tar.gz
blackbird-obmc-uboot-79b5888729b65e7040d6a964f0015fc2c21b2385.zip
dm: usb: Adjust usb_alloc_new_device() to return an error
This function returns NULL on error at present. Adjust it so that we can return a real error, as is needed with driver model. Also improve the error handling in its caller, usb_hub_port_connect_change(), and adjust the code order to prepare for driver model. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'include/usb.h')
-rw-r--r--include/usb.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/include/usb.h b/include/usb.h
index 67615eaa22..8cedaa23f8 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -703,10 +703,26 @@ void usb_hub_reset(void);
int hub_port_reset(struct usb_device *dev, int port,
unsigned short *portstat);
-struct usb_device *usb_alloc_new_device(void *controller);
+/**
+ * usb_alloc_new_device() - Allocate a new device
+ *
+ * @devp: returns a pointer of a new device structure. With driver model this
+ * is a device pointer, but with legacy USB this pointer is
+ * driver-specific.
+ * @return 0 if OK, -ENOSPC if we have found out of room for new devices
+ */
+int usb_alloc_new_device(struct udevice *controller, struct usb_device **devp);
+
+/**
+ * usb_free_device() - Free a partially-inited device
+ *
+ * This is an internal function. It is used to reverse the action of
+ * usb_alloc_new_device() when we hit a problem during init.
+ */
+void usb_free_device(struct udevice *controller);
int usb_new_device(struct usb_device *dev);
-void usb_free_device(void);
+
int usb_alloc_device(struct usb_device *dev);
#endif /*_USB_H_ */
OpenPOWER on IntegriCloud