From c2ec75c25112c9e0d9053f55ba8cf0a358d4a354 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Thu, 6 Sep 2012 20:11:03 +0200 Subject: usb: gadget: push all usb_composite_driver structs into __refdata As it turns out, Sam's comment was better than I initially assumed. This patch pushes as struct usb_composite_driver data structures into __refdata section to avoid a section missmatch report from modpost because the ->bind() can be marked __init. The only downside is that modpost does not check between ->bind() and other member. However, it is temporary. Cc: Sam Ravnborg Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 1f376eba31f6..5df117e3f78d 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -156,7 +156,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev) /****************************** Some noise ******************************/ -static struct usb_composite_driver msg_driver = { +static __refdata struct usb_composite_driver msg_driver = { .name = "g_mass_storage", .dev = &msg_device_desc, .iProduct = DRIVER_DESC, -- cgit v1.2.3 From 03e42bd5937c4c24e411690ab165627e93c258b5 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Thu, 6 Sep 2012 20:11:04 +0200 Subject: usb: gadget: move bind() callback back to struct usb_composite_driver This partly reverts 07a18bd7 ("usb gadget: don't save bind callback in struct usb_composite_driver") and fixes new drivers. The section missmatch problems was solved by whitelisting structs in question via __ref. Cc: devel@driverdev.osuosl.org Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 5df117e3f78d..480edbc368e5 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -162,6 +162,7 @@ static __refdata struct usb_composite_driver msg_driver = { .iProduct = DRIVER_DESC, .max_speed = USB_SPEED_SUPER, .needs_serial = 1, + .bind = msg_bind, }; MODULE_DESCRIPTION(DRIVER_DESC); @@ -170,7 +171,7 @@ MODULE_LICENSE("GPL"); static int __init msg_init(void) { - return usb_composite_probe(&msg_driver, msg_bind); + return usb_composite_probe(&msg_driver); } module_init(msg_init); -- cgit v1.2.3 From a84d9e5361bcfbff1c84481bd9c04fc58a56d83b Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Thu, 6 Sep 2012 20:11:09 +0200 Subject: usb: gadget: start with libcomposite This patch aims to be simple. It removes #include usbstribgs.c line from each gadget and creates libcomposite.ko which has only one member, that is usbstribgs.c. Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 480edbc368e5..a7f32c312a6b 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -49,7 +49,6 @@ */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" #include "f_mass_storage.c" -- cgit v1.2.3 From 0ba16dea72a457bf65fc06ef60165c994e2f7420 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Thu, 6 Sep 2012 20:11:10 +0200 Subject: usb: gadget: libcomposite: move config.c into libcomposite This patch moves config.c into libcomposite and updates all gadgets. Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index a7f32c312a6b..9675e61c9a8d 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -49,7 +49,6 @@ */ #include "composite.c" -#include "config.c" #include "epautoconf.c" #include "f_mass_storage.c" -- cgit v1.2.3 From dc995fc27c2e1c8edebfb2405ede23bd38153f7f Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Thu, 6 Sep 2012 20:11:12 +0200 Subject: usb: gadget: libcomposite: add epautoconf.c to libcomposite This patch adds epautoconf.c into libcomposite and updates all gadgets. Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 9675e61c9a8d..0b0f008427ed 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -49,7 +49,6 @@ */ #include "composite.c" -#include "epautoconf.c" #include "f_mass_storage.c" /*-------------------------------------------------------------------------*/ -- cgit v1.2.3 From 7d16e8d3eb704f5f6eb5a271d5758b495634e8e6 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Mon, 10 Sep 2012 15:01:53 +0200 Subject: usb: gadget: push VID/PID/USB BCD module option into gadgets 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 Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 0b0f008427ed..8ffbade383f2 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -52,6 +52,7 @@ #include "f_mass_storage.c" /*-------------------------------------------------------------------------*/ +USB_GADGET_COMPOSITE_OPTIONS(); static struct usb_device_descriptor msg_device_desc = { .bLength = sizeof msg_device_desc, @@ -143,7 +144,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev) status = usb_add_config(cdev, &msg_config_driver, msg_do_config); if (status < 0) return status; - + usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&cdev->gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); set_bit(0, &msg_registered); -- cgit v1.2.3 From 1cf0d264088907038be560ba2dd472d5e432a3dc Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Mon, 10 Sep 2012 15:01:54 +0200 Subject: usb: gadget: push iSerialNumber into gadgets This patch pushes the iSerialNumber module argument from composite into each gadget. Once the user uses the module paramter, the string is overwritten with the final value. Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 8ffbade383f2..6f5a3b232d81 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -83,6 +83,22 @@ static const struct usb_descriptor_header *otg_desc[] = { NULL, }; +static struct usb_string strings_dev[] = { + [USB_GADGET_MANUFACTURER_IDX].s = "", + [USB_GADGET_PRODUCT_IDX].s = "", + [USB_GADGET_SERIAL_IDX].s = "", + { } /* end of list */ +}; + +static struct usb_gadget_strings stringtab_dev = { + .language = 0x0409, /* en-us */ + .strings = strings_dev, +}; + +static struct usb_gadget_strings *dev_strings[] = { + &stringtab_dev, + NULL, +}; /****************************** Configurations ******************************/ @@ -141,6 +157,10 @@ static int __init msg_bind(struct usb_composite_dev *cdev) { int status; + status = usb_string_ids_tab(cdev, strings_dev); + if (status < 0) + return status; + status = usb_add_config(cdev, &msg_config_driver, msg_do_config); if (status < 0) return status; @@ -160,6 +180,7 @@ static __refdata struct usb_composite_driver msg_driver = { .iProduct = DRIVER_DESC, .max_speed = USB_SPEED_SUPER, .needs_serial = 1, + .strings = dev_strings, .bind = msg_bind, }; -- cgit v1.2.3 From d33f74fce3756d51a0203cec3d0d278e3b48d827 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Mon, 10 Sep 2012 15:01:57 +0200 Subject: usb: gadget: remove string override from struct usb_composite_driver The struct usb_composite_driver members iProduct, iSerial and iManufacturer can be entered directly via the string array. There is no need for them to appear here. Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 6f5a3b232d81..50da3c88cb06 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -85,7 +85,7 @@ static const struct usb_descriptor_header *otg_desc[] = { static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX].s = "", - [USB_GADGET_PRODUCT_IDX].s = "", + [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, [USB_GADGET_SERIAL_IDX].s = "", { } /* end of list */ }; @@ -160,6 +160,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev) status = usb_string_ids_tab(cdev, strings_dev); if (status < 0) return status; + msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; status = usb_add_config(cdev, &msg_config_driver, msg_do_config); if (status < 0) @@ -177,7 +178,6 @@ static int __init msg_bind(struct usb_composite_dev *cdev) static __refdata struct usb_composite_driver msg_driver = { .name = "g_mass_storage", .dev = &msg_device_desc, - .iProduct = DRIVER_DESC, .max_speed = USB_SPEED_SUPER, .needs_serial = 1, .strings = dev_strings, -- cgit v1.2.3 From cc2683c318a5bf192b75cd5c343b51009db0cf6c Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Mon, 10 Sep 2012 15:01:58 +0200 Subject: usb: gadget: Provide a default implementation of default manufacturer string Some gadgets provide custom entry here. Some may override it with an etntry that is also created by composite if there was no value sumbitted at all. This patch removes all "custom manufacturer" strings which are the same as these which are created by composite. Then it moves the creation of the default manufacturer string to usb_composite_overwrite_options() in case no command line argument has been used and the entry is still an empty string. By doing this we get rid of the global variable "composite_manufacturer" in composite. Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 50da3c88cb06..9eb2be685803 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -29,10 +29,8 @@ #include -#include #include - /*-------------------------------------------------------------------------*/ #define DRIVER_DESC "Mass Storage Gadget" -- cgit v1.2.3 From 721e2e91945bc2520d57d795dfe1b502ecec567c Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Thu, 6 Sep 2012 20:11:27 +0200 Subject: usb: gadget: libcomposite: move composite.c into libcomposite This moves composite.c into libcomposite and updates all gadgets. Finally! Acked-by: Michal Nazarewicz Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/gadget/mass_storage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb/gadget/mass_storage.c') diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 9eb2be685803..080e577773d5 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -30,6 +30,7 @@ #include #include +#include /*-------------------------------------------------------------------------*/ @@ -45,8 +46,6 @@ * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ - -#include "composite.c" #include "f_mass_storage.c" /*-------------------------------------------------------------------------*/ -- cgit v1.2.3