usb: gadget: composite: Allow idVendor and other module_params to be writable
RFC PATCH 1/1 usb: gadget: composite: Allow idVendor and other module_params to be writable
In many cases, documentation around composite drivers suggest setting the idVendor and other module params as follows:
$ insmod g_ffs.ko idVendor=<ID> iSerialNumber=<string>
However, this won't work if the driver is not compiled in as a module, as the module_param permissions are S_IRUGO.
Thus this patch changes the composite module_param permissions to S_IRUGO|S_IWUSR to allow the module_params to be set at runtime via /sys/modules/<driver>/parameters/
--- include/linux/usb/composite.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
include/linux/usb/composite.h +10 -6
@@ -399,24 +399,28 @@ struct usb_composite_overwrite {#define USB_GADGET_COMPOSITE_OPTIONS () \ static struct usb_composite_overwrite coverwrite; \ \ - module_param_named(idVendor, coverwrite.idVendor, ushort, S_IRUGO); \ + module_param_named(idVendor, coverwrite.idVendor, ushort, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(idVendor, "USB Vendor ID"); \ \ - module_param_named(idProduct, coverwrite.idProduct, ushort, S_IRUGO); \ + module_param_named(idProduct, coverwrite.idProduct, ushort, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(idProduct, "USB Product ID"); \ \ - module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, S_IRUGO); \ + module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); \ \ module_param_named(iSerialNumber, coverwrite.serial_number, charp, \ - S_IRUGO); \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); \ \ module_param_named(iManufacturer, coverwrite.manufacturer, charp, \ - S_IRUGO); \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \ \ - module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \ + module_param_named(iProduct, coverwrite.product, charp, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(iProduct, "USB Product string") void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
Signature · 1 line
1.7.10.4
Quoted 11 lines · John Stultz
In many cases, documentation around composite drivers suggest setting the idVendor and other module params as follows:
$ insmod g_ffs.ko idVendor=<ID> iSerialNumber=<string>However, this won't work if the driver is not compiled in as a module, as the
module_parampermissions areS_IRUGO.Thus this patch changes the composite
module_parampermissions to S_IRUGO|S_IWUSR to allow themodule_paramsto be set at runtime via /sys/modules/<driver>/parameters/
If the driver is not compiled as a module, setting those variables won't work anyway. Or am I missing something?
You can, however, pass them on Linux command line (with some prefix which I can never remember).
If you want to configure things at run-time without having to compile stuff as modules, you need to wait for the configfs based gadgets.
Quoted 53 lines
Cc Sebastian Andrzej Siewior <[email protected]>Cc Andrzej Pietrasiewicz <[email protected]>Cc Michal Nazarewicz <[email protected]>Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Signed-off-by John Stultz <[email protected]>--- include/linux/usb/composite.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)include/linux/usb/composite.h +10
-6@@ -399,24 +399,28 @@ struct usb_composite_overwrite {#define USB_GADGET_COMPOSITE_OPTIONS () \ static struct usb_composite_overwrite coverwrite; \ \ - module_param_named(idVendor, coverwrite.idVendor, ushort, S_IRUGO); \ + module_param_named(idVendor, coverwrite.idVendor, ushort, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(idVendor, "USB Vendor ID"); \ \ - module_param_named(idProduct, coverwrite.idProduct, ushort, S_IRUGO); \ + module_param_named(idProduct, coverwrite.idProduct, ushort, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(idProduct, "USB Product ID"); \ \ - module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, S_IRUGO); \ + module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); \ \ module_param_named(iSerialNumber, coverwrite.serial_number, charp, \ - S_IRUGO); \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); \ \ module_param_named(iManufacturer, coverwrite.manufacturer, charp, \ - S_IRUGO); \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \ \ - module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \ + module_param_named(iProduct, coverwrite.product, charp, \ + S_IRUGO|S_IWUSR); \ MODULE_PARM_DESC(iProduct, "USB Product string") void usb_composite_overwrite_options(struct usb_composite_dev *cdev,Signature · 1 line
1.7.10.4
Signature · 4 lines
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--
Quoted 6 lines · Michal Nazarewicz
Quoted 5 lines · John Stultz
In many cases, documentation around composite drivers suggest setting the idVendor and other module params as follows:
$ insmod g_ffs.ko idVendor=<ID> iSerialNumber=<string>
Quoted 8 lines
Quoted 6 lines
However, this won't work if the driver is not compiled in as a module, as the
module_parampermissions areS_IRUGO.Thus this patch changes the composite
module_parampermissions to S_IRUGO|S_IWUSR to allow themodule_paramsto be set at runtime via /sys/modules/<driver>/parameters/If the driver is not compiled as a module, setting those variables won't work anyway. Or am I missing something?
Huh. It worked in my testing. But maybe that's only the first time its set? I'll play around with it some more, but yea, on further thought, without unloading the module those values probably shouldn't change. Sorry for the confusion on my part here.
Quoted 2 lines
You can, however, pass them on Linux command line (with some prefix which I can never remember).
That's right. Yea. g_ffs.idVendor and g_ffs.idProduct works for me. Thanks for the reminder!
Quoted 2 lines
If you want to configure things at run-time without having to compile stuff as modules, you need to wait for the configfs based gadgets.
Heh. I thought I was just sorting things out between the out-of-tree android composite, ccg in staging, and functionfs. And now there's *another*?
Any details on configfs based gadget? Is there a git tree somewhere?
thanks
-john
Quoted 3 lines · Michal Nazarewicz
Quoted 2 lines
If the driver is not compiled as a module, setting those variables won't work anyway. Or am I missing something?
Quoted 4 lines · John Stultz
Huh. It worked in my testing. But maybe that's only the first time its set? I'll play around with it some more, but yea, on further thought, without unloading the module those values probably shouldn't change. Sorry for the confusion on my part here.
If you are using g_ffs than yes, it's a bit different, since the module is initialised only after the user space daemon is active, but for all other gadgets, setting those won't work.
Quoted 8 lines
Quoted 2 lines
If you want to configure things at run-time without having to compile stuff as modules, you need to wait for the configfs based gadgets.
Heh. I thought I was just sorting things out between the out-of-tree android composite, ccg in staging, and functionfs. And now there's *another*?
Any details on configfs based gadget? Is there a git tree somewhere?
There are patches from Andrzej Pietrasiewicz and Sebastian Andrzej Siewior on the list. I'm a bit lost in the fate of them and all the namings.
Signature · 4 lines
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--