Re: [PATCH] synclink_gt add compat_ioctl

From: Andrew Morton
Date: Thu May 03 2007 - 20:53:35 EST


On Thu, 03 May 2007 13:01:17 -0500
Paul Fulghum <paulkf@xxxxxxxxxxxxx> wrote:

> Add compat_ioctl handler to synclink_gt driver.
>
> The one case requiring a separate 32 bit handler could be
> removed by redefining the associated structure in
> a way compatible with both 32 and 64 bit systems. But that
> approach would break existing native 64 bit user applications.


A made a few changes here...


From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>

- Fix i386 build:

In file included from drivers/char/synclink_gt.c:85:
include/linux/synclink.h:175: error: expected specifier-qualifier-list before 'compat_ulong_t'

- We might as well do the same ifdef-avoidery trick around compat_ioctl()
too. That required that it be renamed.

- It is fishy that apart from one outlier in kexec.h, synclink.h is the
only header file which uses compat_ulong_t. Are we doing this right?

Cc: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Paul Fulghum <paulkf@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

drivers/char/synclink_gt.c | 16 +++++++++-------
include/linux/synclink.h | 5 +++--
2 files changed, 12 insertions(+), 9 deletions(-)

diff -puN drivers/char/synclink_gt.c~synclink_gt-add-compat_ioctl-fix drivers/char/synclink_gt.c
--- a/drivers/char/synclink_gt.c~synclink_gt-add-compat_ioctl-fix
+++ a/drivers/char/synclink_gt.c
@@ -1176,15 +1176,16 @@ static int ioctl(struct tty_struct *tty,
}

#ifdef CONFIG_COMPAT
-static long compat_ioctl(struct tty_struct *tty, struct file *file,
+static long synclink_compat_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct slgt_info *info = tty->driver_data;
int rc = -ENOIOCTLCMD;

- if (sanity_check(info, tty->name, "compat_ioctl"))
+ if (sanity_check(info, tty->name, "synclink_compat_ioctl"))
return -ENODEV;
- DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd));
+ DBGINFO(("%s synclink_compat_ioctl() cmd=%08X\n",
+ info->device_name, cmd));

switch (cmd) {

@@ -1219,9 +1220,12 @@ static long compat_ioctl(struct tty_stru
break;
}

- DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc));
+ DBGINFO(("%s synclink_compat_ioctl() cmd=%08X rc=%d\n",
+ info->device_name, cmd, rc));
return rc;
}
+#else
+#define synclink_compat_ioctl NULL
#endif

/*
@@ -3554,9 +3558,7 @@ static const struct tty_operations ops =
.chars_in_buffer = chars_in_buffer,
.flush_buffer = flush_buffer,
.ioctl = ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = compat_ioctl,
-#endif
+ .compat_ioctl = synclink_compat_ioctl,
.throttle = throttle,
.unthrottle = unthrottle,
.send_xchar = send_xchar,
diff -puN include/linux/synclink.h~synclink_gt-add-compat_ioctl-fix include/linux/synclink.h
--- a/include/linux/synclink.h~synclink_gt-add-compat_ioctl-fix
+++ a/include/linux/synclink.h
@@ -169,9 +169,9 @@ typedef struct _MGSL_PARAMS

} MGSL_PARAMS, *PMGSL_PARAMS;

+#ifdef CONFIG_COMPAT
/* provide 32 bit ioctl compatibility on 64 bit systems */
-struct MGSL_PARAMS32
-{
+struct MGSL_PARAMS32 {
compat_ulong_t mode;
unsigned char loopback;
unsigned short flags;
@@ -186,6 +186,7 @@ struct MGSL_PARAMS32
unsigned char stop_bits;
unsigned char parity;
};
+#endif

#define MICROGATE_VENDOR_ID 0x13c0
#define SYNCLINK_DEVICE_ID 0x0010
_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/