Commit d4056405 authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

Driver Core: misc: add nodename support for misc devices.

This adds support for misc devices to report their requested nodename to
userspace.  It also updates a number of misc drivers to provide the
needed subdirectory and device name to be used for them.
Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarJan Blunck <jblunck@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6fcf53ac
...@@ -236,6 +236,7 @@ static const struct file_operations microcode_fops = { ...@@ -236,6 +236,7 @@ static const struct file_operations microcode_fops = {
static struct miscdevice microcode_dev = { static struct miscdevice microcode_dev = {
.minor = MICROCODE_MINOR, .minor = MICROCODE_MINOR,
.name = "microcode", .name = "microcode",
.devnode = "cpu/microcode",
.fops = &microcode_fops, .fops = &microcode_fops,
}; };
......
...@@ -153,6 +153,7 @@ static const struct file_operations rng_chrdev_ops = { ...@@ -153,6 +153,7 @@ static const struct file_operations rng_chrdev_ops = {
static struct miscdevice rng_miscdev = { static struct miscdevice rng_miscdev = {
.minor = RNG_MISCDEV_MINOR, .minor = RNG_MISCDEV_MINOR,
.name = RNG_MODULE_NAME, .name = RNG_MODULE_NAME,
.devnode = "hwrng",
.fops = &rng_chrdev_ops, .fops = &rng_chrdev_ops,
}; };
......
...@@ -168,7 +168,6 @@ static const struct file_operations misc_fops = { ...@@ -168,7 +168,6 @@ static const struct file_operations misc_fops = {
.open = misc_open, .open = misc_open,
}; };
/** /**
* misc_register - register a miscellaneous device * misc_register - register a miscellaneous device
* @misc: device structure * @misc: device structure
...@@ -217,8 +216,8 @@ int misc_register(struct miscdevice * misc) ...@@ -217,8 +216,8 @@ int misc_register(struct miscdevice * misc)
misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
dev = MKDEV(MISC_MAJOR, misc->minor); dev = MKDEV(MISC_MAJOR, misc->minor);
misc->this_device = device_create(misc_class, misc->parent, dev, NULL, misc->this_device = device_create(misc_class, misc->parent, dev,
"%s", misc->name); misc, "%s", misc->name);
if (IS_ERR(misc->this_device)) { if (IS_ERR(misc->this_device)) {
err = PTR_ERR(misc->this_device); err = PTR_ERR(misc->this_device);
goto out; goto out;
...@@ -264,6 +263,15 @@ int misc_deregister(struct miscdevice *misc) ...@@ -264,6 +263,15 @@ int misc_deregister(struct miscdevice *misc)
EXPORT_SYMBOL(misc_register); EXPORT_SYMBOL(misc_register);
EXPORT_SYMBOL(misc_deregister); EXPORT_SYMBOL(misc_deregister);
static char *misc_nodename(struct device *dev)
{
struct miscdevice *c = dev_get_drvdata(dev);
if (c->devnode)
return kstrdup(c->devnode, GFP_KERNEL);
return NULL;
}
static int __init misc_init(void) static int __init misc_init(void)
{ {
int err; int err;
...@@ -279,6 +287,7 @@ static int __init misc_init(void) ...@@ -279,6 +287,7 @@ static int __init misc_init(void)
err = -EIO; err = -EIO;
if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
goto fail_printk; goto fail_printk;
misc_class->nodename = misc_nodename;
return 0; return 0;
fail_printk: fail_printk:
......
...@@ -1513,6 +1513,7 @@ static const struct file_operations _ctl_fops = { ...@@ -1513,6 +1513,7 @@ static const struct file_operations _ctl_fops = {
static struct miscdevice _dm_misc = { static struct miscdevice _dm_misc = {
.minor = MISC_DYNAMIC_MINOR, .minor = MISC_DYNAMIC_MINOR,
.name = DM_NAME, .name = DM_NAME,
.devnode = "mapper/control",
.fops = &_ctl_fops .fops = &_ctl_fops
}; };
......
...@@ -1366,6 +1366,7 @@ static const struct file_operations tun_fops = { ...@@ -1366,6 +1366,7 @@ static const struct file_operations tun_fops = {
static struct miscdevice tun_miscdev = { static struct miscdevice tun_miscdev = {
.minor = TUN_MINOR, .minor = TUN_MINOR,
.name = "tun", .name = "tun",
.devnode = "net/tun",
.fops = &tun_fops, .fops = &tun_fops,
}; };
......
...@@ -41,6 +41,7 @@ struct miscdevice { ...@@ -41,6 +41,7 @@ struct miscdevice {
struct list_head list; struct list_head list;
struct device *parent; struct device *parent;
struct device *this_device; struct device *this_device;
const char *devnode;
}; };
extern int misc_register(struct miscdevice * misc); extern int misc_register(struct miscdevice * misc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment