aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2008-06-19 16:34:41 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2008-06-24 09:33:44 -0400
commit8b5332f6994e34f2b400b25975760da709bbaa63 (patch)
tree2ad1bee9616a0be92a54f4c7c747674f6a72b9de
parent4aeba0134f1e54cfd881e118b039ab6ed8b99126 (diff)
pcmcia: cm40x0 cdev lock_kernel() pushdown
Signed-off-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c25
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c23
2 files changed, 35 insertions, 13 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 933a7dd8f86c..59ca35156d81 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1652,16 +1652,22 @@ static int cmm_open(struct inode *inode, struct file *filp)
1652 struct cm4000_dev *dev; 1652 struct cm4000_dev *dev;
1653 struct pcmcia_device *link; 1653 struct pcmcia_device *link;
1654 int minor = iminor(inode); 1654 int minor = iminor(inode);
1655 int ret;
1655 1656
1656 if (minor >= CM4000_MAX_DEV) 1657 if (minor >= CM4000_MAX_DEV)
1657 return -ENODEV; 1658 return -ENODEV;
1658 1659
1660 lock_kernel();
1659 link = dev_table[minor]; 1661 link = dev_table[minor];
1660 if (link == NULL || !pcmcia_dev_present(link)) 1662 if (link == NULL || !pcmcia_dev_present(link)) {
1661 return -ENODEV; 1663 ret = -ENODEV;
1664 goto out;
1665 }
1662 1666
1663 if (link->open) 1667 if (link->open) {
1664 return -EBUSY; 1668 ret = -EBUSY;
1669 goto out;
1670 }
1665 1671
1666 dev = link->priv; 1672 dev = link->priv;
1667 filp->private_data = dev; 1673 filp->private_data = dev;
@@ -1681,8 +1687,10 @@ static int cmm_open(struct inode *inode, struct file *filp)
1681 * vaild = block until valid (or card 1687 * vaild = block until valid (or card
1682 * inserted) 1688 * inserted)
1683 */ 1689 */
1684 if (filp->f_flags & O_NONBLOCK) 1690 if (filp->f_flags & O_NONBLOCK) {
1685 return -EAGAIN; 1691 ret = -EAGAIN;
1692 goto out;
1693 }
1686 1694
1687 dev->mdelay = T_50MSEC; 1695 dev->mdelay = T_50MSEC;
1688 1696
@@ -1692,7 +1700,10 @@ static int cmm_open(struct inode *inode, struct file *filp)
1692 link->open = 1; /* only one open per device */ 1700 link->open = 1; /* only one open per device */
1693 1701
1694 DEBUGP(2, dev, "<- cmm_open\n"); 1702 DEBUGP(2, dev, "<- cmm_open\n");
1695 return nonseekable_open(inode, filp); 1703 ret = nonseekable_open(inode, filp);
1704out:
1705 unlock_kernel();
1706 return ret;
1696} 1707}
1697 1708
1698static int cmm_close(struct inode *inode, struct file *filp) 1709static int cmm_close(struct inode *inode, struct file *filp)
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 035084c07329..6181f8a9b0bd 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -26,6 +26,7 @@
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/poll.h> 28#include <linux/poll.h>
29#include <linux/smp_lock.h>
29#include <linux/wait.h> 30#include <linux/wait.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/io.h> 32#include <asm/io.h>
@@ -448,23 +449,30 @@ static int cm4040_open(struct inode *inode, struct file *filp)
448 struct reader_dev *dev; 449 struct reader_dev *dev;
449 struct pcmcia_device *link; 450 struct pcmcia_device *link;
450 int minor = iminor(inode); 451 int minor = iminor(inode);
452 int ret;
451 453
452 if (minor >= CM_MAX_DEV) 454 if (minor >= CM_MAX_DEV)
453 return -ENODEV; 455 return -ENODEV;
454 456
457 lock_kernel();
455 link = dev_table[minor]; 458 link = dev_table[minor];
456 if (link == NULL || !pcmcia_dev_present(link)) 459 if (link == NULL || !pcmcia_dev_present(link)) {
457 return -ENODEV; 460 ret = -ENODEV;
461 goto out;
462 }
458 463
459 if (link->open) 464 if (link->open) {
460 return -EBUSY; 465 ret = -EBUSY;
466 goto out;
467 }
461 468
462 dev = link->priv; 469 dev = link->priv;
463 filp->private_data = dev; 470 filp->private_data = dev;
464 471
465 if (filp->f_flags & O_NONBLOCK) { 472 if (filp->f_flags & O_NONBLOCK) {
466 DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n"); 473 DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
467 return -EAGAIN; 474 ret = -EAGAIN;
475 goto out;
468 } 476 }
469 477
470 link->open = 1; 478 link->open = 1;
@@ -473,7 +481,10 @@ static int cm4040_open(struct inode *inode, struct file *filp)
473 mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD); 481 mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);
474 482
475 DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); 483 DEBUGP(2, dev, "<- cm4040_open (successfully)\n");
476 return nonseekable_open(inode, filp); 484 ret = nonseekable_open(inode, filp);
485out:
486 unlock_kernel();
487 return ret;
477} 488}
478 489
479static int cm4040_close(struct inode *inode, struct file *filp) 490static int cm4040_close(struct inode *inode, struct file *filp)