1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-25 04:21:18 +02:00

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>
This commit is contained in:
Hans de Goede
2015-05-05 11:54:31 +02:00
committed by Simon Glass
parent 134692af13
commit f78a5c0774
2 changed files with 7 additions and 17 deletions

View File

@@ -476,9 +476,7 @@ int usb_scan_device(struct udevice *parent, int port,
*devp = NULL; *devp = NULL;
memset(udev, '\0', sizeof(*udev)); memset(udev, '\0', sizeof(*udev));
ret = usb_get_bus(parent, &udev->controller_dev); udev->controller_dev = usb_get_bus(parent);
if (ret)
return ret;
priv = dev_get_uclass_priv(udev->controller_dev); priv = dev_get_uclass_priv(udev->controller_dev);
/* /*
@@ -578,35 +576,28 @@ int usb_child_post_bind(struct udevice *dev)
return 0; return 0;
} }
int usb_get_bus(struct udevice *dev, struct udevice **busp) struct udevice *usb_get_bus(struct udevice *dev)
{ {
struct udevice *bus; struct udevice *bus;
*busp = NULL;
for (bus = dev; bus && device_get_uclass_id(bus) != UCLASS_USB; ) for (bus = dev; bus && device_get_uclass_id(bus) != UCLASS_USB; )
bus = bus->parent; bus = bus->parent;
if (!bus) { if (!bus) {
/* By design this cannot happen */ /* By design this cannot happen */
assert(bus); assert(bus);
debug("USB HUB '%s' does not have a controller\n", dev->name); 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) int usb_child_pre_probe(struct udevice *dev)
{ {
struct udevice *bus;
struct usb_device *udev = dev_get_parentdata(dev); struct usb_device *udev = dev_get_parentdata(dev);
struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); struct usb_dev_platdata *plat = dev_get_parent_platdata(dev);
int ret; int ret;
ret = usb_get_bus(dev, &bus); udev->controller_dev = usb_get_bus(dev);
if (ret)
return ret;
udev->controller_dev = bus;
udev->dev = dev; udev->dev = dev;
udev->devnum = plat->devnum; udev->devnum = plat->devnum;
udev->slot_id = plat->slot_id; udev->slot_id = plat->slot_id;

View File

@@ -742,11 +742,10 @@ int usb_scan_device(struct udevice *parent, int port,
* will be a device with uclass UCLASS_USB. * will be a device with uclass UCLASS_USB.
* *
* @dev: Device to check * @dev: Device to check
* @busp: Returns bus, or NULL if not found * @return The bus, or NULL if not found (this indicates a critical error in
* @return 0 if OK, -EXDEV is somehow this bus does not have a controller (this * the USB stack
* indicates a critical error in the USB stack
*/ */
int usb_get_bus(struct udevice *dev, struct udevice **busp); struct udevice *usb_get_bus(struct udevice *dev);
/** /**
* usb_select_config() - Set up a device ready for use * usb_select_config() - Set up a device ready for use