Re: [PATCH v6 13/14] usb/gadget: storage_common: add methods to show/store 'cdrom' and 'removable'

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

 



On Wed, Oct 09 2013, Andrzej Pietrasiewicz wrote:
> This will be required by configfs integration.
>
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
> Signed-off-by: Kyungin Park <kyungmin.park@xxxxxxxxxxx>
> ---
>  drivers/usb/gadget/storage_common.c |   42 +++++++++++++++++++++++++++++++++++
>  drivers/usb/gadget/storage_common.h |    5 ++++
>  2 files changed, 47 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
> index 969948d..c7b78a1 100644
> --- a/drivers/usb/gadget/storage_common.c
> +++ b/drivers/usb/gadget/storage_common.c
> @@ -439,4 +450,35 @@ ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
>  }
>  EXPORT_SYMBOL(fsg_store_file);
>  
> +ssize_t fsg_store_cdrom(struct fsg_lun *curlun, const char *buf, size_t count)
> +{
> +	unsigned	cdrom;
> +	int		ret;
> +
> +	ret = kstrtouint(buf, 2, &cdrom);

Base 2?  That's rather strange.  Just keep it base 10 or use strtobool().

> +	if (ret)
> +		return ret;
> +
> +	curlun->cdrom = cdrom;
> +
> +	return count;
> +}
> +EXPORT_SYMBOL(fsg_store_cdrom);

Loading the module with cdrom set, implies read-only flag, but with this
function, it will become possible to set cdrom without setting read-only
flag.  Some care is needed to make it work properly.

> +
> +ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf,
> +			    size_t count)
> +{
> +	unsigned	removable;
> +	int		ret;
> +
> +	ret = kstrtouint(buf, 2, &removable);
> +	if (ret)
> +		return ret;
> +
> +	curlun->removable = removable;
> +
> +	return count;
> +}
> +EXPORT_SYMBOL(fsg_store_removable);
> +
>  MODULE_LICENSE("GPL");

-- 
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