usb: gadget: rndis: init & exit rndis at module load/unload

This is required in preparation for using usb_gstrings_attach.

The rndis initialization so far has been performed on the first
occurence of rndis_bind(), but the condition to check it (first
or not first) was "borrowed" from strings handling.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Andrzej Pietrasiewicz 2013-05-28 09:15:59 +02:00 committed by Felipe Balbi
parent 9bd4a10e1b
commit 76da66d170
3 changed files with 4 additions and 18 deletions

View File

@ -698,11 +698,6 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
#endif #endif
if (rndis_string_defs[0].id == 0) { if (rndis_string_defs[0].id == 0) {
/* ... and setup RNDIS itself */
status = rndis_init();
if (status < 0)
return status;
status = usb_string_ids_tab(c->cdev, rndis_string_defs); status = usb_string_ids_tab(c->cdev, rndis_string_defs);
if (status) if (status)
return status; return status;
@ -844,7 +839,6 @@ rndis_old_unbind(struct usb_configuration *c, struct usb_function *f)
struct f_rndis *rndis = func_to_rndis(f); struct f_rndis *rndis = func_to_rndis(f);
rndis_deregister(rndis->config); rndis_deregister(rndis->config);
rndis_exit();
rndis_string_defs[0].id = 0; rndis_string_defs[0].id = 0;
usb_free_all_descriptors(f); usb_free_all_descriptors(f);
@ -891,11 +885,9 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
rndis->port.func.disable = rndis_disable; rndis->port.func.disable = rndis_disable;
status = usb_add_function(c, &rndis->port.func); status = usb_add_function(c, &rndis->port.func);
if (status) { if (status)
kfree(rndis); kfree(rndis);
fail: fail:
rndis_exit();
}
return status; return status;
} }
@ -958,7 +950,6 @@ static void rndis_unbind(struct usb_configuration *c, struct usb_function *f)
{ {
struct f_rndis *rndis = func_to_rndis(f); struct f_rndis *rndis = func_to_rndis(f);
rndis_exit();
rndis_string_defs[0].id = 0; rndis_string_defs[0].id = 0;
usb_free_all_descriptors(f); usb_free_all_descriptors(f);
@ -974,10 +965,8 @@ static struct usb_function *rndis_alloc(struct usb_function_instance *fi)
/* allocate and initialize one new instance */ /* allocate and initialize one new instance */
rndis = kzalloc(sizeof(*rndis), GFP_KERNEL); rndis = kzalloc(sizeof(*rndis), GFP_KERNEL);
if (!rndis) { if (!rndis)
rndis_exit();
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
}
opts = container_of(fi, struct f_rndis_opts, func_inst); opts = container_of(fi, struct f_rndis_opts, func_inst);

View File

@ -1174,7 +1174,7 @@ int rndis_init(void)
return 0; return 0;
} }
EXPORT_SYMBOL(rndis_init); module_init(rndis_init);
void rndis_exit(void) void rndis_exit(void)
{ {
@ -1188,6 +1188,6 @@ void rndis_exit(void)
} }
#endif #endif
} }
EXPORT_SYMBOL(rndis_exit); module_exit(rndis_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View File

@ -217,7 +217,4 @@ int rndis_signal_disconnect (int configNr);
int rndis_state (int configNr); int rndis_state (int configNr);
extern void rndis_set_host_mac (int configNr, const u8 *addr); extern void rndis_set_host_mac (int configNr, const u8 *addr);
int rndis_init(void);
void rndis_exit (void);
#endif /* _LINUX_RNDIS_H */ #endif /* _LINUX_RNDIS_H */