[[RFC]] usb-gadget/f_hid: add major/minor to configfs

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

 



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 major/minor to configfs (read-only) to allow looking
up (or even creating) the right device node for each function.

Signed-off-by: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>
---
Untested so far, since I haven't even tried building my own
kernel for the peripheral I'm using right now...
---
 drivers/usb/gadget/function/f_hid.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 51980c50546d..5668bb32a288 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -809,11 +809,28 @@ end:
 
 CONFIGFS_ATTR(f_hid_opts_, report_desc);
 
+static ssize_t f_hid_opts_major_show(struct config_item *item, char *page)
+{
+	return sprintf(page, "%d\n", major);
+}
+
+static ssize_t f_hid_opts_minor_show(struct config_item *item, char *page)
+{
+	struct f_hid_opts *opts = to_f_hid_opts(item);
+
+	return sprintf(page, "%d\n", opts->minor);
+}
+
+CONFIGFS_ATTR_RO(f_hid_opts_, major);
+CONFIGFS_ATTR_RO(f_hid_opts_, minor);
+
 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_major,
+	&f_hid_opts_attr_minor,
 	NULL,
 };
 
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux