From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Kay Sievers <kay.sievers@vrfy.org>, Jan Blunck <jblunck@suse.de>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 27/64] Driver Core: usb: add nodename support for usb drivers.
Date: Mon, 15 Jun 2009 22:46:16 -0700 [thread overview]
Message-ID: <1245131213-24168-27-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20090616051351.GA23627@kroah.com>
From: Kay Sievers <kay.sievers@vrfy.org>
This adds support for USB drivers to report their requested nodename to
userspace. It also updates a number of USB drivers to provide the
needed subdirectory and device name to be used for them.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/hid/usbhid/hiddev.c | 7 ++++++-
drivers/media/video/dabusb.c | 6 ++++++
drivers/usb/class/usblp.c | 6 ++++++
drivers/usb/core/file.c | 13 ++++++++++++-
drivers/usb/core/usb.c | 11 +++++++++++
drivers/usb/misc/iowarrior.c | 6 ++++++
drivers/usb/misc/legousbtower.c | 6 ++++++
include/linux/usb.h | 3 +++
8 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index e9b436d..9e94215 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -850,8 +850,14 @@ static const struct file_operations hiddev_fops = {
#endif
};
+static char *hiddev_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
static struct usb_class_driver hiddev_class = {
.name = "hiddev%d",
+ .nodename = hiddev_nodename,
.fops = &hiddev_fops,
.minor_base = HIDDEV_MINOR_BASE,
};
@@ -955,7 +961,6 @@ static int hiddev_usbd_probe(struct usb_interface *intf,
return -ENODEV;
}
-
static /* const */ struct usb_driver hiddev_driver = {
.name = "hiddev",
.probe = hiddev_usbd_probe,
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c
index ba3709b..ec2f45d 100644
--- a/drivers/media/video/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -747,8 +747,14 @@ static const struct file_operations dabusb_fops =
.release = dabusb_release,
};
+static char *dabusb_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
static struct usb_class_driver dabusb_class = {
.name = "dabusb%d",
+ .nodename = dabusb_nodename,
.fops = &dabusb_fops,
.minor_base = DABUSB_MINOR,
};
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index d2747a4..26c09f0 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1057,8 +1057,14 @@ static const struct file_operations usblp_fops = {
.release = usblp_release,
};
+static char *usblp_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
static struct usb_class_driver usblp_class = {
.name = "lp%d",
+ .nodename = usblp_nodename,
.fops = &usblp_fops,
.minor_base = USBLP_MINOR_BASE,
};
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 997e659..5cef889 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -67,6 +67,16 @@ static struct usb_class {
struct class *class;
} *usb_class;
+static char *usb_nodename(struct device *dev)
+{
+ struct usb_class_driver *drv;
+
+ drv = dev_get_drvdata(dev);
+ if (!drv || !drv->nodename)
+ return NULL;
+ return drv->nodename(dev);
+}
+
static int init_usb_class(void)
{
int result = 0;
@@ -90,6 +100,7 @@ static int init_usb_class(void)
kfree(usb_class);
usb_class = NULL;
}
+ usb_class->class->nodename = usb_nodename;
exit:
return result;
@@ -198,7 +209,7 @@ int usb_register_dev(struct usb_interface *intf,
else
temp = name;
intf->usb_dev = device_create(usb_class->class, &intf->dev,
- MKDEV(USB_MAJOR, minor), NULL,
+ MKDEV(USB_MAJOR, minor), class_driver,
"%s", temp);
if (IS_ERR(intf->usb_dev)) {
down_write(&minor_rwsem);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 7eee400..927a27d 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -305,10 +305,21 @@ static struct dev_pm_ops usb_device_pm_ops = {
#endif /* CONFIG_PM */
+
+static char *usb_nodename(struct device *dev)
+{
+ struct usb_device *usb_dev;
+
+ usb_dev = to_usb_device(dev);
+ return kasprintf(GFP_KERNEL, "bus/usb/%03d/%03d",
+ usb_dev->bus->busnum, usb_dev->devnum);
+}
+
struct device_type usb_device_type = {
.name = "usb_device",
.release = usb_release_dev,
.uevent = usb_dev_uevent,
+ .nodename = usb_nodename,
.pm = &usb_device_pm_ops,
};
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index a4ef77e..3c5fe5c 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -726,12 +726,18 @@ static const struct file_operations iowarrior_fops = {
.poll = iowarrior_poll,
};
+static char *iowarrior_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
/*
* usb class driver info in order to get a minor number from the usb core,
* and to have the device registered with devfs and the driver core
*/
static struct usb_class_driver iowarrior_class = {
.name = "iowarrior%d",
+ .nodename = iowarrior_nodename,
.fops = &iowarrior_fops,
.minor_base = IOWARRIOR_MINOR_BASE,
};
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index ab0f322..c1e2433 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -266,12 +266,18 @@ static const struct file_operations tower_fops = {
.llseek = tower_llseek,
};
+static char *legousbtower_nodename(struct device *dev)
+{
+ return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
+}
+
/*
* usb class driver info in order to get a minor number from the usb core,
* and to have the device registered with the driver core
*/
static struct usb_class_driver tower_class = {
.name = "legousbtower%d",
+ .nodename = legousbtower_nodename,
.fops = &tower_fops,
.minor_base = LEGO_USB_TOWER_MINOR_BASE,
};
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 3aa2cd1..34cdfca 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -869,6 +869,8 @@ struct usb_driver {
* struct usb_device_driver - identifies USB device driver to usbcore
* @name: The driver name should be unique among USB drivers,
* and should normally be the same as the module name.
+ * @nodename: Callback to provide a naming hint for a possible
+ * device node to create.
* @probe: Called to see if the driver is willing to manage a particular
* device. If it is, probe returns zero and uses dev_set_drvdata()
* to associate driver-specific data with the device. If unwilling
@@ -912,6 +914,7 @@ extern struct bus_type usb_bus_type;
*/
struct usb_class_driver {
char *name;
+ char *(*nodename)(struct device *dev);
const struct file_operations *fops;
int minor_base;
};
--
1.6.3.2
next prev parent reply other threads:[~2009-06-16 5:57 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 5:13 [GIT PATCH] driver core patches for 2.6.30-git Greg KH
2009-06-16 5:45 ` [PATCH 01/64] driver core: set default SYSFS_DEPRECATED=n Greg Kroah-Hartman
2009-06-24 15:02 ` Pavel Machek
2009-06-16 5:45 ` [PATCH 02/64] sched: delayed cleanup of user_struct Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 03/64] Driver Core: Warn driver authors about adding device attributes Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 04/64] Sysfs: fix possible memleak in sysfs_follow_link Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 05/64] driver core: firmware_class: replace kfree(dev) with put_device(dev) Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 06/64] driver core: add BUS_NOTIFY_UNBOUND_DRIVER event Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 07/64] driver core: Const-correct platform getbyname functions Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 08/64] debugfs: dont stop on first failed recursive delete Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 09/64] Driver core: fix comment for device_attach() Greg Kroah-Hartman
2009-06-16 5:45 ` [PATCH 10/64] kobject: make kset_create check kobject_set_name return value Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 11/64] driver-core: make sysdev_class_register " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 12/64] debugfs: fix docbook error Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 13/64] driver core: synchronize device shutdown Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 14/64] kobject: samples: make SAMPLE_KOBJECT module-only Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 15/64] driver core: fix documentation of request_firmware_nowait Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 16/64] firmware: allocate firmware id dynamically Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 17/64] firmware: atm/ueagle-atm: prepare for FIRMWARE_NAME_MAX removal Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 18/64] firmware: tuners/xc2028: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 19/64] firmware: dvb/dvb-usb: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 20/64] firmware: pcmcia/ds: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 21/64] firmware: wireless/libertas: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 22/64] firmware: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 23/64] firmware: remove broken example files Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 24/64] driver core: fix gcc 4.3.3 warnings about string literals Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 25/64] Driver Core: add nodename callbacks Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 26/64] Driver Core: misc: add nodename support for misc devices Greg Kroah-Hartman
2009-06-16 5:46 ` Greg Kroah-Hartman [this message]
2009-06-16 5:46 ` [PATCH 28/64] Driver Core: block: add nodename support for block drivers Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 29/64] Driver Core: x86: add nodename for cpuid and msr drivers Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 30/64] Driver Core: dvb: add nodename for dvb drivers Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 31/64] Driver Core: input: add nodename for input drivers Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 32/64] Driver Core: sound: add nodename for sound drivers Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 33/64] Driver Core: raw: add nodename for raw devices Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 34/64] Driver Core: drm: add nodename for drm devices Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 35/64] Driver Core: aoe: add nodename for aoe devices Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 36/64] Driver Core: bsg: add nodename for bsg driver Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 37/64] eisa: remove driver_data direct access of struct device Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 38/64] firewire: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 39/64] ide: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 40/64] ieee1394: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 41/64] infiniband: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 42/64] input: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 43/64] media: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 44/64] mfd: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 45/64] PCIE: " Greg Kroah-Hartman
2009-06-16 17:13 ` Jesse Barnes
2009-06-16 17:17 ` Greg KH
2009-06-16 5:46 ` [PATCH 46/64] pcmcia: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 47/64] scsi: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 48/64] thermal: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 49/64] xen block: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 50/64] hvcs: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 51/64] ibmvscsi: gadget: at91_udc: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 52/64] infiniband: ehca: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 53/64] ipmi: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 54/64] mips: " Greg Kroah-Hartman
2009-06-16 9:31 ` Ralf Baechle
2009-06-16 16:25 ` Greg KH
2009-06-16 5:46 ` [PATCH 55/64] of_serial: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 56/64] parisc: " Greg Kroah-Hartman
2009-06-16 15:15 ` Kyle McMartin
2009-06-16 16:25 ` Greg KH
2009-06-16 17:24 ` Kyle McMartin
2009-06-16 5:46 ` [PATCH 57/64] parport: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 58/64] s390: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 59/64] block/ps3: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 60/64] uml: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 61/64] usb: gadget: at91_udc: " Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 62/64] xen: remove driver_data direct access of struct device from more drivers Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 63/64] debugfs: Fix terminology inconsistency of dir name to mount debugfs filesystem Greg Kroah-Hartman
2009-06-16 5:46 ` [PATCH 64/64] debugfs: use specified mode to possibly mark files read/write only Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1245131213-24168-27-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=jblunck@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®