Skip to content

Commit

Permalink
pcmcia: cm40x0 cdev lock_kernel() pushdown
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
  • Loading branch information
Jonathan Corbet authored and Dominik Brodowski committed Jun 24, 2008
1 parent 4aeba01 commit 8b5332f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
25 changes: 18 additions & 7 deletions drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,16 +1652,22 @@ static int cmm_open(struct inode *inode, struct file *filp)
struct cm4000_dev *dev;
struct pcmcia_device *link;
int minor = iminor(inode);
int ret;

if (minor >= CM4000_MAX_DEV)
return -ENODEV;

lock_kernel();
link = dev_table[minor];
if (link == NULL || !pcmcia_dev_present(link))
return -ENODEV;
if (link == NULL || !pcmcia_dev_present(link)) {
ret = -ENODEV;
goto out;
}

if (link->open)
return -EBUSY;
if (link->open) {
ret = -EBUSY;
goto out;
}

dev = link->priv;
filp->private_data = dev;
Expand All @@ -1681,8 +1687,10 @@ static int cmm_open(struct inode *inode, struct file *filp)
* vaild = block until valid (or card
* inserted)
*/
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
if (filp->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
goto out;
}

dev->mdelay = T_50MSEC;

Expand All @@ -1692,7 +1700,10 @@ static int cmm_open(struct inode *inode, struct file *filp)
link->open = 1; /* only one open per device */

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)
Expand Down
23 changes: 17 additions & 6 deletions drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/fs.h>
#include <linux/delay.h>
#include <linux/poll.h>
#include <linux/smp_lock.h>
#include <linux/wait.h>
#include <asm/uaccess.h>
#include <asm/io.h>
Expand Down Expand Up @@ -448,23 +449,30 @@ static int cm4040_open(struct inode *inode, struct file *filp)
struct reader_dev *dev;
struct pcmcia_device *link;
int minor = iminor(inode);
int ret;

if (minor >= CM_MAX_DEV)
return -ENODEV;

lock_kernel();
link = dev_table[minor];
if (link == NULL || !pcmcia_dev_present(link))
return -ENODEV;
if (link == NULL || !pcmcia_dev_present(link)) {
ret = -ENODEV;
goto out;
}

if (link->open)
return -EBUSY;
if (link->open) {
ret = -EBUSY;
goto out;
}

dev = link->priv;
filp->private_data = dev;

if (filp->f_flags & O_NONBLOCK) {
DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
return -EAGAIN;
ret = -EAGAIN;
goto out;
}

link->open = 1;
Expand All @@ -473,7 +481,10 @@ static int cm4040_open(struct inode *inode, struct file *filp)
mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);

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)
Expand Down

0 comments on commit 8b5332f

Please sign in to comment.