From: Andrzej Pietrasiewicz Date: Tue, 14 Jan 2014 13:26:46 +0000 (+0100) Subject: Revert "usb/gadget: mass_storage: convert to new interface of f_mass_storage" X-Git-Tag: submit/tizen/20141121.110247~2786 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=29f43d0a6b4cdefc0dcfe1e8343974e81acb9791;p=platform%2Fkernel%2Flinux-3.10.git Revert "usb/gadget: mass_storage: convert to new interface of f_mass_storage" This reverts commit d42b40a01037255c0609cfae1607bdf7524c8c75. --- diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 6214b79..99a9f04 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -897,7 +897,6 @@ config USB_MASS_STORAGE depends on BLOCK select USB_LIBCOMPOSITE select USB_U_MS - select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. As its storage repository it can use a regular file or a block diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 39a5316..6b79814 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -46,7 +46,17 @@ #define FSG_VENDOR_ID 0x0525 /* NetChip */ #define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ -#include "f_mass_storage.h" +/*-------------------------------------------------------------------------*/ + +/* + * kbuild is not very cooperative with respect to linking separately + * compiled library objects into one module. So for now we won't use + * separate compilation ... ensuring init/exit sections work to shrink + * the runtime footprint, and giving us at least some parts of what + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. + */ +#define USB_FMS_INCLUDED +#include "f_mass_storage.c" /*-------------------------------------------------------------------------*/ USB_GADGET_COMPOSITE_OPTIONS(); @@ -97,9 +107,6 @@ static struct usb_gadget_strings *dev_strings[] = { NULL, }; -static struct usb_function_instance *fi_msg; -static struct usb_function *f_msg; - /****************************** Configurations ******************************/ static struct fsg_module_parameters mod_data = { @@ -132,7 +139,13 @@ static int msg_thread_exits(struct fsg_common *common) static int __init msg_do_config(struct usb_configuration *c) { - struct fsg_opts *opts; + static const struct fsg_operations ops = { + .thread_exits = msg_thread_exits, + }; + static struct fsg_common common; + + struct fsg_common *retp; + struct fsg_config config; int ret; if (gadget_is_otg(c->cdev->gadget)) { @@ -140,24 +153,15 @@ static int __init msg_do_config(struct usb_configuration *c) c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - opts = container_of(fi_msg, struct fsg_opts, func_inst); - - f_msg = usb_get_function(fi_msg); - if (IS_ERR(f_msg)) - return PTR_ERR(f_msg); - - ret = fsg_common_run_thread(opts->common); - if (ret) - goto put_func; + fsg_config_from_params(&config, &mod_data, fsg_num_buffers); + config.ops = &ops; - ret = usb_add_function(c, f_msg); - if (ret) - goto put_func; + retp = fsg_common_init(&common, c->cdev, &config); + if (IS_ERR(retp)) + return PTR_ERR(retp); - return 0; - -put_func: - usb_put_function(f_msg); + ret = fsg_bind_config(c->cdev, c, &common); + fsg_common_put(&common); return ret; } @@ -172,79 +176,23 @@ static struct usb_configuration msg_config_driver = { static int __init msg_bind(struct usb_composite_dev *cdev) { - static const struct fsg_operations ops = { - .thread_exits = msg_thread_exits, - }; - struct fsg_opts *opts; - struct fsg_config config; int status; - fi_msg = usb_get_function_instance("mass_storage"); - if (IS_ERR(fi_msg)) - return PTR_ERR(fi_msg); - - fsg_config_from_params(&config, &mod_data, fsg_num_buffers); - opts = container_of(fi_msg, struct fsg_opts, func_inst); - - opts->no_configfs = true; - status = fsg_common_set_num_buffers(opts->common, fsg_num_buffers); - if (status) - goto fail; - - status = fsg_common_set_nluns(opts->common, config.nluns); - if (status) - goto fail_set_nluns; - - fsg_common_set_ops(opts->common, &ops); - - status = fsg_common_set_cdev(opts->common, cdev, config.can_stall); - if (status) - goto fail_set_cdev; - - fsg_common_set_sysfs(opts->common, true); - status = fsg_common_create_luns(opts->common, &config); - if (status) - goto fail_set_cdev; - - fsg_common_set_inquiry_string(opts->common, config.vendor_name, - config.product_name); - status = usb_string_ids_tab(cdev, strings_dev); if (status < 0) - goto fail_string_ids; + return status; msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; status = usb_add_config(cdev, &msg_config_driver, msg_do_config); if (status < 0) - goto fail_string_ids; - + return status; usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&cdev->gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); set_bit(0, &msg_registered); return 0; - -fail_string_ids: - fsg_common_remove_luns(opts->common); -fail_set_cdev: - fsg_common_free_luns(opts->common); -fail_set_nluns: - fsg_common_free_buffers(opts->common); -fail: - usb_put_function_instance(fi_msg); - return status; } -static int msg_unbind(struct usb_composite_dev *cdev) -{ - if (!IS_ERR(f_msg)) - usb_put_function(f_msg); - - if (!IS_ERR(fi_msg)) - usb_put_function_instance(fi_msg); - - return 0; -} /****************************** Some noise ******************************/ @@ -255,7 +203,6 @@ static __refdata struct usb_composite_driver msg_driver = { .needs_serial = 1, .strings = dev_strings, .bind = msg_bind, - .unbind = msg_unbind, }; MODULE_DESCRIPTION(DRIVER_DESC);