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;
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)
*/
int usb_emul_find(struct udevice *bus, ulong pipe, struct udevice **emulp);
+/**
+ * usb_emul_find_for_dev() - Find an emulator for a particular device
+ *
+ * @bus: USB bus (controller)
+ * @dev: USB device to check
+ * @emulp: Returns pointer to emulator, or NULL if not found
+ * @return 0 if found, -ve on error
+ */
+int usb_emul_find_for_dev(struct udevice *dev, struct udevice **emulp);
+
/**
* usb_emul_reset() - Reset all emulators ready for use
*