]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
usb: emul: Expose find_descriptor() as a public API
authorBin Meng <bmeng.cn@gmail.com>
Sun, 1 Oct 2017 13:19:40 +0000 (06:19 -0700)
committerMarek Vasut <marex@denx.de>
Sun, 1 Oct 2017 14:32:51 +0000 (16:32 +0200)
This can be useful outside of the sandbox usb emulation uclass
driver. Expose it as a public API with a proper prefix (usb_emul_).

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
drivers/usb/emul/usb-emul-uclass.c
include/usb.h

index 1203eb2f11a8e88dc22aa6def5fa509d5eb5e5d2..359d0da07e604f14c26333229f6fa024250991cc 100644 (file)
@@ -52,7 +52,7 @@ static int usb_emul_get_string(struct usb_string *strings, int index,
        return -EINVAL;
 }
 
-static struct usb_generic_descriptor **find_descriptor(
+struct usb_generic_descriptor **usb_emul_find_descriptor(
                struct usb_generic_descriptor **ptr, int type, int index)
 {
        debug("%s: type=%x, index=%d\n", __func__, type, index);
@@ -91,8 +91,7 @@ static int usb_emul_get_descriptor(struct usb_dev_platdata *plat, int value,
                                           length);
        }
 
-       ptr = find_descriptor((struct usb_generic_descriptor **)plat->desc_list,
-                             type, index);
+       ptr = usb_emul_find_descriptor(plat->desc_list, type, index);
        if (!ptr) {
                debug("%s: Could not find descriptor type %d, index %d\n",
                      __func__, type, index);
index 63eddddc914fb35717278fc546be8e683d02755f..37665146359af52e52083a872ba71f17f6741be7 100644 (file)
@@ -1055,6 +1055,17 @@ int usb_emul_find(struct udevice *bus, ulong pipe, int port1,
  */
 int usb_emul_find_for_dev(struct udevice *dev, struct udevice **emulp);
 
+/**
+ * usb_emul_find_descriptor() - Find a USB descriptor of a particular device
+ *
+ * @ptr:       a pointer to a list of USB descriptor pointers
+ * @type:      type of USB descriptor to find
+ * @index:     if @type is USB_DT_CONFIG, this is the configuration value
+ * @return a pointer to the USB descriptor found, NULL if not found
+ */
+struct usb_generic_descriptor **usb_emul_find_descriptor(
+               struct usb_generic_descriptor **ptr, int type, int index);
+
 /**
  * usb_emul_reset() - Reset all emulators ready for use
  *