Re: [PATCH v5 03/15] usb/gadget: f_mass_storage: create fsg_common_setup for use in fsg_common_init

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

 



On Thu, Oct 03 2013, Andrzej Pietrasiewicz wrote:
> fsg_common_init is a lengthy function. Factor a portion of it out.
>
> 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 |   41 +++++++++++++++++++++-------------
>  1 files changed, 25 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index 14c9e5b..b7ed792 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2643,6 +2643,28 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers)
>  	return -EINVAL;
>  }
>  
> +static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero)

I don't see the point of zero argument.

> +{
> +	if (!common) {
> +		common = kzalloc(sizeof(*common), GFP_KERNEL);
> +		if (!common)
> +			return ERR_PTR(-ENOMEM);
> +		common->free_storage_on_release = 1;
> +	} else {
> +		if (zero)
> +			memset(common, 0, sizeof(*common));
> +		common->free_storage_on_release = 0;
> +	}
> +	init_rwsem(&common->filesem);
> +	spin_lock_init(&common->lock);
> +	kref_init(&common->ref);
> +	init_completion(&common->thread_notifier);
> +	init_waitqueue_head(&common->fsg_wait);
> +	common->state = FSG_STATE_TERMINATED;
> +
> +	return common;
> +}
> +
>  void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs)
>  {
>  	common->sysfs = sysfs;

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@xxxxxxxxxx>--<xmpp:mina86@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