diff options
Diffstat (limited to 'fs/char_dev.c')
-rw-r--r-- | fs/char_dev.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/char_dev.c b/fs/char_dev.c index 38f71222a552..b7c9d5187a75 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c | |||
@@ -375,7 +375,6 @@ static int chrdev_open(struct inode *inode, struct file *filp) | |||
375 | p = inode->i_cdev; | 375 | p = inode->i_cdev; |
376 | if (!p) { | 376 | if (!p) { |
377 | inode->i_cdev = p = new; | 377 | inode->i_cdev = p = new; |
378 | inode->i_cindex = idx; | ||
379 | list_add(&inode->i_devices, &p->list); | 378 | list_add(&inode->i_devices, &p->list); |
380 | new = NULL; | 379 | new = NULL; |
381 | } else if (!cdev_get(p)) | 380 | } else if (!cdev_get(p)) |
@@ -405,6 +404,18 @@ static int chrdev_open(struct inode *inode, struct file *filp) | |||
405 | return ret; | 404 | return ret; |
406 | } | 405 | } |
407 | 406 | ||
407 | int cdev_index(struct inode *inode) | ||
408 | { | ||
409 | int idx; | ||
410 | struct kobject *kobj; | ||
411 | |||
412 | kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx); | ||
413 | if (!kobj) | ||
414 | return -1; | ||
415 | kobject_put(kobj); | ||
416 | return idx; | ||
417 | } | ||
418 | |||
408 | void cd_forget(struct inode *inode) | 419 | void cd_forget(struct inode *inode) |
409 | { | 420 | { |
410 | spin_lock(&cdev_lock); | 421 | spin_lock(&cdev_lock); |
@@ -557,6 +568,7 @@ EXPORT_SYMBOL(cdev_init); | |||
557 | EXPORT_SYMBOL(cdev_alloc); | 568 | EXPORT_SYMBOL(cdev_alloc); |
558 | EXPORT_SYMBOL(cdev_del); | 569 | EXPORT_SYMBOL(cdev_del); |
559 | EXPORT_SYMBOL(cdev_add); | 570 | EXPORT_SYMBOL(cdev_add); |
571 | EXPORT_SYMBOL(cdev_index); | ||
560 | EXPORT_SYMBOL(register_chrdev); | 572 | EXPORT_SYMBOL(register_chrdev); |
561 | EXPORT_SYMBOL(unregister_chrdev); | 573 | EXPORT_SYMBOL(unregister_chrdev); |
562 | EXPORT_SYMBOL(directly_mappable_cdev_bdi); | 574 | EXPORT_SYMBOL(directly_mappable_cdev_bdi); |