diff options
author | Michal Nazarewicz <m.nazarewicz@samsung.com> | 2009-11-09 14:15:26 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 11:55:23 -0800 |
commit | c85efcb9657a7c15e24c1d4745826a80f9a53bbe (patch) | |
tree | e113af4f96b9a232fb8b8c40066d3cb973b45448 /drivers/usb/gadget/mass_storage.c | |
parent | 915c8befccbe5d81d441b53ab7a9a98caf0c67d4 (diff) | |
download | op-kernel-dev-c85efcb9657a7c15e24c1d4745826a80f9a53bbe.zip op-kernel-dev-c85efcb9657a7c15e24c1d4745826a80f9a53bbe.tar.gz |
USB: g_mass_storage: thread_exits callback added
thread_exits callback has been added to fsg_common structure.
This callback is called when MSF's thread exits (is terminated
by a signal or function is unregistered). It's then gadget's
responsibility to unregister the gadget.
Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/mass_storage.c')
-rw-r--r-- | drivers/usb/gadget/mass_storage.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index e43ca8f..19619fb 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -132,9 +132,13 @@ static struct fsg_module_parameters mod_data = { }; FSG_MODULE_PARAMETERS(/* no prefix */, mod_data); +static unsigned long msg_registered = 0; +static void msg_cleanup(void); + static int __init msg_do_config(struct usb_configuration *c) { struct fsg_common *common; + struct fsg_config config; int ret; if (gadget_is_otg(c->cdev->gadget)) { @@ -142,7 +146,9 @@ static int __init msg_do_config(struct usb_configuration *c) c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - common = fsg_common_from_params(0, c->cdev, &mod_data); + fsg_config_from_params(&config, &mod_data); + config.thread_exits = (void(*)(struct fsg_common*))&msg_cleanup; + common = fsg_common_init(0, c->cdev, &config); if (IS_ERR(common)) return PTR_ERR(common); @@ -201,11 +207,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev) return status; dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); - return 0; -} - -static int __exit msg_unbind(struct usb_composite_dev *cdev) -{ + set_bit(0, &msg_registered); return 0; } @@ -218,7 +220,6 @@ static struct usb_composite_driver msg_driver = { .dev = &msg_device_desc, .strings = dev_strings, .bind = msg_bind, - .unbind = __exit_p(msg_unbind), }; MODULE_DESCRIPTION(DRIVER_DESC); @@ -231,8 +232,9 @@ static int __init msg_init(void) } module_init(msg_init); -static void __exit msg_cleanup(void) +static void msg_cleanup(void) { - usb_composite_unregister(&msg_driver); + if (test_and_clear_bit(0, &msg_registered)) + usb_composite_unregister(&msg_driver); } module_exit(msg_cleanup); |