usb: gadget: f_hid: add dev to configfs
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 23 Jun 2016 20:28:54 +0000 (22:28 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 25 Aug 2016 09:13:16 +0000 (12:13 +0300)
Even if the /dev/hidg* chardev is automatically created, one
has to guess which one belongs to which function. In the case
of multiple HID functions, or maybe even multiple peripherals,
this becomes difficult.

Add the dev (with major and minor number) to configfs to allow
looking up (or even creating) the right device node for each
function. This file is read-only.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_hid.c

index 51980c50546d5b1061eb289b8825604cf8b031bc..4cd486600a9b18d2ac34d42e04bfe41f41af2e96 100644 (file)
@@ -809,11 +809,21 @@ end:
 
 CONFIGFS_ATTR(f_hid_opts_, report_desc);
 
+static ssize_t f_hid_opts_dev_show(struct config_item *item, char *page)
+{
+       struct f_hid_opts *opts = to_f_hid_opts(item);
+
+       return sprintf(page, "%d:%d\n", major, opts->minor);
+}
+
+CONFIGFS_ATTR_RO(f_hid_opts_, dev);
+
 static struct configfs_attribute *hid_attrs[] = {
        &f_hid_opts_attr_subclass,
        &f_hid_opts_attr_protocol,
        &f_hid_opts_attr_report_length,
        &f_hid_opts_attr_report_desc,
+       &f_hid_opts_attr_dev,
        NULL,
 };
 
This page took 0.025093 seconds and 5 git commands to generate.