aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ieee1394/dv1394.c5
-rw-r--r--drivers/ieee1394/ieee1394_core.h6
-rw-r--r--fs/char_dev.c14
-rw-r--r--include/linux/cdev.h2
-rw-r--r--include/linux/fs.h1
5 files changed, 23 insertions, 5 deletions
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index 823a6297a1af..2cd00b5b45b4 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -1789,12 +1789,13 @@ static int dv1394_open(struct inode *inode, struct file *file)
1789 } else { 1789 } else {
1790 /* look up the card by ID */ 1790 /* look up the card by ID */
1791 unsigned long flags; 1791 unsigned long flags;
1792 int idx = ieee1394_file_to_instance(file);
1792 1793
1793 spin_lock_irqsave(&dv1394_cards_lock, flags); 1794 spin_lock_irqsave(&dv1394_cards_lock, flags);
1794 if (!list_empty(&dv1394_cards)) { 1795 if (!list_empty(&dv1394_cards)) {
1795 struct video_card *p; 1796 struct video_card *p;
1796 list_for_each_entry(p, &dv1394_cards, list) { 1797 list_for_each_entry(p, &dv1394_cards, list) {
1797 if ((p->id) == ieee1394_file_to_instance(file)) { 1798 if ((p->id) == idx) {
1798 video = p; 1799 video = p;
1799 break; 1800 break;
1800 } 1801 }
@@ -1803,7 +1804,7 @@ static int dv1394_open(struct inode *inode, struct file *file)
1803 spin_unlock_irqrestore(&dv1394_cards_lock, flags); 1804 spin_unlock_irqrestore(&dv1394_cards_lock, flags);
1804 1805
1805 if (!video) { 1806 if (!video) {
1806 debug_printk("dv1394: OHCI card %d not found", ieee1394_file_to_instance(file)); 1807 debug_printk("dv1394: OHCI card %d not found", idx);
1807 return -ENODEV; 1808 return -ENODEV;
1808 } 1809 }
1809 1810
diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
index 21d50f73a210..28b9f58bafd2 100644
--- a/drivers/ieee1394/ieee1394_core.h
+++ b/drivers/ieee1394/ieee1394_core.h
@@ -5,6 +5,7 @@
5#include <linux/fs.h> 5#include <linux/fs.h>
6#include <linux/list.h> 6#include <linux/list.h>
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/cdev.h>
8#include <asm/atomic.h> 9#include <asm/atomic.h>
9 10
10#include "hosts.h" 11#include "hosts.h"
@@ -155,7 +156,10 @@ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
155 */ 156 */
156static inline unsigned char ieee1394_file_to_instance(struct file *file) 157static inline unsigned char ieee1394_file_to_instance(struct file *file)
157{ 158{
158 return file->f_path.dentry->d_inode->i_cindex; 159 int idx = cdev_index(file->f_path.dentry->d_inode);
160 if (idx < 0)
161 idx = 0;
162 return idx;
159} 163}
160 164
161extern int hpsb_disable_irm; 165extern int hpsb_disable_irm;
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
407int 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
408void cd_forget(struct inode *inode) 419void 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);
557EXPORT_SYMBOL(cdev_alloc); 568EXPORT_SYMBOL(cdev_alloc);
558EXPORT_SYMBOL(cdev_del); 569EXPORT_SYMBOL(cdev_del);
559EXPORT_SYMBOL(cdev_add); 570EXPORT_SYMBOL(cdev_add);
571EXPORT_SYMBOL(cdev_index);
560EXPORT_SYMBOL(register_chrdev); 572EXPORT_SYMBOL(register_chrdev);
561EXPORT_SYMBOL(unregister_chrdev); 573EXPORT_SYMBOL(unregister_chrdev);
562EXPORT_SYMBOL(directly_mappable_cdev_bdi); 574EXPORT_SYMBOL(directly_mappable_cdev_bdi);
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index fb4591977b03..f389e319a454 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -28,6 +28,8 @@ int cdev_add(struct cdev *, dev_t, unsigned);
28 28
29void cdev_del(struct cdev *); 29void cdev_del(struct cdev *);
30 30
31int cdev_index(struct inode *inode);
32
31void cd_forget(struct inode *); 33void cd_forget(struct inode *);
32 34
33extern struct backing_dev_info directly_mappable_cdev_bdi; 35extern struct backing_dev_info directly_mappable_cdev_bdi;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e7833ef5d1d6..bcd63706db87 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -751,7 +751,6 @@ struct inode {
751 struct block_device *i_bdev; 751 struct block_device *i_bdev;
752 struct cdev *i_cdev; 752 struct cdev *i_cdev;
753 }; 753 };
754 int i_cindex;
755 754
756 __u32 i_generation; 755 __u32 i_generation;
757 756