aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Nazarewicz <m.nazarewicz@samsung.com>2010-08-12 11:43:47 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:21:23 -0400
commit7c2b61d02c384a0d5867e524ae72ad98ec2d33fd (patch)
tree83984b9b6ea3c9379c4e132f51dd348a37b15314
parentad1a8102f957f4d25fc58cdc10736c5ade7557e1 (diff)
USB: gadget: mass_storage: moved strings handling code to composite
This patch removes string registration from the Mass Storage Gadget. With recent changes to the composite framework, all that we need is handled by the composite layer. This means composite registers a string ID for manufacturer and product. This also adds the "needs_serial" so that composite layer will issue a warning if user space fails to provide the iSerialNumber module parameter. Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/mass_storage.c72
1 files changed, 6 insertions, 66 deletions
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c
index 585f2559484..493d1533984 100644
--- a/drivers/usb/gadget/mass_storage.c
+++ b/drivers/usb/gadget/mass_storage.c
@@ -75,10 +75,6 @@ static struct usb_device_descriptor msg_device_desc = {
75 /* Vendor and product id can be overridden by module parameters. */ 75 /* Vendor and product id can be overridden by module parameters. */
76 .idVendor = cpu_to_le16(FSG_VENDOR_ID), 76 .idVendor = cpu_to_le16(FSG_VENDOR_ID),
77 .idProduct = cpu_to_le16(FSG_PRODUCT_ID), 77 .idProduct = cpu_to_le16(FSG_PRODUCT_ID),
78 /* .bcdDevice = f(hardware) */
79 /* .iManufacturer = DYNAMIC */
80 /* .iProduct = DYNAMIC */
81 /* NO SERIAL NUMBER */
82 .bNumConfigurations = 1, 78 .bNumConfigurations = 1,
83}; 79};
84 80
@@ -86,7 +82,8 @@ static struct usb_otg_descriptor otg_descriptor = {
86 .bLength = sizeof otg_descriptor, 82 .bLength = sizeof otg_descriptor,
87 .bDescriptorType = USB_DT_OTG, 83 .bDescriptorType = USB_DT_OTG,
88 84
89 /* REVISIT SRP-only hardware is possible, although 85 /*
86 * REVISIT SRP-only hardware is possible, although
90 * it would not be called "OTG" ... 87 * it would not be called "OTG" ...
91 */ 88 */
92 .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, 89 .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
@@ -98,33 +95,6 @@ static const struct usb_descriptor_header *otg_desc[] = {
98}; 95};
99 96
100 97
101/* string IDs are assigned dynamically */
102
103#define STRING_MANUFACTURER_IDX 0
104#define STRING_PRODUCT_IDX 1
105#define STRING_CONFIGURATION_IDX 2
106
107static char manufacturer[50];
108
109static struct usb_string strings_dev[] = {
110 [STRING_MANUFACTURER_IDX].s = manufacturer,
111 [STRING_PRODUCT_IDX].s = DRIVER_DESC,
112 [STRING_CONFIGURATION_IDX].s = "Self Powered",
113 { } /* end of list */
114};
115
116static struct usb_gadget_strings stringtab_dev = {
117 .language = 0x0409, /* en-us */
118 .strings = strings_dev,
119};
120
121static struct usb_gadget_strings *dev_strings[] = {
122 &stringtab_dev,
123 NULL,
124};
125
126
127
128/****************************** Configurations ******************************/ 98/****************************** Configurations ******************************/
129 99
130static struct fsg_module_parameters mod_data = { 100static struct fsg_module_parameters mod_data = {
@@ -173,52 +143,22 @@ static struct usb_configuration msg_config_driver = {
173 .label = "Linux File-Backed Storage", 143 .label = "Linux File-Backed Storage",
174 .bind = msg_do_config, 144 .bind = msg_do_config,
175 .bConfigurationValue = 1, 145 .bConfigurationValue = 1,
176 /* .iConfiguration = DYNAMIC */
177 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 146 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
178}; 147};
179 148
180 149
181
182/****************************** Gadget Bind ******************************/ 150/****************************** Gadget Bind ******************************/
183 151
184
185static int __ref msg_bind(struct usb_composite_dev *cdev) 152static int __ref msg_bind(struct usb_composite_dev *cdev)
186{ 153{
187 struct usb_gadget *gadget = cdev->gadget;
188 int status; 154 int status;
189 155
190 /* Allocate string descriptor numbers ... note that string
191 * contents can be overridden by the composite_dev glue.
192 */
193
194 /* device descriptor strings: manufacturer, product */
195 snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
196 init_utsname()->sysname, init_utsname()->release,
197 gadget->name);
198 status = usb_string_id(cdev);
199 if (status < 0)
200 return status;
201 strings_dev[STRING_MANUFACTURER_IDX].id = status;
202 msg_device_desc.iManufacturer = status;
203
204 status = usb_string_id(cdev);
205 if (status < 0)
206 return status;
207 strings_dev[STRING_PRODUCT_IDX].id = status;
208 msg_device_desc.iProduct = status;
209
210 status = usb_string_id(cdev);
211 if (status < 0)
212 return status;
213 strings_dev[STRING_CONFIGURATION_IDX].id = status;
214 msg_config_driver.iConfiguration = status;
215
216 /* register our second configuration */
217 status = usb_add_config(cdev, &msg_config_driver); 156 status = usb_add_config(cdev, &msg_config_driver);
218 if (status < 0) 157 if (status < 0)
219 return status; 158 return status;
220 159
221 dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); 160 dev_info(&cdev->gadget->dev,
161 DRIVER_DESC ", version: " DRIVER_VERSION "\n");
222 set_bit(0, &msg_registered); 162 set_bit(0, &msg_registered);
223 return 0; 163 return 0;
224} 164}
@@ -226,12 +166,12 @@ static int __ref msg_bind(struct usb_composite_dev *cdev)
226 166
227/****************************** Some noise ******************************/ 167/****************************** Some noise ******************************/
228 168
229
230static struct usb_composite_driver msg_driver = { 169static struct usb_composite_driver msg_driver = {
231 .name = "g_mass_storage", 170 .name = "g_mass_storage",
232 .dev = &msg_device_desc, 171 .dev = &msg_device_desc,
233 .strings = dev_strings,
234 .bind = msg_bind, 172 .bind = msg_bind,
173 .iProduct = DRIVER_DESC,
174 .needs_serial = 1,
235}; 175};
236 176
237MODULE_DESCRIPTION(DRIVER_DESC); 177MODULE_DESCRIPTION(DRIVER_DESC);