public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jonathan Corbet <corbet@lwn•net>
To: Dominik Brodowski <linux@dominikbrodowski•net>
Cc: Alan Cox <alan@lxorguk•ukuu.org.uk>,
	linux-next@vger•kernel.org,
	Stephen Rothwell <sfr@canb•auug.org.au>
Subject: Re: linux-next: manual merge of pcmcia tree
Date: Thu, 19 Jun 2008 14:34:41 -0600	[thread overview]
Message-ID: <20080619143441.3ab03fcf@bike.lwn.net> (raw)
In-Reply-To: <20080616081258.GA18142@isilmar.linta.de>

[Finally beginning to catch up with life...]

On Mon, 16 Jun 2008 10:12:58 +0200
Dominik Brodowski <linux@dominikbrodowski•net> wrote:

> @Alan,@Jonathan: since this is the same patch, just a different title
> -- shall it be removed from one of our trees?

If you want to have it
in your tree, that's fine with me; the only dependency is that it needs
to be applied *before* the removal of BKL protection to cdev open()
functions or there will be a range of commits over which things are
potentially unsafe - not that I think it would burn even a single
tester.

Here's the patch; if you take it let me know and I'll remove it from
the bkl-removal tree.

Thanks,

jon

--
cm40x0: cdev lock_kernel() pushdown

Signed-off-by: Jonathan Corbet <corbet@lwn•net>

diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 4a933d4..350f596 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -32,6 +32,7 @@
 #include <linux/fs.h>
 #include <linux/delay.h>
 #include <linux/bitrev.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -1631,16 +1632,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;
@@ -1660,8 +1667,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;
 
@@ -1671,7 +1680,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)
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 035084c..6181f8a 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -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>
@@ -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;
@@ -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)
-- 
1.5.4.5


  parent reply	other threads:[~2008-06-19 20:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-16  7:51 linux-next: manual merge of pcmcia tree Stephen Rothwell
2008-06-16  8:12 ` Dominik Brodowski
2008-06-16  8:49   ` Stephen Rothwell
2008-06-16  8:57     ` Dominik Brodowski
2008-06-16  9:04       ` Stephen Rothwell
2008-06-16  9:05         ` Stephen Rothwell
2008-06-19 20:34   ` Jonathan Corbet [this message]
2008-06-20 17:43     ` Dominik Brodowski
2008-06-20 19:53       ` Jonathan Corbet
2008-06-21  3:37         ` Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2008-06-23  7:32 Stephen Rothwell
2008-06-24 13:49 ` Dominik Brodowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080619143441.3ab03fcf@bike.lwn.net \
    --to=corbet@lwn$(echo .)net \
    --cc=alan@lxorguk$(echo .)ukuu.org.uk \
    --cc=linux-next@vger$(echo .)kernel.org \
    --cc=linux@dominikbrodowski$(echo .)net \
    --cc=sfr@canb$(echo .)auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox