Sebastian Andrzej Siewior <[email protected]> writes: > This patch moves the module options idVendor, idProduct and bcdDevice > from composite.c into each gadgets. This ensures compatibility with > current gadgets and removes the global variable which brings me step > closer towards composite.c in libcomposite > > Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
> diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
> index e970fba..bc84afc 100644
> --- a/include/linux/usb/composite.h
> +++ b/include/linux/usb/composite.h
> @@ -381,6 +381,34 @@ extern int usb_string_ids_tab(struct usb_composite_dev
> *c,
> struct usb_string *str);
> extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
>
> +/*
> + * Some systems will need runtime overrides for the product identifiers
> + * published in the device descriptor, either numbers or strings or both.
> + * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
> + */
> +#define USB_GADGET_COMPOSITE_OPTIONS()
> \
> + static ushort idVendor; \
> + module_param(idVendor, ushort, S_IRUGO); \
> + MODULE_PARM_DESC(idVendor, "USB Vendor ID"); \
> + \
> + static ushort idProduct; \
> + module_param(idProduct, ushort, S_IRUGO); \
> + MODULE_PARM_DESC(idProduct, "USB Product ID"); \
> + \
> + static ushort bcdDevice; \
> + module_param(bcdDevice, ushort, S_IRUGO); \
> + MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)")
> +
> +#define USB_GADGET_COMPOSITE_OVERWRITE_VID_PID_BCD(__usb_desc)
> \
> + if (idVendor) \
> + __usb_desc.idVendor = cpu_to_le16(idVendor); \
> + \
> + if (idProduct) \
> + __usb_desc.idProduct = cpu_to_le16(idProduct); \
> + \
> + if (bcdDevice) \
> + __usb_desc.bcdDevice = cpu_to_le16(bcdDevice)
> +
Wrap with a “do { ... } while (0)”.
> /* messaging utils */
> #define DBG(d, fmt, args...) \
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo--
pgpCQ7lQeCV4E.pgp
Description: PGP signature
