All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pmu: add compat_pmu_ioctl
@ 2010-08-21 21:32 Andreas Schwab
  2010-08-22 11:33 ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2010-08-21 21:32 UTC (permalink / raw)
  To: linuxppc-dev

The ioctls are actually compatible, but due to historical mistake the
numbers differ between 32bit and 64bit.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 drivers/macintosh/via-pmu.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 35bc273..610f247 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2349,11 +2349,52 @@ static long pmu_unlocked_ioctl(struct file *filp,
 	return ret;
 }
 
+#ifdef CONFIG_COMPAT
+#define PMU_IOC_GET_BACKLIGHT32	_IOR('B', 1, u32)
+#define PMU_IOC_SET_BACKLIGHT32	_IOW('B', 2, u32)
+#define PMU_IOC_GET_MODEL32	_IOR('B', 3, u32)
+#define PMU_IOC_HAS_ADB32	_IOR('B', 4, u32)
+#define PMU_IOC_CAN_SLEEP32	_IOR('B', 5, u32)
+#define PMU_IOC_GRAB_BACKLIGHT32 _IOR('B', 6, u32)
+
+static long compat_pmu_ioctl (struct file *filp, u_int cmd, u_long arg)
+{
+	switch (cmd) {
+	case PMU_IOC_SLEEP:
+		break;
+	case PMU_IOC_GET_BACKLIGHT32:
+		cmd = PMU_IOC_GET_BACKLIGHT;
+		break;
+	case PMU_IOC_SET_BACKLIGHT32:
+		cmd = PMU_IOC_SET_BACKLIGHT;
+		break;
+	case PMU_IOC_GET_MODEL32:
+		cmd = PMU_IOC_GET_MODEL;
+		break;
+	case PMU_IOC_HAS_ADB32:
+		cmd = PMU_IOC_HAS_ADB;
+		break;
+	case PMU_IOC_CAN_SLEEP32:
+		cmd = PMU_IOC_CAN_SLEEP;
+		break;
+	case PMU_IOC_GRAB_BACKLIGHT32:
+		cmd = PMU_IOC_GRAB_BACKLIGHT;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return pmu_unlocked_ioctl(filp, cmd, arg);
+}
+#endif
+
 static const struct file_operations pmu_device_fops = {
 	.read		= pmu_read,
 	.write		= pmu_write,
 	.poll		= pmu_fpoll,
 	.unlocked_ioctl	= pmu_unlocked_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= compat_pmu_ioctl,
+#endif
 	.open		= pmu_open,
 	.release	= pmu_release,
 };
-- 
1.7.2.2


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] pmu: add compat_pmu_ioctl
  2010-08-21 21:32 [PATCH] pmu: add compat_pmu_ioctl Andreas Schwab
@ 2010-08-22 11:33 ` Arnd Bergmann
  2010-08-22 16:23   ` [PATCH/v2] via-pmu: " Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2010-08-22 11:33 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Andreas Schwab

On Saturday 21 August 2010 23:32:23 Andreas Schwab wrote:
> The ioctls are actually compatible, but due to historical mistake the
> numbers differ between 32bit and 64bit.

Looks good to me, but

> +#ifdef CONFIG_COMPAT
> +#define PMU_IOC_GET_BACKLIGHT32	_IOR('B', 1, u32)
> +#define PMU_IOC_SET_BACKLIGHT32	_IOW('B', 2, u32)
> +#define PMU_IOC_GET_MODEL32	_IOR('B', 3, u32)
> +#define PMU_IOC_HAS_ADB32	_IOR('B', 4, u32)
> +#define PMU_IOC_CAN_SLEEP32	_IOR('B', 5, u32)
> +#define PMU_IOC_GRAB_BACKLIGHT32 _IOR('B', 6, u32)

It would be nicer to use compat_size_t instead of u32 for annotation
purposes. Obviously both of them are defined as unsigned int, so
that is no functional change.

> +	return pmu_unlocked_ioctl(filp, cmd, arg);

This should ideally use "(unsigned long)compat_ptr(arg)" instead of
just arg. Also doesn't matter on powerpc, but it's better to do
it the strict way.

	Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH/v2] via-pmu: add compat_pmu_ioctl
  2010-08-22 11:33 ` Arnd Bergmann
@ 2010-08-22 16:23   ` Andreas Schwab
  2010-08-23  8:53     ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2010-08-22 16:23 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev

The ioctls are actually compatible, but due to historical mistake the
numbers differ between 32bit and 64bit.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 drivers/macintosh/via-pmu.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 35bc273..2d17e76 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -45,6 +45,7 @@
 #include <linux/syscalls.h>
 #include <linux/suspend.h>
 #include <linux/cpu.h>
+#include <linux/compat.h>
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
@@ -2349,11 +2350,52 @@ static long pmu_unlocked_ioctl(struct file *filp,
 	return ret;
 }
 
+#ifdef CONFIG_COMPAT
+#define PMU_IOC_GET_BACKLIGHT32	_IOR('B', 1, compat_size_t)
+#define PMU_IOC_SET_BACKLIGHT32	_IOW('B', 2, compat_size_t)
+#define PMU_IOC_GET_MODEL32	_IOR('B', 3, compat_size_t)
+#define PMU_IOC_HAS_ADB32	_IOR('B', 4, compat_size_t)
+#define PMU_IOC_CAN_SLEEP32	_IOR('B', 5, compat_size_t)
+#define PMU_IOC_GRAB_BACKLIGHT32 _IOR('B', 6, compat_size_t)
+
+static long compat_pmu_ioctl (struct file *filp, u_int cmd, u_long arg)
+{
+	switch (cmd) {
+	case PMU_IOC_SLEEP:
+		break;
+	case PMU_IOC_GET_BACKLIGHT32:
+		cmd = PMU_IOC_GET_BACKLIGHT;
+		break;
+	case PMU_IOC_SET_BACKLIGHT32:
+		cmd = PMU_IOC_SET_BACKLIGHT;
+		break;
+	case PMU_IOC_GET_MODEL32:
+		cmd = PMU_IOC_GET_MODEL;
+		break;
+	case PMU_IOC_HAS_ADB32:
+		cmd = PMU_IOC_HAS_ADB;
+		break;
+	case PMU_IOC_CAN_SLEEP32:
+		cmd = PMU_IOC_CAN_SLEEP;
+		break;
+	case PMU_IOC_GRAB_BACKLIGHT32:
+		cmd = PMU_IOC_GRAB_BACKLIGHT;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return pmu_unlocked_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
+
 static const struct file_operations pmu_device_fops = {
 	.read		= pmu_read,
 	.write		= pmu_write,
 	.poll		= pmu_fpoll,
 	.unlocked_ioctl	= pmu_unlocked_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= compat_pmu_ioctl,
+#endif
 	.open		= pmu_open,
 	.release	= pmu_release,
 };
-- 
1.7.2.2


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH/v2] via-pmu: add compat_pmu_ioctl
  2010-08-22 16:23   ` [PATCH/v2] via-pmu: " Andreas Schwab
@ 2010-08-23  8:53     ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2010-08-23  8:53 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linuxppc-dev

On Sunday 22 August 2010, Andreas Schwab wrote:
> The ioctls are actually compatible, but due to historical mistake the
> numbers differ between 32bit and 64bit.
> 
> Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-23  8:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-21 21:32 [PATCH] pmu: add compat_pmu_ioctl Andreas Schwab
2010-08-22 11:33 ` Arnd Bergmann
2010-08-22 16:23   ` [PATCH/v2] via-pmu: " Andreas Schwab
2010-08-23  8:53     ` Arnd Bergmann

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.