On Fri, Jul 19 2013, Andrzej Pietrasiewicz wrote: > fsg_common_init is a lengthy function. Now there are helper functions > which cover all parts of it. Use them. > > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> > Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx> Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx> > --- > drivers/usb/gadget/f_mass_storage.c | 22 +++++----------------- > 1 files changed, 5 insertions(+), 17 deletions(-) > > diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c > index 5a129c9..9981694 100644 > --- a/drivers/usb/gadget/f_mass_storage.c > +++ b/drivers/usb/gadget/f_mass_storage.c > @@ -3007,12 +3007,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, > int nluns, i, rc; > char *pathbuf; > > - /* Find out how many LUNs there should be */ > - nluns = cfg->nluns; > - if (nluns < 1 || nluns > FSG_MAX_LUNS) { > - dev_err(&gadget->dev, "invalid number of LUNs: %u\n", nluns); > - return ERR_PTR(-EINVAL); > - } > > common = fsg_common_setup(common, !!common); > if (IS_ERR(common)) > @@ -3042,17 +3036,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, > } > fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; > > - /* > - * Create the LUNs, open their backing files, and register the > - * LUN devices in sysfs. > - */ > - curlun_it = kcalloc(nluns, sizeof(*curlun_it), GFP_KERNEL); > - if (unlikely(!curlun_it)) { > - rc = -ENOMEM; > - goto error_release; > - } > - common->luns = curlun_it; > > + rc = fsg_common_set_nluns(common, cfg->nluns); > + if (rc) > + goto error_release; > + curlun_it = common->luns; > + nluns = cfg->nluns; > for (i = 0, lcfg = cfg->luns; i < nluns; ++i, ++curlun_it, ++lcfg) { > struct fsg_lun *curlun; > > @@ -3116,7 +3105,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, > goto error_luns; > } > } > - common->nluns = nluns; > > > /* Prepare inquiryString */ > -- > 1.7.0.4 > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +----<email/xmpp: mpn@xxxxxxxxxx>--------------ooO--(_)--Ooo--
Attachment:
signature.asc
Description: PGP signature