summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2022-05-10 17:51:29 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-05-11 18:59:25 +0200
commitf9d76d15072caf1ec5558fa7cc6d93c7b9d33488 (patch)
treeed7dfff99994add27e32f3b32c4b49bac3271d89 /include
parentusb: gadget: uvc: track frames in format entries (diff)
downloadlinux-f9d76d15072caf1ec5558fa7cc6d93c7b9d33488.tar.xz
linux-f9d76d15072caf1ec5558fa7cc6d93c7b9d33488.zip
USB: gadget: Add ID numbers to gadget names
Putting USB gadgets on a new bus of their own encounters a problem when multiple gadgets are present: They all have the same name! The driver core fails with a "sys: cannot create duplicate filename" error when creating any of the /sys/bus/gadget/devices/<gadget-name> symbolic links after the first. This patch fixes the problem by adding a ".N" suffix to each gadget's name when the gadget is registered (where N is a unique ID number), thus making the names distinct. Reported-and-tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Fixes: fc274c1e9973 ("USB: gadget: Add a new bus for gadgets") Link: https://lore.kernel.org/r/YnqKAXKyp9Vq/pbn@rowland.harvard.edu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/usb/gadget.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index cf7af8a0a6e9..3ad58b7a0824 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -386,6 +386,7 @@ struct usb_gadget_ops {
* @lpm_capable: If the gadget max_speed is FULL or HIGH, this flag
* indicates that it supports LPM as per the LPM ECN & errata.
* @irq: the interrupt number for device controller.
+ * @id_number: a unique ID number for ensuring that gadget names are distinct
*
* Gadgets have a mostly-portable "gadget driver" implementing device
* functions, handling all usb configurations and interfaces. Gadget
@@ -446,6 +447,7 @@ struct usb_gadget {
unsigned connected:1;
unsigned lpm_capable:1;
int irq;
+ int id_number;
};
#define work_to_gadget(w) (container_of((w), struct usb_gadget, work))