public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb/serial: Add compat_ioctl pass-through
@ 2008-11-27  8:29 Keith Packard
  2008-11-27  8:29 ` [PATCH] usb/serial/cp2101: Add support for cp2103 GPIO pins Keith Packard
  2008-11-27 14:31 ` [PATCH] usb/serial: Add compat_ioctl pass-through Arnd Bergmann
  0 siblings, 2 replies; 19+ messages in thread
From: Keith Packard @ 2008-11-27  8:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Keith Packard

USB serial devices with extended IOCTLs cannot be used in a 64-bit kernel
from 32-bit user space as the compat_ioctl path is missing. This adds a
pass-through so that drivers may offer this functionality. This requires
that all drivers actually implement a compat_ioctl function if they want to
support this operation.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 drivers/usb/serial/usb-serial.c |   22 ++++++++++++++++++++++
 include/linux/usb/serial.h      |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 794b5ff..8fb4e13 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -381,6 +381,27 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
 	return retval;
 }
 
+static long serial_compat_ioctl(struct tty_struct *tty, struct file *file,
+			       unsigned int cmd, unsigned long arg)
+{
+	struct usb_serial_port *port = tty->driver_data;
+	long retval = -ENODEV;
+
+	dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
+
+	WARN_ON(!port->port.count);
+
+	/* pass on to the driver specific version of this function
+	   if it is available */
+	if (port->serial->type->compat_ioctl) {
+		lock_kernel();
+		retval = port->serial->type->compat_ioctl(tty, file, cmd, arg);
+		unlock_kernel();
+	} else
+		retval = -ENOIOCTLCMD;
+	return retval;
+}
+
 static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
 	struct usb_serial_port *port = tty->driver_data;
@@ -1095,6 +1116,7 @@ static const struct tty_operations serial_ops = {
 	.write =		serial_write,
 	.write_room =		serial_write_room,
 	.ioctl =		serial_ioctl,
+	.compat_ioctl =		serial_compat_ioctl,
 	.set_termios =		serial_set_termios,
 	.throttle =		serial_throttle,
 	.unthrottle =		serial_unthrottle,
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 0b8617a..c15766a 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -228,6 +228,8 @@ struct usb_serial_driver {
 	int  (*write_room)(struct tty_struct *tty);
 	int  (*ioctl)(struct tty_struct *tty, struct file *file,
 		      unsigned int cmd, unsigned long arg);
+	long  (*compat_ioctl)(struct tty_struct *tty, struct file *file,
+			      unsigned int cmd, unsigned long arg);
 	void (*set_termios)(struct tty_struct *tty,
 			struct usb_serial_port *port, struct ktermios *old);
 	void (*break_ctl)(struct tty_struct *tty, int break_state);
-- 
1.5.6.5


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

end of thread, other threads:[~2008-12-03  9:09 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27  8:29 [PATCH] usb/serial: Add compat_ioctl pass-through Keith Packard
2008-11-27  8:29 ` [PATCH] usb/serial/cp2101: Add support for cp2103 GPIO pins Keith Packard
2008-11-27 10:58   ` Alan Cox
2008-11-27 18:20     ` Keith Packard
2008-11-27 18:41       ` Greg KH
2008-11-28  1:31         ` Keith Packard
2008-12-03  7:12           ` Greg KH
2008-12-03  8:11             ` Keith Packard
2008-11-27 14:31 ` [PATCH] usb/serial: Add compat_ioctl pass-through Arnd Bergmann
2008-11-27 18:27   ` Keith Packard
2008-11-28 11:43     ` Arnd Bergmann
2008-11-28 14:03       ` Alan Cox
2008-11-28 15:42         ` Arnd Bergmann
2008-11-28 22:28           ` Keith Packard
2008-11-28 22:33             ` Alan Cox
2008-11-29  1:02               ` Keith Packard
2008-11-29  1:10                 ` Alan Cox
2008-11-29  1:23                   ` Arjan van de Ven
2008-11-29  1:37                     ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox