diff options
Diffstat (limited to 'drivers/usb/gadget/hid.c')
-rw-r--r-- | drivers/usb/gadget/hid.c | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 3493adf064f5..74130f6c12c0 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -15,7 +15,10 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/module.h> | ||
19 | #include <linux/usb/composite.h> | ||
18 | 20 | ||
21 | #include "gadget_chips.h" | ||
19 | #define DRIVER_DESC "HID Gadget" | 22 | #define DRIVER_DESC "HID Gadget" |
20 | #define DRIVER_VERSION "2010/03/16" | 23 | #define DRIVER_VERSION "2010/03/16" |
21 | 24 | ||
@@ -33,12 +36,6 @@ | |||
33 | * the runtime footprint, and giving us at least some parts of what | 36 | * the runtime footprint, and giving us at least some parts of what |
34 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 37 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
35 | */ | 38 | */ |
36 | |||
37 | #include "composite.c" | ||
38 | #include "usbstring.c" | ||
39 | #include "config.c" | ||
40 | #include "epautoconf.c" | ||
41 | |||
42 | #include "f_hid.c" | 39 | #include "f_hid.c" |
43 | 40 | ||
44 | 41 | ||
@@ -50,6 +47,7 @@ struct hidg_func_node { | |||
50 | static LIST_HEAD(hidg_func_list); | 47 | static LIST_HEAD(hidg_func_list); |
51 | 48 | ||
52 | /*-------------------------------------------------------------------------*/ | 49 | /*-------------------------------------------------------------------------*/ |
50 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
53 | 51 | ||
54 | static struct usb_device_descriptor device_desc = { | 52 | static struct usb_device_descriptor device_desc = { |
55 | .bLength = sizeof device_desc, | 53 | .bLength = sizeof device_desc, |
@@ -92,15 +90,10 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
92 | 90 | ||
93 | 91 | ||
94 | /* string IDs are assigned dynamically */ | 92 | /* string IDs are assigned dynamically */ |
95 | |||
96 | #define STRING_MANUFACTURER_IDX 0 | ||
97 | #define STRING_PRODUCT_IDX 1 | ||
98 | |||
99 | static char manufacturer[50]; | ||
100 | |||
101 | static struct usb_string strings_dev[] = { | 93 | static struct usb_string strings_dev[] = { |
102 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 94 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
103 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 95 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
96 | [USB_GADGET_SERIAL_IDX].s = "", | ||
104 | { } /* end of list */ | 97 | { } /* end of list */ |
105 | }; | 98 | }; |
106 | 99 | ||
@@ -150,7 +143,7 @@ static int __init hid_bind(struct usb_composite_dev *cdev) | |||
150 | { | 143 | { |
151 | struct usb_gadget *gadget = cdev->gadget; | 144 | struct usb_gadget *gadget = cdev->gadget; |
152 | struct list_head *tmp; | 145 | struct list_head *tmp; |
153 | int status, gcnum, funcs = 0; | 146 | int status, funcs = 0; |
154 | 147 | ||
155 | list_for_each(tmp, &hidg_func_list) | 148 | list_for_each(tmp, &hidg_func_list) |
156 | funcs++; | 149 | funcs++; |
@@ -163,38 +156,22 @@ static int __init hid_bind(struct usb_composite_dev *cdev) | |||
163 | if (status < 0) | 156 | if (status < 0) |
164 | return status; | 157 | return status; |
165 | 158 | ||
166 | gcnum = usb_gadget_controller_number(gadget); | ||
167 | if (gcnum >= 0) | ||
168 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
169 | else | ||
170 | device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099); | ||
171 | |||
172 | |||
173 | /* Allocate string descriptor numbers ... note that string | 159 | /* Allocate string descriptor numbers ... note that string |
174 | * contents can be overridden by the composite_dev glue. | 160 | * contents can be overridden by the composite_dev glue. |
175 | */ | 161 | */ |
176 | 162 | ||
177 | /* device descriptor strings: manufacturer, product */ | 163 | status = usb_string_ids_tab(cdev, strings_dev); |
178 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
179 | init_utsname()->sysname, init_utsname()->release, | ||
180 | gadget->name); | ||
181 | status = usb_string_id(cdev); | ||
182 | if (status < 0) | ||
183 | return status; | ||
184 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
185 | device_desc.iManufacturer = status; | ||
186 | |||
187 | status = usb_string_id(cdev); | ||
188 | if (status < 0) | 164 | if (status < 0) |
189 | return status; | 165 | return status; |
190 | strings_dev[STRING_PRODUCT_IDX].id = status; | 166 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
191 | device_desc.iProduct = status; | 167 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
192 | 168 | ||
193 | /* register our configuration */ | 169 | /* register our configuration */ |
194 | status = usb_add_config(cdev, &config_driver, do_config); | 170 | status = usb_add_config(cdev, &config_driver, do_config); |
195 | if (status < 0) | 171 | if (status < 0) |
196 | return status; | 172 | return status; |
197 | 173 | ||
174 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
198 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 175 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); |
199 | 176 | ||
200 | return 0; | 177 | return 0; |
@@ -242,11 +219,12 @@ static int __devexit hidg_plat_driver_remove(struct platform_device *pdev) | |||
242 | /****************************** Some noise ******************************/ | 219 | /****************************** Some noise ******************************/ |
243 | 220 | ||
244 | 221 | ||
245 | static struct usb_composite_driver hidg_driver = { | 222 | static __refdata struct usb_composite_driver hidg_driver = { |
246 | .name = "g_hid", | 223 | .name = "g_hid", |
247 | .dev = &device_desc, | 224 | .dev = &device_desc, |
248 | .strings = dev_strings, | 225 | .strings = dev_strings, |
249 | .max_speed = USB_SPEED_HIGH, | 226 | .max_speed = USB_SPEED_HIGH, |
227 | .bind = hid_bind, | ||
250 | .unbind = __exit_p(hid_unbind), | 228 | .unbind = __exit_p(hid_unbind), |
251 | }; | 229 | }; |
252 | 230 | ||
@@ -272,7 +250,7 @@ static int __init hidg_init(void) | |||
272 | if (status < 0) | 250 | if (status < 0) |
273 | return status; | 251 | return status; |
274 | 252 | ||
275 | status = usb_composite_probe(&hidg_driver, hid_bind); | 253 | status = usb_composite_probe(&hidg_driver); |
276 | if (status < 0) | 254 | if (status < 0) |
277 | platform_driver_unregister(&hidg_plat_driver); | 255 | platform_driver_unregister(&hidg_plat_driver); |
278 | 256 | ||