Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 151257
b: refs/heads/master
c: f7a386c
h: refs/heads/master
i:
  151255: 3b4d334
v: v3
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed Jun 16, 2009
1 parent 803d5b6 commit bfbdb02
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d405640539555b601e52f7d18f1f0b1345d18bf5
refs/heads/master: f7a386c5b8ff34cd84ae922603d1c6f9d234edee
7 changes: 6 additions & 1 deletion trunk/drivers/hid/usbhid/hiddev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions trunk/drivers/media/video/dabusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
6 changes: 6 additions & 0 deletions trunk/drivers/usb/class/usblp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
13 changes: 12 additions & 1 deletion trunk/drivers/usb/core/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions trunk/drivers/usb/core/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
6 changes: 6 additions & 0 deletions trunk/drivers/usb/misc/iowarrior.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
6 changes: 6 additions & 0 deletions trunk/drivers/usb/misc/legousbtower.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit bfbdb02

Please sign in to comment.