On Fri, Oct 11 2013, Andrzej Pietrasiewicz wrote: > W dniu 10.10.2013 20:05, Michal Nazarewicz pisze: >> 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(). > > I vote for strtobool(). One thing to keep in mind though, is that wit strtobool() the interface for those files would be different from the interface for the other files. Namely, cdrom would accept, 0, 1, n, N, y and Y, whereas the other files would accept numbers and treat non-zero as true. >>> + 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. > > Is it enough if I call fsg_store_ro() before actually assigning > curlun->crdrom = cdrom? I don't think you need to call fsg_store_ro, just set the ro flag if cdrom flog is being set. -- 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