From: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> 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> --- drivers/usb/gadget/f_mass_storage.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index f833c35..6869134 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2984,12 +2984,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)) @@ -3019,17 +3013,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 = kcalloc(nluns, sizeof(*curlun), GFP_KERNEL); - if (unlikely(!curlun)) { - rc = -ENOMEM; - goto error_release; - } - common->luns = curlun; + rc = fsg_common_set_nluns(common, cfg->nluns); + if (rc) + goto error_release; + curlun = common->luns; + nluns = cfg->nluns; for (i = 0, lcfg = cfg->luns; i < nluns; ++i, ++curlun, ++lcfg) { *curlun = kzalloc(sizeof(**curlun), GFP_KERNEL); if (!*curlun) { @@ -3082,7 +3071,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, goto error_luns; } } - common->nluns = nluns; /* Prepare inquiryString */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html