Re: [PATCH v2 10/21] usb/gadget: f_mass_storage: use fsg_common_set_num_buffers in fsg_common_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 |   29 +++--------------------------
>  1 files changed, 3 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index 0f40d35..5a129c9 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -3001,17 +3001,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
>  				   struct fsg_config *cfg)
>  {
>  	struct usb_gadget *gadget = cdev->gadget;
> -	struct fsg_buffhd *bh;
>  	struct fsg_lun **curlun_it;
>  	struct fsg_lun_config *lcfg;
>  	struct usb_string *us;
>  	int nluns, i, rc;
>  	char *pathbuf;
>  
> -	rc = fsg_num_buffers_validate(cfg->fsg_num_buffers);
> -	if (rc != 0)
> -		return ERR_PTR(rc);
> -
>  	/* Find out how many LUNs there should be */
>  	nluns = cfg->nluns;
>  	if (nluns < 1 || nluns > FSG_MAX_LUNS) {
> @@ -3025,15 +3020,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
>  	common->sysfs = true;
>  	common->state = FSG_STATE_IDLE;
>  
> -	common->fsg_num_buffers = cfg->fsg_num_buffers;
> -	common->buffhds = kcalloc(common->fsg_num_buffers,
> -				  sizeof *(common->buffhds), GFP_KERNEL);
> -	if (!common->buffhds) {
> +	rc = fsg_common_set_num_buffers(common, cfg->fsg_num_buffers);
> +	if (rc) {
>  		if (common->free_storage_on_release)
>  			kfree(common);
> -		return ERR_PTR(-ENOMEM);
> +		return ERR_PTR(rc);
>  	}
> -
>  	common->ops = cfg->ops;
>  	common->private_data = cfg->private_data;
>  
> @@ -3126,21 +3118,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
>  	}
>  	common->nluns = nluns;
>  
> -	/* Data buffers cyclic list */
> -	bh = common->buffhds;
> -	i = common->fsg_num_buffers;
> -	goto buffhds_first_it;
> -	do {
> -		bh->next = bh + 1;
> -		++bh;
> -buffhds_first_it:
> -		bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
> -		if (unlikely(!bh->buf)) {
> -			rc = -ENOMEM;
> -			goto error_release;
> -		}
> -	} while (--i);
> -	bh->next = common->buffhds;
>  
>  	/* Prepare inquiryString */
>  	i = get_default_bcdDevice();
> -- 
> 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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux