diff options
author | Julius Werner <jwerner@chromium.org> | 2014-04-08 12:54:25 -0700 |
---|---|---|
committer | Marc Jones <marc.jones@se-eng.com> | 2014-11-13 06:22:45 +0100 |
commit | 7234d60a6e6ee3a3403865ad1469105ff1d92c4e (patch) | |
tree | d4bb49b8cb95ae5b6efd655c2aa32b6ce5ded690 /payloads/libpayload/drivers/usb/ohci_rh.c | |
parent | badf0f974479cf16134063d7c8c17bd1a30273d7 (diff) | |
download | coreboot-7234d60a6e6ee3a3403865ad1469105ff1d92c4e.tar.xz |
libpayload: usb: Fix up usb_shutdown() code paths
This patch combines a few minor fixes and refactoring to the various
host controller and root hub drivers to ensure they all do the right
thing on a call to usb_exit(). It puts a usb_detach_device(0) call
into detach_controller() so that the HCD doesn't need to remember to
tear down the root hub itself, and makes sure all root hubs properly
detach the subtree of devices connected to their ports first (as
generic_hub and by extension XHCI had already been doing).
It also fixes up some missing free() calls and replaces most 'ptr =
malloc(); if (!ptr) fatal()' idioms with the new x(z)alloc().
BUG=chromium:343415
TEST=Tested EHCI on Big and OHCI, EHCI, and XHCI on Snow. Could not test
UHCI (unless anyone volunteers to port coreboot to a ZGB? ;) ), but the
changes are really tame.
Original-Change-Id: I6eca51ff2685d0946fe4267ad7d3ec48ad7fc510
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/193731
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 5791b546e5a21a360d0c65888a5b92d5f48f8178)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I00138f0aeceb12ed721f7368c7788c9b6bee227d
Reviewed-on: http://review.coreboot.org/7222
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'payloads/libpayload/drivers/usb/ohci_rh.c')
-rw-r--r-- | payloads/libpayload/drivers/usb/ohci_rh.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/payloads/libpayload/drivers/usb/ohci_rh.c b/payloads/libpayload/drivers/usb/ohci_rh.c index b3bf7ef3cb..5d82bd59e0 100644 --- a/payloads/libpayload/drivers/usb/ohci_rh.c +++ b/payloads/libpayload/drivers/usb/ohci_rh.c @@ -83,6 +83,11 @@ ohci_rh_enable_port (usbdev_t *dev, int port) static void ohci_rh_disable_port (usbdev_t *dev, int port) { + if (RH_INST (dev)->port[port] != -1) { + usb_detach_device(dev->controller, RH_INST (dev)->port[port]); + RH_INST (dev)->port[port] = -1; + } + OHCI_INST (dev->controller)->opreg->HcRhPortStatus[port] = ClearPortEnable; // disable port int timeout = 50; /* timeout after 50 * 100us == 5ms */ while ((OHCI_INST (dev->controller)->opreg->HcRhPortStatus[port] @@ -180,12 +185,9 @@ ohci_rh_init (usbdev_t *dev) dev->destroy = ohci_rh_destroy; dev->poll = ohci_rh_poll; - dev->data = malloc (sizeof (rh_inst_t)); - if (!dev->data) - fatal("Not enough memory for OHCI RH.\n"); - + dev->data = xmalloc (sizeof (rh_inst_t)); RH_INST (dev)->numports = OHCI_INST (dev->controller)->opreg->HcRhDescriptorA & NumberDownstreamPortsMask; - RH_INST (dev)->port = malloc(sizeof(int) * RH_INST (dev)->numports); + RH_INST (dev)->port = xmalloc(sizeof(int) * RH_INST (dev)->numports); usb_debug("%d ports registered\n", RH_INST (dev)->numports); for (i = 0; i < RH_INST (dev)->numports; i++) { |