On Thu, Oct 03 2013, Andrzej Pietrasiewicz wrote:
> Convert old mass_storage gadget to use the new interface of f_mass_storage
> so that later the compatibility layer in f_mass_storage can be removed.
>
> Signed-off-by: Andrzej Pietrasiewicz <andrze...@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.p...@samsung.com>
> ---
>  drivers/usb/gadget/Kconfig        |    1 +
>  drivers/usb/gadget/mass_storage.c |  107 +++++++++++++++++++++++++++---------
>  2 files changed, 81 insertions(+), 27 deletions(-)

> diff --git a/drivers/usb/gadget/mass_storage.c 
> b/drivers/usb/gadget/mass_storage.c
> index f670251..580f23e 100644
> --- a/drivers/usb/gadget/mass_storage.c
> +++ b/drivers/usb/gadget/mass_storage.c

> @@ -139,13 +132,7 @@ static int msg_thread_exits(struct fsg_common *common)
>  
>  static int __init msg_do_config(struct usb_configuration *c)
>  {
> -     static const struct fsg_operations ops = {
> -             .thread_exits = msg_thread_exits,
> -     };
> -     static struct fsg_common common;
> -
> -     struct fsg_common *retp;
> -     struct fsg_config config;
> +     struct fsg_opts *opts;
>       int ret;
>  
>       if (gadget_is_otg(c->cdev->gadget)) {
> @@ -153,15 +140,24 @@ static int __init msg_do_config(struct 
> usb_configuration *c)
>               c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>       }
>  
> -     fsg_config_from_params(&config, &mod_data, fsg_num_buffers);
> -     config.ops = &ops;
> +     opts = container_of(fi_msg, struct fsg_opts, func_inst);

This line seems to be reappearing over and over.  Perhaps add the
following to the header file:

static inline struct fsg_opts *
fsg_opts_from_func_inst(struct usb_function_instance *fi)
{
        return container_of((fi), struct fsg_opts, func_inst);
}

> +
> +     f_msg = usb_get_function(fi_msg);
> +     if (IS_ERR(f_msg))
> +             return PTR_ERR(f_msg);
>  
> -     retp = fsg_common_init(&common, c->cdev, &config);
> -     if (IS_ERR(retp))
> -             return PTR_ERR(retp);
> +     ret = fsg_common_run_thread(opts->common);
> +     if (ret)
> +             goto put_func;
>  
> -     ret = fsg_bind_config(c->cdev, c, &common);
> -     fsg_common_put(&common);
> +     ret = usb_add_function(c, f_msg);
> +     if (ret)
> +             goto put_func;
> +
> +     return 0;
> +
> +put_func:
> +     usb_put_function(f_msg);
>       return ret;
>  }
>  

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<m...@google.com>--<xmpp:min...@jabber.org>--ooO--(_)--Ooo--

Attachment: signature.asc
Description: PGP signature

Reply via email to