Commit 3872b925 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix device open return values

The recent conversion of the open-of-a-nonexistent-blockdev return value from
ENXO to ENODEV was wrong.  We should have converted the chardev code to
return -ENXIO too.
parent f49e140b
...@@ -550,7 +550,7 @@ static int do_open(struct block_device *bdev, struct file *file) ...@@ -550,7 +550,7 @@ static int do_open(struct block_device *bdev, struct file *file)
{ {
struct module *owner = NULL; struct module *owner = NULL;
struct gendisk *disk; struct gendisk *disk;
int ret = -ENODEV; int ret = -ENXIO;
int part; int part;
file->f_mapping = bdev->bd_inode->i_mapping; file->f_mapping = bdev->bd_inode->i_mapping;
...@@ -563,7 +563,6 @@ static int do_open(struct block_device *bdev, struct file *file) ...@@ -563,7 +563,6 @@ static int do_open(struct block_device *bdev, struct file *file)
} }
owner = disk->fops->owner; owner = disk->fops->owner;
ret = -ENXIO;
down(&bdev->bd_sem); down(&bdev->bd_sem);
if (!bdev->bd_openers) { if (!bdev->bd_openers) {
bdev->bd_disk = disk; bdev->bd_disk = disk;
......
...@@ -265,7 +265,7 @@ int chrdev_open(struct inode * inode, struct file * filp) ...@@ -265,7 +265,7 @@ int chrdev_open(struct inode * inode, struct file * filp)
spin_unlock(&cdev_lock); spin_unlock(&cdev_lock);
kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx); kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
if (!kobj) if (!kobj)
return -ENODEV; return -ENXIO;
new = container_of(kobj, struct cdev, kobj); new = container_of(kobj, struct cdev, kobj);
spin_lock(&cdev_lock); spin_lock(&cdev_lock);
p = inode->i_cdev; p = inode->i_cdev;
...@@ -275,9 +275,9 @@ int chrdev_open(struct inode * inode, struct file * filp) ...@@ -275,9 +275,9 @@ int chrdev_open(struct inode * inode, struct file * filp)
list_add(&inode->i_devices, &p->list); list_add(&inode->i_devices, &p->list);
new = NULL; new = NULL;
} else if (!cdev_get(p)) } else if (!cdev_get(p))
ret = -ENODEV; ret = -ENXIO;
} else if (!cdev_get(p)) } else if (!cdev_get(p))
ret = -ENODEV; ret = -ENXIO;
spin_unlock(&cdev_lock); spin_unlock(&cdev_lock);
cdev_put(new); cdev_put(new);
if (ret) if (ret)
...@@ -285,7 +285,7 @@ int chrdev_open(struct inode * inode, struct file * filp) ...@@ -285,7 +285,7 @@ int chrdev_open(struct inode * inode, struct file * filp)
filp->f_op = fops_get(p->ops); filp->f_op = fops_get(p->ops);
if (!filp->f_op) { if (!filp->f_op) {
cdev_put(p); cdev_put(p);
return -ENODEV; return -ENXIO;
} }
if (filp->f_op->open) { if (filp->f_op->open) {
lock_kernel(); lock_kernel();
......
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