aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/emul
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-11-08 23:47:55 -0700
committerSimon Glass <sjg@chromium.org>2015-11-19 20:27:51 -0700
commitaf9c7c11e97ce99a8b8a0de99f91bde1b703377e (patch)
tree174b9e5b545fac3c1d50c8dbc91b187a0a3fcd4b /drivers/usb/emul
parent80438a6c71b95b2749bdf5c58f7ff26f2907f3d5 (diff)
downloadu-boot-af9c7c11e97ce99a8b8a0de99f91bde1b703377e.zip
u-boot-af9c7c11e97ce99a8b8a0de99f91bde1b703377e.tar.gz
u-boot-af9c7c11e97ce99a8b8a0de99f91bde1b703377e.tar.bz2
sandbox: usb: Allow finding a USB emulator for a device
Each USB device has an emulator. Currently this can only be found by supplying the 'pipe' value, which contains the device number. Add a way to find it directly from the emulated device. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/usb/emul')
-rw-r--r--drivers/usb/emul/usb-emul-uclass.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/usb/emul/usb-emul-uclass.c b/drivers/usb/emul/usb-emul-uclass.c
index 205f2c5..6b5f3c0 100644
--- a/drivers/usb/emul/usb-emul-uclass.c
+++ b/drivers/usb/emul/usb-emul-uclass.c
@@ -108,9 +108,8 @@ static int usb_emul_get_descriptor(struct usb_dev_platdata *plat, int value,
return upto ? upto : length ? -EIO : 0;
}
-int usb_emul_find(struct udevice *bus, ulong pipe, struct udevice **emulp)
+static int usb_emul_find_devnum(int devnum, struct udevice **emulp)
{
- int devnum = usb_pipedevice(pipe);
struct udevice *dev;
struct uclass *uc;
int ret;
@@ -134,6 +133,20 @@ int usb_emul_find(struct udevice *bus, ulong pipe, struct udevice **emulp)
return -ENOENT;
}
+int usb_emul_find(struct udevice *bus, ulong pipe, struct udevice **emulp)
+{
+ int devnum = usb_pipedevice(pipe);
+
+ return usb_emul_find_devnum(devnum, emulp);
+}
+
+int usb_emul_find_for_dev(struct udevice *dev, struct udevice **emulp)
+{
+ struct usb_dev_platdata *udev = dev_get_parent_platdata(dev);
+
+ return usb_emul_find_devnum(udev->devnum, emulp);
+}
+
int usb_emul_control(struct udevice *emul, struct usb_device *udev,
unsigned long pipe, void *buffer, int length,
struct devrequest *setup)