All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-next@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Peter Osterlund <petero2@telia.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	Akinobu Mita <akinobu.mita@gmail.com>
Subject: [PATCH -next] pktcdvd: improve BKL and compat_ioctl.c usage
Date: Thu, 25 Feb 2010 22:27:11 +0100	[thread overview]
Message-ID: <201002252227.11472.arnd@arndb.de> (raw)
In-Reply-To: <4B86B97D.6030208@oracle.com>

The pktcdvd driver uses proper locking and does not need the
BKL in the ioctl and llseek functions of the character device,
so kill both. Moving the compat_ioctl handling from common code
into the driver itself fixes build problems when CONFIG_BLOCK is
disabled.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
On Thursday 25 February 2010, Randy Dunlap wrote:
> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> fs/compat_ioctl.c should omit pktcdvd.h and its ioctl when CONFIG_BLOCK
> is not enabled.  This fixes these build errors:
> 
> In file included from fs/compat_ioctl.c:105:
> include/linux/pktcdvd.h:166: error: field 'read_queue' has incomplete type
> include/linux/pktcdvd.h:167: error: field 'write_queue' has incomplete type
> include/linux/pktcdvd.h:207: error: field 'orig_bios' has incomplete type
> make[2]: *** [fs/compat_ioctl.o] Error 1

How about this one instead, cleaning pktcdvd ioctl handling up for good?

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 68b5957..f508015 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -48,6 +48,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/compat.h>
 #include <linux/kthread.h>
 #include <linux/errno.h>
 #include <linux/spinlock.h>
@@ -3024,7 +3025,7 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
 	mutex_unlock(&ctl_mutex);
 }
 
-static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
 	struct pkt_ctrl_command ctrl_cmd;
@@ -3061,10 +3062,20 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
 	return ret;
 }
 
+#ifdef CONFIG_COMPAT
+static long pkt_ctl_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	return pkt_ctl_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
 
 static const struct file_operations pkt_ctl_fops = {
-	.ioctl	 = pkt_ctl_ioctl,
-	.owner	 = THIS_MODULE,
+	.open		= nonseekable_open,
+	.unlocked_ioctl	= pkt_ctl_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= pkt_ctl_compat_ioctl,
+#endif
+	.owner		= THIS_MODULE,
 };
 
 static struct miscdevice pkt_misc = {
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 0ca9ec4..fa61262 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -102,7 +102,6 @@
 #include <linux/nbd.h>
 #include <linux/random.h>
 #include <linux/filter.h>
-#include <linux/pktcdvd.h>
 
 #include <linux/hiddev.h>
 
@@ -1126,8 +1125,6 @@ COMPATIBLE_IOCTL(PPGETMODE)
 COMPATIBLE_IOCTL(PPGETPHASE)
 COMPATIBLE_IOCTL(PPGETFLAGS)
 COMPATIBLE_IOCTL(PPSETFLAGS)
-/* pktcdvd */
-COMPATIBLE_IOCTL(PACKET_CTRL_CMD)
 /* Big A */
 /* sparc only */
 /* Big Q for sound/OSS */

  reply	other threads:[~2010-02-25 21:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-25  7:35 linux-next: Tree for February 25 Stephen Rothwell
2010-02-25 17:21 ` linux-next: Tree for February 25 (quota) Randy Dunlap
2010-03-01 13:27   ` Jan Kara
2010-03-01 16:56     ` Randy Dunlap
2010-02-25 17:55 ` [PATCH -next] staging: fix wlan-ng printk format warning Randy Dunlap
2010-02-25 17:55 ` [PATCH -next] fs: fix compat_ioctl when CONFIG_BLOCK=n Randy Dunlap
2010-02-25 21:27   ` Arnd Bergmann [this message]
2010-02-25 22:10     ` [PATCH -next] pktcdvd: improve BKL and compat_ioctl.c usage Randy Dunlap
2010-03-02 12:06       ` Ingo Molnar
2010-03-02 23:38         ` Stephen Rothwell
2010-02-25 22:41 ` [PATCH -next] staging/pohmelfs: fix write_inode parameter warning Randy Dunlap
2010-02-26  0:41   ` Stephen Rothwell
2010-03-07  9:22   ` Geert Uytterhoeven
2010-03-07 15:50     ` Greg KH

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=201002252227.11472.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=akinobu.mita@gmail.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=petero2@telia.com \
    --cc=randy.dunlap@oracle.com \
    --cc=sfr@canb.auug.org.au \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.