RFC: platform overrides of gadget descriptions (ids/text)

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

 



Hi,

I use the gadget stack in a product, and there's a desire from product
management to use our own vendor/product ids + something more
descriptive in the device strings than the defaults of g_serial.

Now, I could hack up something like below to override that stuff on
the kernel cmdline, but that doesn't quite seem clean. Ideally I would
like to just be able to add a platform_device with this kind of info
in my platform code or similar - Am I missing something with the
composite stuff to make this easier to do?

Comments, suggestions?

diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 37879af..c99f78c 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -135,6 +135,22 @@ static unsigned n_ports = 1;
 module_param(n_ports, uint, 0);
 MODULE_PARM_DESC(n_ports, "number of ports to create, default=1");
 
+static int idvendor = -1;
+module_param(idvendor, int, 0);
+MODULE_PARM_DESC(n_ports, "Alternative vendor ID to use");
+
+static int idproduct = -1;
+module_param(idproduct, int, 0);
+MODULE_PARM_DESC(n_ports, "Alternative product ID to use");
+
+module_param_string(manu, manufacturer, sizeof manufacturer, 0);
+MODULE_PARM_DESC(manu, "Alternative manufacturer string to use");
+
+static char product[50];
+module_param_string(prod, product, sizeof product, 0);
+MODULE_PARM_DESC(manu, "Alternative product string to use");
+
+
 /*-------------------------------------------------------------------------*/
 
 static int __init serial_bind_config(struct usb_configuration *c)
@@ -176,9 +192,11 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
 	 */
 
 	/* device description: manufacturer, product */
-	snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
-		init_utsname()->sysname, init_utsname()->release,
-		gadget->name);
+	if (!manufacturer[0])
+		snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
+			 init_utsname()->sysname, init_utsname()->release,
+			 gadget->name);
+
 	status = usb_string_id(cdev);
 	if (status < 0)
 		goto fail;
@@ -269,6 +287,14 @@ static int __init init(void)
 		device_desc.idProduct =
 				__constant_cpu_to_le16(GS_PRODUCT_ID);
 	}
+
+	if (idvendor != -1)
+		device_desc.idVendor  = cpu_to_le16(idvendor);
+	if (idproduct != -1)
+		device_desc.idProduct = cpu_to_le16(idproduct);
+	if (product[0])
+		strings_dev[STRING_PRODUCT_IDX].s = product;
+
 	strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label;
 
 	return usb_composite_register(&gserial_driver);
-- 
1.5.6.5

-- 
Bye, Peter Korsgaard
--
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