Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb gadget: don't save bind callback in struct usb_configuration

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 configuration structure.

This fixes many section mismatches reported by modpost.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[m.nazarewicz@samsung.com: updated for -next]
Signed-off-by: Michał Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Uwe Kleine-König and committed by
Greg Kroah-Hartman
c9bfff9c 07a18bd7

+33 -43
+1 -2
drivers/usb/gadget/audio.c
··· 105 105 106 106 static struct usb_configuration audio_config_driver = { 107 107 .label = DRIVER_DESC, 108 - .bind = audio_do_config, 109 108 .bConfigurationValue = 1, 110 109 /* .iConfiguration = DYNAMIC */ 111 110 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 144 145 strings_dev[STRING_PRODUCT_IDX].id = status; 145 146 device_desc.iProduct = status; 146 147 147 - status = usb_add_config(cdev, &audio_config_driver); 148 + status = usb_add_config(cdev, &audio_config_driver, audio_do_config); 148 149 if (status < 0) 149 150 goto fail; 150 151
+1 -2
drivers/usb/gadget/cdc2.c
··· 151 151 152 152 static struct usb_configuration cdc_config_driver = { 153 153 .label = "CDC Composite (ECM + ACM)", 154 - .bind = cdc_do_config, 155 154 .bConfigurationValue = 1, 156 155 /* .iConfiguration = DYNAMIC */ 157 156 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 217 218 device_desc.iProduct = status; 218 219 219 220 /* register our configuration */ 220 - status = usb_add_config(cdev, &cdc_config_driver); 221 + status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); 221 222 if (status < 0) 222 223 goto fail1; 223 224
+8 -6
drivers/usb/gadget/composite.c
··· 474 474 * usb_add_config() - add a configuration to a device. 475 475 * @cdev: wraps the USB gadget 476 476 * @config: the configuration, with bConfigurationValue assigned 477 + * @bind: the configuration's bind function 477 478 * Context: single threaded during gadget setup 478 479 * 479 - * One of the main tasks of a composite driver's bind() routine is to 480 + * One of the main tasks of a composite @bind() routine is to 480 481 * add each of the configurations it supports, using this routine. 481 482 * 482 - * This function returns the value of the configuration's bind(), which 483 + * This function returns the value of the configuration's @bind(), which 483 484 * is zero for success else a negative errno value. Binding configurations 484 485 * assigns global resources including string IDs, and per-configuration 485 486 * resources such as interface IDs and endpoints. 486 487 */ 487 488 int usb_add_config(struct usb_composite_dev *cdev, 488 - struct usb_configuration *config) 489 + struct usb_configuration *config, 490 + int (*bind)(struct usb_configuration *)) 489 491 { 490 492 int status = -EINVAL; 491 493 struct usb_configuration *c; ··· 496 494 config->bConfigurationValue, 497 495 config->label, config); 498 496 499 - if (!config->bConfigurationValue || !config->bind) 497 + if (!config->bConfigurationValue || !bind) 500 498 goto done; 501 499 502 500 /* Prevent duplicate configuration identifiers */ ··· 513 511 INIT_LIST_HEAD(&config->functions); 514 512 config->next_interface_id = 0; 515 513 516 - status = config->bind(config); 514 + status = bind(config); 517 515 if (status < 0) { 518 516 list_del(&config->list); 519 517 config->cdev = NULL; ··· 539 537 } 540 538 } 541 539 542 - /* set_alt(), or next config->bind(), sets up 540 + /* set_alt(), or next bind(), sets up 543 541 * ep->driver_data as needed. 544 542 */ 545 543 usb_ep_autoconfig_reset(cdev->gadget);
+3 -4
drivers/usb/gadget/ether.c
··· 251 251 252 252 static struct usb_configuration rndis_config_driver = { 253 253 .label = "RNDIS", 254 - .bind = rndis_do_config, 255 254 .bConfigurationValue = 2, 256 255 /* .iConfiguration = DYNAMIC */ 257 256 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 288 289 289 290 static struct usb_configuration eth_config_driver = { 290 291 /* .label = f(hardware) */ 291 - .bind = eth_do_config, 292 292 .bConfigurationValue = 1, 293 293 /* .iConfiguration = DYNAMIC */ 294 294 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 371 373 372 374 /* register our configuration(s); RNDIS first, if it's used */ 373 375 if (has_rndis()) { 374 - status = usb_add_config(cdev, &rndis_config_driver); 376 + status = usb_add_config(cdev, &rndis_config_driver, 377 + rndis_do_config); 375 378 if (status < 0) 376 379 goto fail; 377 380 } 378 381 379 - status = usb_add_config(cdev, &eth_config_driver); 382 + status = usb_add_config(cdev, &eth_config_driver, eth_do_config); 380 383 if (status < 0) 381 384 goto fail; 382 385
+1 -2
drivers/usb/gadget/f_loopback.c
··· 349 349 static struct usb_configuration loopback_driver = { 350 350 .label = "loopback", 351 351 .strings = loopback_strings, 352 - .bind = loopback_bind_config, 353 352 .bConfigurationValue = 2, 354 353 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 355 354 /* .iConfiguration = DYNAMIC */ ··· 381 382 loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 382 383 } 383 384 384 - return usb_add_config(cdev, &loopback_driver); 385 + return usb_add_config(cdev, &loopback_driver, loopback_bind_config); 385 386 }
+1 -2
drivers/usb/gadget/f_sourcesink.c
··· 498 498 static struct usb_configuration sourcesink_driver = { 499 499 .label = "source/sink", 500 500 .strings = sourcesink_strings, 501 - .bind = sourcesink_bind_config, 502 501 .setup = sourcesink_setup, 503 502 .bConfigurationValue = 3, 504 503 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 531 532 sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 532 533 } 533 534 534 - return usb_add_config(cdev, &sourcesink_driver); 535 + return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config); 535 536 }
+1 -2
drivers/usb/gadget/g_ffs.c
··· 234 234 235 235 c->c.label = gfs_strings[i].s; 236 236 c->c.iConfiguration = gfs_strings[i].id; 237 - c->c.bind = gfs_do_config; 238 237 c->c.bConfigurationValue = 1 + i; 239 238 c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; 240 239 241 - ret = usb_add_config(cdev, &c->c); 240 + ret = usb_add_config(cdev, &c->c, gfs_do_config); 242 241 if (unlikely(ret < 0)) 243 242 goto error_unbind; 244 243 }
+1 -2
drivers/usb/gadget/hid.c
··· 148 148 149 149 static struct usb_configuration config_driver = { 150 150 .label = "HID Gadget", 151 - .bind = do_config, 152 151 .bConfigurationValue = 1, 153 152 /* .iConfiguration = DYNAMIC */ 154 153 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 200 201 device_desc.iProduct = status; 201 202 202 203 /* register our configuration */ 203 - status = usb_add_config(cdev, &config_driver); 204 + status = usb_add_config(cdev, &config_driver, do_config); 204 205 if (status < 0) 205 206 return status; 206 207
+1 -2
drivers/usb/gadget/mass_storage.c
··· 141 141 142 142 static struct usb_configuration msg_config_driver = { 143 143 .label = "Linux File-Backed Storage", 144 - .bind = msg_do_config, 145 144 .bConfigurationValue = 1, 146 145 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 147 146 }; ··· 152 153 { 153 154 int status; 154 155 155 - status = usb_add_config(cdev, &msg_config_driver); 156 + status = usb_add_config(cdev, &msg_config_driver, msg_do_config); 156 157 if (status < 0) 157 158 return status; 158 159
+4 -6
drivers/usb/gadget/multi.c
··· 164 164 165 165 #ifdef USB_ETH_RNDIS 166 166 167 - static __ref int rndis_do_config(struct usb_configuration *c) 167 + static __init int rndis_do_config(struct usb_configuration *c) 168 168 { 169 169 int ret; 170 170 ··· 191 191 static int rndis_config_register(struct usb_composite_dev *cdev) 192 192 { 193 193 static struct usb_configuration config = { 194 - .bind = rndis_do_config, 195 194 .bConfigurationValue = MULTI_RNDIS_CONFIG_NUM, 196 195 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 197 196 }; ··· 198 199 config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s; 199 200 config.iConfiguration = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].id; 200 201 201 - return usb_add_config(cdev, &config); 202 + return usb_add_config(cdev, &config, rndis_do_config); 202 203 } 203 204 204 205 #else ··· 215 216 216 217 #ifdef CONFIG_USB_G_MULTI_CDC 217 218 218 - static __ref int cdc_do_config(struct usb_configuration *c) 219 + static __init int cdc_do_config(struct usb_configuration *c) 219 220 { 220 221 int ret; 221 222 ··· 242 243 static int cdc_config_register(struct usb_composite_dev *cdev) 243 244 { 244 245 static struct usb_configuration config = { 245 - .bind = cdc_do_config, 246 246 .bConfigurationValue = MULTI_CDC_CONFIG_NUM, 247 247 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 248 248 }; ··· 249 251 config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s; 250 252 config.iConfiguration = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].id; 251 253 252 - return usb_add_config(cdev, &config); 254 + return usb_add_config(cdev, &config, cdc_do_config); 253 255 } 254 256 255 257 #else
+4 -4
drivers/usb/gadget/nokia.c
··· 135 135 136 136 static struct usb_configuration nokia_config_500ma_driver = { 137 137 .label = "Bus Powered", 138 - .bind = nokia_bind_config, 139 138 .bConfigurationValue = 1, 140 139 /* .iConfiguration = DYNAMIC */ 141 140 .bmAttributes = USB_CONFIG_ATT_ONE, ··· 143 144 144 145 static struct usb_configuration nokia_config_100ma_driver = { 145 146 .label = "Self Powered", 146 - .bind = nokia_bind_config, 147 147 .bConfigurationValue = 2, 148 148 /* .iConfiguration = DYNAMIC */ 149 149 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, ··· 204 206 } 205 207 206 208 /* finaly register the configuration */ 207 - status = usb_add_config(cdev, &nokia_config_500ma_driver); 209 + status = usb_add_config(cdev, &nokia_config_500ma_driver, 210 + nokia_bind_config); 208 211 if (status < 0) 209 212 goto err_usb; 210 213 211 - status = usb_add_config(cdev, &nokia_config_100ma_driver); 214 + status = usb_add_config(cdev, &nokia_config_100ma_driver, 215 + nokia_bind_config); 212 216 if (status < 0) 213 217 goto err_usb; 214 218
+2 -2
drivers/usb/gadget/serial.c
··· 155 155 156 156 static struct usb_configuration serial_config_driver = { 157 157 /* .label = f(use_acm) */ 158 - .bind = serial_bind_config, 159 158 /* .bConfigurationValue = f(use_acm) */ 160 159 /* .iConfiguration = DYNAMIC */ 161 160 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 224 225 } 225 226 226 227 /* register our configuration */ 227 - status = usb_add_config(cdev, &serial_config_driver); 228 + status = usb_add_config(cdev, &serial_config_driver, 229 + serial_bind_config); 228 230 if (status < 0) 229 231 goto fail; 230 232
+2 -2
drivers/usb/gadget/webcam.c
··· 317 317 318 318 static struct usb_configuration webcam_config_driver = { 319 319 .label = webcam_config_label, 320 - .bind = webcam_config_bind, 321 320 .bConfigurationValue = 1, 322 321 .iConfiguration = 0, /* dynamic */ 323 322 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, ··· 353 354 webcam_config_driver.iConfiguration = ret; 354 355 355 356 /* Register our configuration. */ 356 - if ((ret = usb_add_config(cdev, &webcam_config_driver)) < 0) 357 + if ((ret = usb_add_config(cdev, &webcam_config_driver, 358 + webcam_config_bind)) < 0) 357 359 goto error; 358 360 359 361 INFO(cdev, "Webcam Video Gadget\n");
+3 -5
include/linux/usb/composite.h
··· 161 161 * and by language IDs provided in control requests. 162 162 * @descriptors: Table of descriptors preceding all function descriptors. 163 163 * Examples include OTG and vendor-specific descriptors. 164 - * @bind: Called from @usb_add_config() to allocate resources unique to this 165 - * configuration and to call @usb_add_function() for each function used. 166 164 * @unbind: Reverses @bind; called as a side effect of unregistering the 167 165 * driver which added this configuration. 168 166 * @setup: Used to delegate control requests that aren't handled by standard ··· 205 207 * we can't restructure things to avoid mismatching... 206 208 */ 207 209 208 - /* configuration management: bind/unbind */ 209 - int (*bind)(struct usb_configuration *); 210 + /* configuration management: unbind/setup */ 210 211 void (*unbind)(struct usb_configuration *); 211 212 int (*setup)(struct usb_configuration *, 212 213 const struct usb_ctrlrequest *); ··· 229 232 }; 230 233 231 234 int usb_add_config(struct usb_composite_dev *, 232 - struct usb_configuration *); 235 + struct usb_configuration *, 236 + int (*)(struct usb_configuration *)); 233 237 234 238 /** 235 239 * struct usb_composite_driver - groups configurations into a gadget