summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/function/f_mass_storage.c
diff options
context:
space:
mode:
authorPhilipp Gesang <philipp.gesang@intra2net.com>2016-08-01 17:04:19 +0200
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-08-25 12:13:13 +0300
commit6ac47090eef0c4358b04a974c4a5ac3d9bf44f79 (patch)
tree2b2f8a6f6a25fc182a3f5042c00c8532d03f689e /drivers/usb/gadget/function/f_mass_storage.c
parentf652191be3f6bc997bbaf9bd4e8ec6dc96f44433 (diff)
downloadop-kernel-dev-6ac47090eef0c4358b04a974c4a5ac3d9bf44f79.zip
op-kernel-dev-6ac47090eef0c4358b04a974c4a5ac3d9bf44f79.tar.gz
usb: gadget: Add per-lun inquiry string
Introduce an attribute "inquiry_string" to the lun. In some environments, e. g. BIOS boot menus, the inquiry string is the only information about devices presented to the user. The default string depends on the "cdrom" bit of the first lun as well as the kernel version and allows no further customization. So without access to the client it is not obvious which gadget is active at a given point and what any of the available luns might contain. If "inquiry_string" is ignored or set to the empty string, the old behavior is preserved. Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/gadget/function/f_mass_storage.c')
-rw-r--r--drivers/usb/gadget/function/f_mass_storage.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 2505117..8f3659b 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -311,11 +311,7 @@ struct fsg_common {
/* Gadget's private data. */
void *private_data;
- /*
- * Vendor (8 chars), product (16 chars), release (4
- * hexadecimal digits) and NUL byte
- */
- char inquiry_string[8 + 16 + 4 + 1];
+ char inquiry_string[INQUIRY_STRING_LEN];
struct kref ref;
};
@@ -1107,7 +1103,12 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh)
buf[5] = 0; /* No special options */
buf[6] = 0;
buf[7] = 0;
- memcpy(buf + 8, common->inquiry_string, sizeof common->inquiry_string);
+ if (curlun->inquiry_string[0])
+ memcpy(buf + 8, curlun->inquiry_string,
+ sizeof(curlun->inquiry_string));
+ else
+ memcpy(buf + 8, common->inquiry_string,
+ sizeof(common->inquiry_string));
return 36;
}
@@ -3209,12 +3210,27 @@ static ssize_t fsg_lun_opts_nofua_store(struct config_item *item,
CONFIGFS_ATTR(fsg_lun_opts_, nofua);
+static ssize_t fsg_lun_opts_inquiry_string_show(struct config_item *item,
+ char *page)
+{
+ return fsg_show_inquiry_string(to_fsg_lun_opts(item)->lun, page);
+}
+
+static ssize_t fsg_lun_opts_inquiry_string_store(struct config_item *item,
+ const char *page, size_t len)
+{
+ return fsg_store_inquiry_string(to_fsg_lun_opts(item)->lun, page, len);
+}
+
+CONFIGFS_ATTR(fsg_lun_opts_, inquiry_string);
+
static struct configfs_attribute *fsg_lun_attrs[] = {
&fsg_lun_opts_attr_file,
&fsg_lun_opts_attr_ro,
&fsg_lun_opts_attr_removable,
&fsg_lun_opts_attr_cdrom,
&fsg_lun_opts_attr_nofua,
+ &fsg_lun_opts_attr_inquiry_string,
NULL,
};
OpenPOWER on IntegriCloud