From 9b20776b05d6ed4a96dc37b79bee695b2010f2a0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 23 Jun 2016 22:28:54 +0200 Subject: [PATCH] usb: gadget: f_hid: add dev to configfs 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. Change-Id: If11a531a4b65cbcfb5c5456712c5f965fd4eb4c2 Signed-off-by: Johannes Berg Signed-off-by: Felipe Balbi Git-commit: ed6fe1f50f0c0fdea674dfa739af50011034bdfa Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git Signed-off-by: Ajay Agarwal --- drivers/usb/gadget/function/f_hid.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index a5dae5bb62ab..b43de80518b0 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -825,11 +825,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, }; -- 2.11.0