Commit 8b5332f6 authored by Jonathan Corbet's avatar Jonathan Corbet Committed by Dominik Brodowski

pcmcia: cm40x0 cdev lock_kernel() pushdown

Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 4aeba013
...@@ -1652,16 +1652,22 @@ static int cmm_open(struct inode *inode, struct file *filp) ...@@ -1652,16 +1652,22 @@ static int cmm_open(struct inode *inode, struct file *filp)
struct cm4000_dev *dev; struct cm4000_dev *dev;
struct pcmcia_device *link; struct pcmcia_device *link;
int minor = iminor(inode); int minor = iminor(inode);
int ret;
if (minor >= CM4000_MAX_DEV) if (minor >= CM4000_MAX_DEV)
return -ENODEV; return -ENODEV;
lock_kernel();
link = dev_table[minor]; link = dev_table[minor];
if (link == NULL || !pcmcia_dev_present(link)) if (link == NULL || !pcmcia_dev_present(link)) {
return -ENODEV; ret = -ENODEV;
goto out;
}
if (link->open) if (link->open) {
return -EBUSY; ret = -EBUSY;
goto out;
}
dev = link->priv; dev = link->priv;
filp->private_data = dev; filp->private_data = dev;
...@@ -1681,8 +1687,10 @@ static int cmm_open(struct inode *inode, struct file *filp) ...@@ -1681,8 +1687,10 @@ static int cmm_open(struct inode *inode, struct file *filp)
* vaild = block until valid (or card * vaild = block until valid (or card
* inserted) * inserted)
*/ */
if (filp->f_flags & O_NONBLOCK) if (filp->f_flags & O_NONBLOCK) {
return -EAGAIN; ret = -EAGAIN;
goto out;
}
dev->mdelay = T_50MSEC; dev->mdelay = T_50MSEC;
...@@ -1692,7 +1700,10 @@ static int cmm_open(struct inode *inode, struct file *filp) ...@@ -1692,7 +1700,10 @@ static int cmm_open(struct inode *inode, struct file *filp)
link->open = 1; /* only one open per device */ link->open = 1; /* only one open per device */
DEBUGP(2, dev, "<- cmm_open\n"); DEBUGP(2, dev, "<- cmm_open\n");
return nonseekable_open(inode, filp); ret = nonseekable_open(inode, filp);
out:
unlock_kernel();
return ret;
} }
static int cmm_close(struct inode *inode, struct file *filp) static int cmm_close(struct inode *inode, struct file *filp)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/smp_lock.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -448,23 +449,30 @@ static int cm4040_open(struct inode *inode, struct file *filp) ...@@ -448,23 +449,30 @@ static int cm4040_open(struct inode *inode, struct file *filp)
struct reader_dev *dev; struct reader_dev *dev;
struct pcmcia_device *link; struct pcmcia_device *link;
int minor = iminor(inode); int minor = iminor(inode);
int ret;
if (minor >= CM_MAX_DEV) if (minor >= CM_MAX_DEV)
return -ENODEV; return -ENODEV;
lock_kernel();
link = dev_table[minor]; link = dev_table[minor];
if (link == NULL || !pcmcia_dev_present(link)) if (link == NULL || !pcmcia_dev_present(link)) {
return -ENODEV; ret = -ENODEV;
goto out;
}
if (link->open) if (link->open) {
return -EBUSY; ret = -EBUSY;
goto out;
}
dev = link->priv; dev = link->priv;
filp->private_data = dev; filp->private_data = dev;
if (filp->f_flags & O_NONBLOCK) { if (filp->f_flags & O_NONBLOCK) {
DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n"); DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
return -EAGAIN; ret = -EAGAIN;
goto out;
} }
link->open = 1; link->open = 1;
...@@ -473,7 +481,10 @@ static int cm4040_open(struct inode *inode, struct file *filp) ...@@ -473,7 +481,10 @@ static int cm4040_open(struct inode *inode, struct file *filp)
mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD); mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);
DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); DEBUGP(2, dev, "<- cm4040_open (successfully)\n");
return nonseekable_open(inode, filp); ret = nonseekable_open(inode, filp);
out:
unlock_kernel();
return ret;
} }
static int cm4040_close(struct inode *inode, struct file *filp) static int cm4040_close(struct inode *inode, struct file *filp)
......
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