diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-04-30 09:23:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:30:25 -0400 |
commit | d405640539555b601e52f7d18f1f0b1345d18bf5 (patch) | |
tree | 6a748c0acea0fa72c732d2f188e57153418395e0 /drivers/char/misc.c | |
parent | 6fcf53acccf85b4b0d0260e66c692a341760f464 (diff) |
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: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/misc.c')
-rw-r--r-- | drivers/char/misc.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index a5e0db9d7662..62c99fa59e2b 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
@@ -168,7 +168,6 @@ static const struct file_operations misc_fops = { | |||
168 | .open = misc_open, | 168 | .open = misc_open, |
169 | }; | 169 | }; |
170 | 170 | ||
171 | |||
172 | /** | 171 | /** |
173 | * misc_register - register a miscellaneous device | 172 | * misc_register - register a miscellaneous device |
174 | * @misc: device structure | 173 | * @misc: device structure |
@@ -217,8 +216,8 @@ int misc_register(struct miscdevice * misc) | |||
217 | misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); | 216 | misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); |
218 | dev = MKDEV(MISC_MAJOR, misc->minor); | 217 | dev = MKDEV(MISC_MAJOR, misc->minor); |
219 | 218 | ||
220 | misc->this_device = device_create(misc_class, misc->parent, dev, NULL, | 219 | misc->this_device = device_create(misc_class, misc->parent, dev, |
221 | "%s", misc->name); | 220 | misc, "%s", misc->name); |
222 | if (IS_ERR(misc->this_device)) { | 221 | if (IS_ERR(misc->this_device)) { |
223 | err = PTR_ERR(misc->this_device); | 222 | err = PTR_ERR(misc->this_device); |
224 | goto out; | 223 | goto out; |
@@ -264,6 +263,15 @@ int misc_deregister(struct miscdevice *misc) | |||
264 | EXPORT_SYMBOL(misc_register); | 263 | EXPORT_SYMBOL(misc_register); |
265 | EXPORT_SYMBOL(misc_deregister); | 264 | EXPORT_SYMBOL(misc_deregister); |
266 | 265 | ||
266 | static char *misc_nodename(struct device *dev) | ||
267 | { | ||
268 | struct miscdevice *c = dev_get_drvdata(dev); | ||
269 | |||
270 | if (c->devnode) | ||
271 | return kstrdup(c->devnode, GFP_KERNEL); | ||
272 | return NULL; | ||
273 | } | ||
274 | |||
267 | static int __init misc_init(void) | 275 | static int __init misc_init(void) |
268 | { | 276 | { |
269 | int err; | 277 | int err; |
@@ -279,6 +287,7 @@ static int __init misc_init(void) | |||
279 | err = -EIO; | 287 | err = -EIO; |
280 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) | 288 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) |
281 | goto fail_printk; | 289 | goto fail_printk; |
290 | misc_class->nodename = misc_nodename; | ||
282 | return 0; | 291 | return 0; |
283 | 292 | ||
284 | fail_printk: | 293 | fail_printk: |