cpwatchdog: implement ->compat_ioctl
PATCH 1/1 cpwatchdog: implement ->compat_ioctl
Index: linux-2.6/arch/sparc64/kernel/ioctl32.c
=================================--- linux-2.6.orig/arch/sparc64/kernel/ioctl32.c 2005-11-07 11:56:00.000000000 +0100
+++ linux-2.6/arch/sparc64/kernel/ioctl32.c 2005-11-07 11:56:21.000000000 +0100
@@ -121,9 +121,6 @@
/* Little v, the video4linux ioctls */
COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
-COMPATIBLE_IOCTL(WIOCSTART)
-COMPATIBLE_IOCTL(WIOCSTOP)
-COMPATIBLE_IOCTL(WIOCGSTAT)
/* And these ioctls need translation */
/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */ HANDLE_IOCTL(FBIOPUTCMAP32, fbiogetputcmap)
Index: linux-2.6/drivers/sbus/char/cpwatchdog.c
=================================--- linux-2.6.orig/drivers/sbus/char/cpwatchdog.c 2005-11-07 11:53:44.000000000 +0100
+++ linux-2.6/drivers/sbus/char/cpwatchdog.c 2005-11-07 11:56:11.000000000 +0100
@@ -26,6 +26,7 @@
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/timer.h>
+#include <linux/smp_lock.h>
#include <asm/irq.h>
#include <asm/ebus.h>
#include <asm/oplib.h>
@@ -394,6 +395,28 @@
return(0);
}
+static long wd_compat_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int rval = -ENOIOCTLCMD;
+
+ switch (cmd) {
+ /* solaris ioctls are specific to this driver */
+ case WIOCSTART:
+ case WIOCSTOP:
+ case WIOCGSTAT:
+ lock_kernel();
+ rval = wd_ioctl(file->f_dentry->d_inode, file, cmd, arg);
+ lock_kernel();
+ break;
+ /* everything else is handled by the generic compat layer */
+ default:
+ break;
+ }
+
+ return rval;
+}
+
static ssize_t wd_write(struct file *file,
const char __user *buf,
size_t count,
@@ -441,6 +464,7 @@
static struct file_operations wd_fops = {
.owner = THIS_MODULE,
.ioctl = wd_ioctl,
+ .compat_ioctl = wd_compat_ioctl,
.open = wd_open,
.write = wd_write,
.read = wd_read,
David S. Miller
AppliedFrom: Christoph Hellwig <[email protected]>
Date: Mon, 7 Nov 2005 20:43:20 +0100
Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>
Applied, thanks.
We seem to be calling lock_kernel() twice here too-- am I misunderstanding some nuance of the BKL?
E
Quoted 11 lines · David S. Miller
From: Christoph Hellwig <[email protected]>
Date: Mon, 7 Nov 2005 20:43:20 +0100Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>Applied, thanks.
-
To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
E
I noticed the envctrl.c patch bounds the assignment of .compat_ioctl by #ifdef CONFIG_COMPAT but the patch to cpwatchdog.c does not. What's the currently preferred convention? I'd assume it is unnecessary for in-kernel drivers, but I'd appreciate your take.
Thanks,
E
Quoted 11 lines · David S. Miller
From: Christoph Hellwig <[email protected]>
Date: Mon, 7 Nov 2005 20:43:20 +0100Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>Applied, thanks.
-
To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
E
Quoted 4 lines · Eric Brower
I noticed the
envctrl.cpatch bounds the assignment of .compat_ioctl by #ifdefCONFIG_COMPATbut the patch tocpwatchdog.cdoes not. What's the currently preferred convention? I'd assume it is unnecessary for in-kernel drivers, but I'd appreciate your take.
I'm a bit confused on that aswell as you can see ;-) Generally I'm not a big fan of ifdefs, but for some compat_ioctl handlers it seems to be nessecary because they use contructs not available outside it. if envctrl.c compiles without the ifdef and without CONFIG_COMPAT set feel free to remove it.