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 <[email protected]>
---

 drivers/usb/emul/usb-emul-uclass.c |  5 ++---
 include/usb.h                      | 11 +++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/emul/usb-emul-uclass.c 
b/drivers/usb/emul/usb-emul-uclass.c
index 1203eb2..359d0da 100644
--- a/drivers/usb/emul/usb-emul-uclass.c
+++ b/drivers/usb/emul/usb-emul-uclass.c
@@ -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);
diff --git a/include/usb.h b/include/usb.h
index 63edddd..3766514 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -1056,6 +1056,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
  *
  * Clear out any address information in the emulators and make then ready for
-- 
2.7.4

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to