[PATCH 16/21] usb/gadget: push iManufacturer into gadgets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch pushes the iManufacturer module argument from composite into
each gadget. Once the user uses the module paramter, the string is
overwritten with the final value.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
 drivers/usb/gadget/composite.c |   20 +++++++++++---------
 include/linux/usb/composite.h  |    7 ++++++-
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index ee657f6..699de9c 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -32,10 +32,6 @@
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
  */
-static char *iManufacturer;
-module_param(iManufacturer, charp, S_IRUGO);
-MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
-
 static char *iProduct;
 module_param(iProduct, charp, S_IRUGO);
 MODULE_PARM_DESC(iProduct, "USB Product string");
@@ -916,8 +912,7 @@ static int get_string(struct usb_composite_dev *cdev,
 	 * check if the string has not been overridden.
 	 */
 	if (cdev->manufacturer_override == id)
-		str = iManufacturer ?: cdriver->iManufacturer ?:
-			composite_manufacturer;
+		str = cdriver->iManufacturer ?: composite_manufacturer;
 	else if (cdev->product_override == id)
 		str = iProduct ?: cdriver->iProduct;
 	else if (cdev->serial_override == id)
@@ -1408,6 +1403,7 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new,
 	__le16 idProduct;
 	__le16 bcdDevice;
 	u8 iSerialNumber;
+	u8 iManufacturer;
 
 	/*
 	 * these variables may have been set in
@@ -1417,6 +1413,7 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new,
 	idProduct = new->idProduct;
 	bcdDevice = new->bcdDevice;
 	iSerialNumber = new->iSerialNumber;
+	iManufacturer = new->iManufacturer;
 
 	*new = *old;
 	if (idVendor)
@@ -1427,6 +1424,8 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new,
 		new->bcdDevice = bcdDevice;
 	if (iSerialNumber)
 		new->iSerialNumber = iSerialNumber;
+	if (iManufacturer)
+		new->iManufacturer = iManufacturer;
 }
 
 static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv)
@@ -1487,9 +1486,8 @@ static int composite_bind(struct usb_gadget *gadget,
 	update_unchanged_dev_desc(&cdev->desc, cdriver->dev);
 
 	/* string overrides */
-	if (iManufacturer || !cdev->desc.iManufacturer) {
-		if (!iManufacturer && !cdriver->iManufacturer &&
-		    !*composite_manufacturer)
+	if (!cdev->desc.iManufacturer) {
+		if (!cdriver->iManufacturer)
 			snprintf(composite_manufacturer,
 				 sizeof composite_manufacturer,
 				 "%s %s with %s",
@@ -1713,4 +1711,8 @@ void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
 		desc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id;
 		dev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number;
 	}
+	if (covr->manufacturer) {
+		desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id;
+		dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer;
+	}
 }
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 9d068a4..86553c8 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -401,6 +401,7 @@ struct usb_composite_overwrite {
 	u16	idProduct;
 	u16	bcdDevice;
 	char	*serial_number;
+	char	*manufacturer;
 };
 #define USB_GADGET_COMPOSITE_OPTIONS()					\
 	static struct usb_composite_overwrite coverwrite;		\
@@ -416,7 +417,11 @@ struct usb_composite_overwrite {
 									\
 	module_param_named(iSerialNumber, coverwrite.serial_number, charp, \
 			S_IRUGO); \
-	MODULE_PARM_DESC(iSerialNumber, "SerialNumber string")
+	MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");		\
+									\
+	module_param_named(iManufacturer, coverwrite.manufacturer, charp, \
+			S_IRUGO); \
+	MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string")
 
 void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
 		struct usb_composite_overwrite *covr);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux