diff options
author | Michal Nazarewicz <m.nazarewicz@samsung.com> | 2010-08-12 11:43:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:21:25 -0400 |
commit | 07a18bd716ed5dea336429404b132568cfaaef95 (patch) | |
tree | 1ff7719e2e0e022cff3ed420bc1c332662a1a48c | |
parent | b0fca50f5a94a268ed02cfddf44448051ed9343f (diff) |
usb gadget: don't save bind callback in struct usb_composite_driver
The bind function is most of the time only called at init time so there
is no need to save a pointer to it in the composite driver structure.
This fixes many section mismatches reported by modpost.
Signed-off-by: Michał Nazarewicz <m.nazarewicz@samsung.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/gadget/audio.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/cdc2.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/composite.c | 15 | ||||
-rw-r--r-- | drivers/usb/gadget/ether.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/g_ffs.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/hid.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/mass_storage.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/multi.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/nokia.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/serial.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/webcam.c | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/zero.c | 3 | ||||
-rw-r--r-- | include/linux/usb/composite.h | 19 |
13 files changed, 27 insertions, 40 deletions
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index a62af7b5909..5a65fbb4e20 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -166,13 +166,12 @@ static struct usb_composite_driver audio_driver = { | |||
166 | .name = "g_audio", | 166 | .name = "g_audio", |
167 | .dev = &device_desc, | 167 | .dev = &device_desc, |
168 | .strings = audio_strings, | 168 | .strings = audio_strings, |
169 | .bind = audio_bind, | ||
170 | .unbind = __exit_p(audio_unbind), | 169 | .unbind = __exit_p(audio_unbind), |
171 | }; | 170 | }; |
172 | 171 | ||
173 | static int __init init(void) | 172 | static int __init init(void) |
174 | { | 173 | { |
175 | return usb_composite_register(&audio_driver); | 174 | return usb_composite_probe(&audio_driver, audio_bind); |
176 | } | 175 | } |
177 | module_init(init); | 176 | module_init(init); |
178 | 177 | ||
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 928137d3dbd..1f2a9b1e4f2 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -245,7 +245,6 @@ static struct usb_composite_driver cdc_driver = { | |||
245 | .name = "g_cdc", | 245 | .name = "g_cdc", |
246 | .dev = &device_desc, | 246 | .dev = &device_desc, |
247 | .strings = dev_strings, | 247 | .strings = dev_strings, |
248 | .bind = cdc_bind, | ||
249 | .unbind = __exit_p(cdc_unbind), | 248 | .unbind = __exit_p(cdc_unbind), |
250 | }; | 249 | }; |
251 | 250 | ||
@@ -255,7 +254,7 @@ MODULE_LICENSE("GPL"); | |||
255 | 254 | ||
256 | static int __init init(void) | 255 | static int __init init(void) |
257 | { | 256 | { |
258 | return usb_composite_register(&cdc_driver); | 257 | return usb_composite_probe(&cdc_driver, cdc_bind); |
259 | } | 258 | } |
260 | module_init(init); | 259 | module_init(init); |
261 | 260 | ||
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index a3009bf0122..c531a7e05f1 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #define USB_BUFSIZ 1024 | 40 | #define USB_BUFSIZ 1024 |
41 | 41 | ||
42 | static struct usb_composite_driver *composite; | 42 | static struct usb_composite_driver *composite; |
43 | static int (*composite_gadget_bind)(struct usb_composite_dev *cdev); | ||
43 | 44 | ||
44 | /* Some systems will need runtime overrides for the product identifers | 45 | /* Some systems will need runtime overrides for the product identifers |
45 | * published in the device descriptor, either numbers or strings or both. | 46 | * published in the device descriptor, either numbers or strings or both. |
@@ -1115,7 +1116,7 @@ static int composite_bind(struct usb_gadget *gadget) | |||
1115 | * serial number), register function drivers, potentially update | 1116 | * serial number), register function drivers, potentially update |
1116 | * power state and consumption, etc | 1117 | * power state and consumption, etc |
1117 | */ | 1118 | */ |
1118 | status = composite->bind(cdev); | 1119 | status = composite_gadget_bind(cdev); |
1119 | if (status < 0) | 1120 | if (status < 0) |
1120 | goto fail; | 1121 | goto fail; |
1121 | 1122 | ||
@@ -1227,8 +1228,12 @@ static struct usb_gadget_driver composite_driver = { | |||
1227 | }; | 1228 | }; |
1228 | 1229 | ||
1229 | /** | 1230 | /** |
1230 | * usb_composite_register() - register a composite driver | 1231 | * usb_composite_probe() - register a composite driver |
1231 | * @driver: the driver to register | 1232 | * @driver: the driver to register |
1233 | * @bind: the callback used to allocate resources that are shared across the | ||
1234 | * whole device, such as string IDs, and add its configurations using | ||
1235 | * @usb_add_config(). This may fail by returning a negative errno | ||
1236 | * value; it should return zero on successful initialization. | ||
1232 | * Context: single threaded during gadget setup | 1237 | * Context: single threaded during gadget setup |
1233 | * | 1238 | * |
1234 | * This function is used to register drivers using the composite driver | 1239 | * This function is used to register drivers using the composite driver |
@@ -1241,9 +1246,10 @@ static struct usb_gadget_driver composite_driver = { | |||
1241 | * while it was binding. That would usually be done in order to wait for | 1246 | * while it was binding. That would usually be done in order to wait for |
1242 | * some userspace participation. | 1247 | * some userspace participation. |
1243 | */ | 1248 | */ |
1244 | int usb_composite_register(struct usb_composite_driver *driver) | 1249 | extern int usb_composite_probe(struct usb_composite_driver *driver, |
1250 | int (*bind)(struct usb_composite_dev *cdev)) | ||
1245 | { | 1251 | { |
1246 | if (!driver || !driver->dev || !driver->bind || composite) | 1252 | if (!driver || !driver->dev || !bind || composite) |
1247 | return -EINVAL; | 1253 | return -EINVAL; |
1248 | 1254 | ||
1249 | if (!driver->iProduct) | 1255 | if (!driver->iProduct) |
@@ -1253,6 +1259,7 @@ int usb_composite_register(struct usb_composite_driver *driver) | |||
1253 | composite_driver.function = (char *) driver->name; | 1259 | composite_driver.function = (char *) driver->name; |
1254 | composite_driver.driver.name = driver->name; | 1260 | composite_driver.driver.name = driver->name; |
1255 | composite = driver; | 1261 | composite = driver; |
1262 | composite_gadget_bind = bind; | ||
1256 | 1263 | ||
1257 | return usb_gadget_probe_driver(&composite_driver, composite_bind); | 1264 | return usb_gadget_probe_driver(&composite_driver, composite_bind); |
1258 | } | 1265 | } |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 400f80372d9..33076bca993 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -402,7 +402,6 @@ static struct usb_composite_driver eth_driver = { | |||
402 | .name = "g_ether", | 402 | .name = "g_ether", |
403 | .dev = &device_desc, | 403 | .dev = &device_desc, |
404 | .strings = dev_strings, | 404 | .strings = dev_strings, |
405 | .bind = eth_bind, | ||
406 | .unbind = __exit_p(eth_unbind), | 405 | .unbind = __exit_p(eth_unbind), |
407 | }; | 406 | }; |
408 | 407 | ||
@@ -412,7 +411,7 @@ MODULE_LICENSE("GPL"); | |||
412 | 411 | ||
413 | static int __init init(void) | 412 | static int __init init(void) |
414 | { | 413 | { |
415 | return usb_composite_register(ð_driver); | 414 | return usb_composite_probe(ð_driver, eth_bind); |
416 | } | 415 | } |
417 | module_init(init); | 416 | module_init(init); |
418 | 417 | ||
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index 52fd3fa0d13..9fcb1587950 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c | |||
@@ -147,7 +147,6 @@ static struct usb_composite_driver gfs_driver = { | |||
147 | .name = DRIVER_NAME, | 147 | .name = DRIVER_NAME, |
148 | .dev = &gfs_dev_desc, | 148 | .dev = &gfs_dev_desc, |
149 | .strings = gfs_dev_strings, | 149 | .strings = gfs_dev_strings, |
150 | .bind = gfs_bind, | ||
151 | .unbind = gfs_unbind, | 150 | .unbind = gfs_unbind, |
152 | .iProduct = DRIVER_DESC, | 151 | .iProduct = DRIVER_DESC, |
153 | }; | 152 | }; |
@@ -187,7 +186,7 @@ static int functionfs_ready_callback(struct ffs_data *ffs) | |||
187 | return -EBUSY; | 186 | return -EBUSY; |
188 | 187 | ||
189 | gfs_ffs_data = ffs; | 188 | gfs_ffs_data = ffs; |
190 | ret = usb_composite_register(&gfs_driver); | 189 | ret = usb_composite_probe(&gfs_driver, gfs_bind); |
191 | if (unlikely(ret < 0)) | 190 | if (unlikely(ret < 0)) |
192 | clear_bit(0, &gfs_registered); | 191 | clear_bit(0, &gfs_registered); |
193 | return ret; | 192 | return ret; |
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 775722686ed..77f495212fb 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -256,7 +256,6 @@ static struct usb_composite_driver hidg_driver = { | |||
256 | .name = "g_hid", | 256 | .name = "g_hid", |
257 | .dev = &device_desc, | 257 | .dev = &device_desc, |
258 | .strings = dev_strings, | 258 | .strings = dev_strings, |
259 | .bind = hid_bind, | ||
260 | .unbind = __exit_p(hid_unbind), | 259 | .unbind = __exit_p(hid_unbind), |
261 | }; | 260 | }; |
262 | 261 | ||
@@ -282,7 +281,7 @@ static int __init hidg_init(void) | |||
282 | if (status < 0) | 281 | if (status < 0) |
283 | return status; | 282 | return status; |
284 | 283 | ||
285 | status = usb_composite_register(&hidg_driver); | 284 | status = usb_composite_probe(&hidg_driver, hid_bind); |
286 | if (status < 0) | 285 | if (status < 0) |
287 | platform_driver_unregister(&hidg_plat_driver); | 286 | platform_driver_unregister(&hidg_plat_driver); |
288 | 287 | ||
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 05e9bd33034..a5e4a777d92 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c | |||
@@ -169,7 +169,6 @@ static int __init msg_bind(struct usb_composite_dev *cdev) | |||
169 | static struct usb_composite_driver msg_driver = { | 169 | static struct usb_composite_driver msg_driver = { |
170 | .name = "g_mass_storage", | 170 | .name = "g_mass_storage", |
171 | .dev = &msg_device_desc, | 171 | .dev = &msg_device_desc, |
172 | .bind = msg_bind, | ||
173 | .iProduct = DRIVER_DESC, | 172 | .iProduct = DRIVER_DESC, |
174 | .needs_serial = 1, | 173 | .needs_serial = 1, |
175 | }; | 174 | }; |
@@ -180,7 +179,7 @@ MODULE_LICENSE("GPL"); | |||
180 | 179 | ||
181 | static int __init msg_init(void) | 180 | static int __init msg_init(void) |
182 | { | 181 | { |
183 | return usb_composite_register(&msg_driver); | 182 | return usb_composite_probe(&msg_driver, msg_bind); |
184 | } | 183 | } |
185 | module_init(msg_init); | 184 | module_init(msg_init); |
186 | 185 | ||
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index ca51661d71d..91170a02a9a 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c | |||
@@ -353,7 +353,6 @@ static struct usb_composite_driver multi_driver = { | |||
353 | .name = "g_multi", | 353 | .name = "g_multi", |
354 | .dev = &device_desc, | 354 | .dev = &device_desc, |
355 | .strings = dev_strings, | 355 | .strings = dev_strings, |
356 | .bind = multi_bind, | ||
357 | .unbind = __exit_p(multi_unbind), | 356 | .unbind = __exit_p(multi_unbind), |
358 | .iProduct = DRIVER_DESC, | 357 | .iProduct = DRIVER_DESC, |
359 | .needs_serial = 1, | 358 | .needs_serial = 1, |
@@ -362,7 +361,7 @@ static struct usb_composite_driver multi_driver = { | |||
362 | 361 | ||
363 | static int __init multi_init(void) | 362 | static int __init multi_init(void) |
364 | { | 363 | { |
365 | return usb_composite_register(&multi_driver); | 364 | return usb_composite_probe(&multi_driver, multi_bind); |
366 | } | 365 | } |
367 | module_init(multi_init); | 366 | module_init(multi_init); |
368 | 367 | ||
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index 7d6b66a8572..8aec728882a 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c | |||
@@ -241,13 +241,12 @@ static struct usb_composite_driver nokia_driver = { | |||
241 | .name = "g_nokia", | 241 | .name = "g_nokia", |
242 | .dev = &device_desc, | 242 | .dev = &device_desc, |
243 | .strings = dev_strings, | 243 | .strings = dev_strings, |
244 | .bind = nokia_bind, | ||
245 | .unbind = __exit_p(nokia_unbind), | 244 | .unbind = __exit_p(nokia_unbind), |
246 | }; | 245 | }; |
247 | 246 | ||
248 | static int __init nokia_init(void) | 247 | static int __init nokia_init(void) |
249 | { | 248 | { |
250 | return usb_composite_register(&nokia_driver); | 249 | return usb_composite_probe(&nokia_driver, nokia_bind); |
251 | } | 250 | } |
252 | module_init(nokia_init); | 251 | module_init(nokia_init); |
253 | 252 | ||
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index f46a60962da..0b81d7b741d 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -242,7 +242,6 @@ static struct usb_composite_driver gserial_driver = { | |||
242 | .name = "g_serial", | 242 | .name = "g_serial", |
243 | .dev = &device_desc, | 243 | .dev = &device_desc, |
244 | .strings = dev_strings, | 244 | .strings = dev_strings, |
245 | .bind = gs_bind, | ||
246 | }; | 245 | }; |
247 | 246 | ||
248 | static int __init init(void) | 247 | static int __init init(void) |
@@ -271,7 +270,7 @@ static int __init init(void) | |||
271 | } | 270 | } |
272 | strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; | 271 | strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; |
273 | 272 | ||
274 | return usb_composite_register(&gserial_driver); | 273 | return usb_composite_probe(&gserial_driver, gs_bind); |
275 | } | 274 | } |
276 | module_init(init); | 275 | module_init(init); |
277 | 276 | ||
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index 288d21155ab..de65b8078e0 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c | |||
@@ -373,14 +373,13 @@ static struct usb_composite_driver webcam_driver = { | |||
373 | .name = "g_webcam", | 373 | .name = "g_webcam", |
374 | .dev = &webcam_device_descriptor, | 374 | .dev = &webcam_device_descriptor, |
375 | .strings = webcam_device_strings, | 375 | .strings = webcam_device_strings, |
376 | .bind = webcam_bind, | ||
377 | .unbind = webcam_unbind, | 376 | .unbind = webcam_unbind, |
378 | }; | 377 | }; |
379 | 378 | ||
380 | static int __init | 379 | static int __init |
381 | webcam_init(void) | 380 | webcam_init(void) |
382 | { | 381 | { |
383 | return usb_composite_register(&webcam_driver); | 382 | return usb_composite_probe(&webcam_driver, webcam_bind); |
384 | } | 383 | } |
385 | 384 | ||
386 | static void __exit | 385 | static void __exit |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 807280d069f..6d16db9d9d2 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -340,7 +340,6 @@ static struct usb_composite_driver zero_driver = { | |||
340 | .name = "zero", | 340 | .name = "zero", |
341 | .dev = &device_desc, | 341 | .dev = &device_desc, |
342 | .strings = dev_strings, | 342 | .strings = dev_strings, |
343 | .bind = zero_bind, | ||
344 | .unbind = zero_unbind, | 343 | .unbind = zero_unbind, |
345 | .suspend = zero_suspend, | 344 | .suspend = zero_suspend, |
346 | .resume = zero_resume, | 345 | .resume = zero_resume, |
@@ -351,7 +350,7 @@ MODULE_LICENSE("GPL"); | |||
351 | 350 | ||
352 | static int __init init(void) | 351 | static int __init init(void) |
353 | { | 352 | { |
354 | return usb_composite_register(&zero_driver); | 353 | return usb_composite_probe(&zero_driver, zero_bind); |
355 | } | 354 | } |
356 | module_init(init); | 355 | module_init(init); |
357 | 356 | ||
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index a78e813d27e..e28b6626802 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
@@ -248,11 +248,7 @@ int usb_add_config(struct usb_composite_dev *, | |||
248 | * and language IDs provided in control requests | 248 | * and language IDs provided in control requests |
249 | * @needs_serial: set to 1 if the gadget needs userspace to provide | 249 | * @needs_serial: set to 1 if the gadget needs userspace to provide |
250 | * a serial number. If one is not provided, warning will be printed. | 250 | * a serial number. If one is not provided, warning will be printed. |
251 | * @bind: (REQUIRED) Used to allocate resources that are shared across the | 251 | * @unbind: Reverses bind; called as a side effect of unregistering |
252 | * whole device, such as string IDs, and add its configurations using | ||
253 | * @usb_add_config(). This may fail by returning a negative errno | ||
254 | * value; it should return zero on successful initialization. | ||
255 | * @unbind: Reverses @bind(); called as a side effect of unregistering | ||
256 | * this driver. | 252 | * this driver. |
257 | * @disconnect: optional driver disconnect method | 253 | * @disconnect: optional driver disconnect method |
258 | * @suspend: Notifies when the host stops sending USB traffic, | 254 | * @suspend: Notifies when the host stops sending USB traffic, |
@@ -263,7 +259,7 @@ int usb_add_config(struct usb_composite_dev *, | |||
263 | * Devices default to reporting self powered operation. Devices which rely | 259 | * Devices default to reporting self powered operation. Devices which rely |
264 | * on bus powered operation should report this in their @bind() method. | 260 | * on bus powered operation should report this in their @bind() method. |
265 | * | 261 | * |
266 | * Before returning from @bind, various fields in the template descriptor | 262 | * Before returning from bind, various fields in the template descriptor |
267 | * may be overridden. These include the idVendor/idProduct/bcdDevice values | 263 | * may be overridden. These include the idVendor/idProduct/bcdDevice values |
268 | * normally to bind the appropriate host side driver, and the three strings | 264 | * normally to bind the appropriate host side driver, and the three strings |
269 | * (iManufacturer, iProduct, iSerialNumber) normally used to provide user | 265 | * (iManufacturer, iProduct, iSerialNumber) normally used to provide user |
@@ -279,12 +275,6 @@ struct usb_composite_driver { | |||
279 | struct usb_gadget_strings **strings; | 275 | struct usb_gadget_strings **strings; |
280 | unsigned needs_serial:1; | 276 | unsigned needs_serial:1; |
281 | 277 | ||
282 | /* REVISIT: bind() functions can be marked __init, which | ||
283 | * makes trouble for section mismatch analysis. See if | ||
284 | * we can't restructure things to avoid mismatching... | ||
285 | */ | ||
286 | |||
287 | int (*bind)(struct usb_composite_dev *); | ||
288 | int (*unbind)(struct usb_composite_dev *); | 278 | int (*unbind)(struct usb_composite_dev *); |
289 | 279 | ||
290 | void (*disconnect)(struct usb_composite_dev *); | 280 | void (*disconnect)(struct usb_composite_dev *); |
@@ -294,8 +284,9 @@ struct usb_composite_driver { | |||
294 | void (*resume)(struct usb_composite_dev *); | 284 | void (*resume)(struct usb_composite_dev *); |
295 | }; | 285 | }; |
296 | 286 | ||
297 | extern int usb_composite_register(struct usb_composite_driver *); | 287 | extern int usb_composite_probe(struct usb_composite_driver *driver, |
298 | extern void usb_composite_unregister(struct usb_composite_driver *); | 288 | int (*bind)(struct usb_composite_dev *cdev)); |
289 | extern void usb_composite_unregister(struct usb_composite_driver *driver); | ||
299 | 290 | ||
300 | 291 | ||
301 | /** | 292 | /** |