diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-05-05 11:54:31 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-05-05 20:58:41 -0600 |
commit | f78a5c0774da9ca1702df453f974f022580552f4 (patch) | |
tree | c654b04dbbe16a3b653db1a7f8c00fa84500f5d7 /drivers/usb | |
parent | 134692af138243fca1037fc737651281701a9ab3 (diff) | |
download | u-boot-imx-f78a5c0774da9ca1702df453f974f022580552f4.zip u-boot-imx-f78a5c0774da9ca1702df453f974f022580552f4.tar.gz u-boot-imx-f78a5c0774da9ca1702df453f974f022580552f4.tar.bz2 |
dm: usb: Make usb_get_bus easier to use for callers
Make usb_get_bus easier to use for callers, by directly returning the bus
rather then returning it via a pass-by-ref argument.
This also removes the error checking from the current callers, as
we already have an assert() for bus not being NULL in usb_get_bus().
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/host/usb-uclass.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 8dc1823..ba7d32a 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -476,9 +476,7 @@ int usb_scan_device(struct udevice *parent, int port, *devp = NULL; memset(udev, '\0', sizeof(*udev)); - ret = usb_get_bus(parent, &udev->controller_dev); - if (ret) - return ret; + udev->controller_dev = usb_get_bus(parent); priv = dev_get_uclass_priv(udev->controller_dev); /* @@ -578,35 +576,28 @@ int usb_child_post_bind(struct udevice *dev) return 0; } -int usb_get_bus(struct udevice *dev, struct udevice **busp) +struct udevice *usb_get_bus(struct udevice *dev) { struct udevice *bus; - *busp = NULL; for (bus = dev; bus && device_get_uclass_id(bus) != UCLASS_USB; ) bus = bus->parent; if (!bus) { /* By design this cannot happen */ assert(bus); debug("USB HUB '%s' does not have a controller\n", dev->name); - return -EXDEV; } - *busp = bus; - return 0; + return bus; } int usb_child_pre_probe(struct udevice *dev) { - struct udevice *bus; struct usb_device *udev = dev_get_parentdata(dev); struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); int ret; - ret = usb_get_bus(dev, &bus); - if (ret) - return ret; - udev->controller_dev = bus; + udev->controller_dev = usb_get_bus(dev); udev->dev = dev; udev->devnum = plat->devnum; udev->slot_id = plat->slot_id; |