aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/hp/sim/simserial.c24
-rw-r--r--drivers/bluetooth/hci_ldisc.c1
-rw-r--r--drivers/char/pcmcia/synclink_cs.c3
-rw-r--r--drivers/input/serio/serport.c2
-rw-r--r--drivers/isdn/capi/capi.c7
-rw-r--r--drivers/isdn/gigaset/interface.c13
-rw-r--r--drivers/isdn/i4l/isdn_tty.c19
-rw-r--r--drivers/net/hamradio/6pack.c21
-rw-r--r--drivers/net/hamradio/mkiss.c21
-rw-r--r--drivers/net/slip/slip.c25
-rw-r--r--drivers/net/wan/x25_asy.c19
-rw-r--r--drivers/staging/dgnc/dgnc_tty.c218
-rw-r--r--drivers/staging/fwserial/fwserial.c66
-rw-r--r--drivers/staging/greybus/uart.c47
-rw-r--r--drivers/tty/amiserial.c90
-rw-r--r--drivers/tty/cyclades.c77
-rw-r--r--drivers/tty/ipwireless/tty.c36
-rw-r--r--drivers/tty/isicom.c72
-rw-r--r--drivers/tty/moxa.c79
-rw-r--r--drivers/tty/mxser.c97
-rw-r--r--drivers/tty/n_gsm.c11
-rw-r--r--drivers/tty/n_r3964.c22
-rw-r--r--drivers/tty/pty.c14
-rw-r--r--drivers/tty/serial/serial_core.c43
-rw-r--r--drivers/tty/synclink.c3
-rw-r--r--drivers/tty/synclink_gt.c19
-rw-r--r--drivers/tty/synclinkmp.c3
-rw-r--r--drivers/tty/tty_io.c229
-rw-r--r--drivers/tty/tty_ioctl.c16
-rw-r--r--drivers/tty/vt/vt_ioctl.c31
-rw-r--r--drivers/usb/class/cdc-acm.c41
-rw-r--r--drivers/usb/serial/ark3116.c38
-rw-r--r--drivers/usb/serial/f81232.c36
-rw-r--r--drivers/usb/serial/f81534.c38
-rw-r--r--drivers/usb/serial/ftdi_sio.c48
-rw-r--r--drivers/usb/serial/io_edgeport.c37
-rw-r--r--drivers/usb/serial/io_ti.c47
-rw-r--r--drivers/usb/serial/mos7720.c86
-rw-r--r--drivers/usb/serial/mos7840.c39
-rw-r--r--drivers/usb/serial/opticon.c43
-rw-r--r--drivers/usb/serial/option.c3
-rw-r--r--drivers/usb/serial/pl2303.c29
-rw-r--r--drivers/usb/serial/quatech2.c42
-rw-r--r--drivers/usb/serial/ssu100.c42
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c74
-rw-r--r--drivers/usb/serial/usb-serial.c20
-rw-r--r--drivers/usb/serial/usb-wwan.h6
-rw-r--r--drivers/usb/serial/usb_wwan.c63
-rw-r--r--drivers/usb/serial/whiteheat.c42
-rw-r--r--fs/compat_ioctl.c169
-rw-r--r--include/linux/tty.h2
-rw-r--r--include/linux/tty_driver.h3
-rw-r--r--include/linux/tty_ldisc.h10
-rw-r--r--include/linux/usb/serial.h2
-rw-r--r--net/bluetooth/rfcomm/tty.c12
-rw-r--r--net/nfc/nci/uart.c1
56 files changed, 779 insertions, 1522 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 663388a73d4e..7aeb48a18576 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -297,29 +297,29 @@ static void rs_unthrottle(struct tty_struct * tty)
297 printk(KERN_INFO "simrs_unthrottle called\n"); 297 printk(KERN_INFO "simrs_unthrottle called\n");
298} 298}
299 299
300static int rs_setserial(struct tty_struct *tty, struct serial_struct *ss)
301{
302 return 0;
303}
304
305static int rs_getserial(struct tty_struct *tty, struct serial_struct *ss)
306{
307 return 0;
308}
309
300static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) 310static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
301{ 311{
302 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 312 if ((cmd != TIOCSERCONFIG) && (cmd != TIOCMIWAIT)) {
303 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
304 (cmd != TIOCMIWAIT)) {
305 if (tty_io_error(tty)) 313 if (tty_io_error(tty))
306 return -EIO; 314 return -EIO;
307 } 315 }
308 316
309 switch (cmd) { 317 switch (cmd) {
310 case TIOCGSERIAL:
311 case TIOCSSERIAL:
312 case TIOCSERGSTRUCT:
313 case TIOCMIWAIT: 318 case TIOCMIWAIT:
314 return 0; 319 return 0;
315 case TIOCSERCONFIG: 320 case TIOCSERCONFIG:
316 case TIOCSERGETLSR: /* Get line status register */ 321 case TIOCSERGETLSR: /* Get line status register */
317 return -EINVAL; 322 return -EINVAL;
318 case TIOCSERGWILD:
319 case TIOCSERSWILD:
320 /* "setserial -W" is called in Debian boot */
321 printk (KERN_INFO "TIOCSER?WILD ioctl obsolete, ignored.\n");
322 return 0;
323 } 323 }
324 return -ENOIOCTLCMD; 324 return -ENOIOCTLCMD;
325} 325}
@@ -448,6 +448,8 @@ static const struct tty_operations hp_ops = {
448 .throttle = rs_throttle, 448 .throttle = rs_throttle,
449 .unthrottle = rs_unthrottle, 449 .unthrottle = rs_unthrottle,
450 .send_xchar = rs_send_xchar, 450 .send_xchar = rs_send_xchar,
451 .set_serial = rs_setserial,
452 .get_serial = rs_getserial,
451 .hangup = rs_hangup, 453 .hangup = rs_hangup,
452 .proc_show = rs_proc_show, 454 .proc_show = rs_proc_show,
453}; 455};
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index ea6238ed5c0e..fbf7b4df23ab 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -823,6 +823,7 @@ static int __init hci_uart_init(void)
823 hci_uart_ldisc.read = hci_uart_tty_read; 823 hci_uart_ldisc.read = hci_uart_tty_read;
824 hci_uart_ldisc.write = hci_uart_tty_write; 824 hci_uart_ldisc.write = hci_uart_tty_write;
825 hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; 825 hci_uart_ldisc.ioctl = hci_uart_tty_ioctl;
826 hci_uart_ldisc.compat_ioctl = hci_uart_tty_ioctl;
826 hci_uart_ldisc.poll = hci_uart_tty_poll; 827 hci_uart_ldisc.poll = hci_uart_tty_poll;
827 hci_uart_ldisc.receive_buf = hci_uart_tty_receive; 828 hci_uart_ldisc.receive_buf = hci_uart_tty_receive;
828 hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup; 829 hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup;
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 66b04194aa9f..82f9a6a814ae 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2237,8 +2237,7 @@ static int mgslpc_ioctl(struct tty_struct *tty,
2237 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) 2237 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl"))
2238 return -ENODEV; 2238 return -ENODEV;
2239 2239
2240 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 2240 if (cmd != TIOCMIWAIT) {
2241 (cmd != TIOCMIWAIT)) {
2242 if (tty_io_error(tty)) 2241 if (tty_io_error(tty))
2243 return -EIO; 2242 return -EIO;
2244 } 2243 }
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index f8ead9f9c77e..5977b8a34ebe 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -226,7 +226,7 @@ static int serport_ldisc_ioctl(struct tty_struct *tty, struct file *file,
226 226
227#ifdef CONFIG_COMPAT 227#ifdef CONFIG_COMPAT
228#define COMPAT_SPIOCSTYPE _IOW('q', 0x01, compat_ulong_t) 228#define COMPAT_SPIOCSTYPE _IOW('q', 0x01, compat_ulong_t)
229static long serport_ldisc_compat_ioctl(struct tty_struct *tty, 229static int serport_ldisc_compat_ioctl(struct tty_struct *tty,
230 struct file *file, 230 struct file *file,
231 unsigned int cmd, unsigned long arg) 231 unsigned int cmd, unsigned long arg)
232{ 232{
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index ef5560b848ab..e1da70a9530c 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1155,12 +1155,6 @@ static int capinc_tty_chars_in_buffer(struct tty_struct *tty)
1155 return mp->outbytes; 1155 return mp->outbytes;
1156} 1156}
1157 1157
1158static int capinc_tty_ioctl(struct tty_struct *tty,
1159 unsigned int cmd, unsigned long arg)
1160{
1161 return -ENOIOCTLCMD;
1162}
1163
1164static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old) 1158static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1165{ 1159{
1166 pr_debug("capinc_tty_set_termios\n"); 1160 pr_debug("capinc_tty_set_termios\n");
@@ -1236,7 +1230,6 @@ static const struct tty_operations capinc_ops = {
1236 .flush_chars = capinc_tty_flush_chars, 1230 .flush_chars = capinc_tty_flush_chars,
1237 .write_room = capinc_tty_write_room, 1231 .write_room = capinc_tty_write_room,
1238 .chars_in_buffer = capinc_tty_chars_in_buffer, 1232 .chars_in_buffer = capinc_tty_chars_in_buffer,
1239 .ioctl = capinc_tty_ioctl,
1240 .set_termios = capinc_tty_set_termios, 1233 .set_termios = capinc_tty_set_termios,
1241 .throttle = capinc_tty_throttle, 1234 .throttle = capinc_tty_throttle,
1242 .unthrottle = capinc_tty_unthrottle, 1235 .unthrottle = capinc_tty_unthrottle,
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 600c79b030cd..d9a578ac32cd 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -206,7 +206,7 @@ static int if_ioctl(struct tty_struct *tty,
206 ? -EFAULT : 0; 206 ? -EFAULT : 0;
207 if (retval >= 0) { 207 if (retval >= 0) {
208 gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", 208 gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS",
209 6, (const unsigned char *) arg); 209 6, buf);
210 retval = cs->ops->brkchars(cs, buf); 210 retval = cs->ops->brkchars(cs, buf);
211 } 211 }
212 break; 212 break;
@@ -233,6 +233,14 @@ static int if_ioctl(struct tty_struct *tty,
233 return retval; 233 return retval;
234} 234}
235 235
236#ifdef CONFIG_COMPAT
237static long if_compat_ioctl(struct tty_struct *tty,
238 unsigned int cmd, unsigned long arg)
239{
240 return if_ioctl(tty, cmd, (unsigned long)compat_ptr(arg));
241}
242#endif
243
236static int if_tiocmget(struct tty_struct *tty) 244static int if_tiocmget(struct tty_struct *tty)
237{ 245{
238 struct cardstate *cs = tty->driver_data; 246 struct cardstate *cs = tty->driver_data;
@@ -472,6 +480,9 @@ static const struct tty_operations if_ops = {
472 .open = if_open, 480 .open = if_open,
473 .close = if_close, 481 .close = if_close,
474 .ioctl = if_ioctl, 482 .ioctl = if_ioctl,
483#ifdef CONFIG_COMPAT
484 .compat_ioctl = if_compat_ioctl,
485#endif
475 .write = if_write, 486 .write = if_write,
476 .write_room = if_write_room, 487 .write_room = if_write_room,
477 .chars_in_buffer = if_chars_in_buffer, 488 .chars_in_buffer = if_chars_in_buffer,
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index b730037a0e2d..1b2239c1d569 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1412,31 +1412,12 @@ static int
1412isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg) 1412isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg)
1413{ 1413{
1414 modem_info *info = (modem_info *) tty->driver_data; 1414 modem_info *info = (modem_info *) tty->driver_data;
1415 int retval;
1416 1415
1417 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_ioctl")) 1416 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_ioctl"))
1418 return -ENODEV; 1417 return -ENODEV;
1419 if (tty_io_error(tty)) 1418 if (tty_io_error(tty))
1420 return -EIO; 1419 return -EIO;
1421 switch (cmd) { 1420 switch (cmd) {
1422 case TCSBRK: /* SVID version: non-zero arg --> no break */
1423#ifdef ISDN_DEBUG_MODEM_IOCTL
1424 printk(KERN_DEBUG "ttyI%d ioctl TCSBRK\n", info->line);
1425#endif
1426 retval = tty_check_change(tty);
1427 if (retval)
1428 return retval;
1429 tty_wait_until_sent(tty, 0);
1430 return 0;
1431 case TCSBRKP: /* support for POSIX tcsendbreak() */
1432#ifdef ISDN_DEBUG_MODEM_IOCTL
1433 printk(KERN_DEBUG "ttyI%d ioctl TCSBRKP\n", info->line);
1434#endif
1435 retval = tty_check_change(tty);
1436 if (retval)
1437 return retval;
1438 tty_wait_until_sent(tty, 0);
1439 return 0;
1440 case TIOCSERGETLSR: /* Get line status register */ 1421 case TIOCSERGETLSR: /* Get line status register */
1441#ifdef ISDN_DEBUG_MODEM_IOCTL 1422#ifdef ISDN_DEBUG_MODEM_IOCTL
1442 printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line); 1423 printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line);
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index d79a69dd2146..17e6dcd2eb42 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -34,7 +34,6 @@
34#include <linux/ip.h> 34#include <linux/ip.h>
35#include <linux/tcp.h> 35#include <linux/tcp.h>
36#include <linux/semaphore.h> 36#include <linux/semaphore.h>
37#include <linux/compat.h>
38#include <linux/refcount.h> 37#include <linux/refcount.h>
39 38
40#define SIXPACK_VERSION "Revision: 0.3.0" 39#define SIXPACK_VERSION "Revision: 0.3.0"
@@ -752,23 +751,6 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
752 return err; 751 return err;
753} 752}
754 753
755#ifdef CONFIG_COMPAT
756static long sixpack_compat_ioctl(struct tty_struct * tty, struct file * file,
757 unsigned int cmd, unsigned long arg)
758{
759 switch (cmd) {
760 case SIOCGIFNAME:
761 case SIOCGIFENCAP:
762 case SIOCSIFENCAP:
763 case SIOCSIFHWADDR:
764 return sixpack_ioctl(tty, file, cmd,
765 (unsigned long)compat_ptr(arg));
766 }
767
768 return -ENOIOCTLCMD;
769}
770#endif
771
772static struct tty_ldisc_ops sp_ldisc = { 754static struct tty_ldisc_ops sp_ldisc = {
773 .owner = THIS_MODULE, 755 .owner = THIS_MODULE,
774 .magic = TTY_LDISC_MAGIC, 756 .magic = TTY_LDISC_MAGIC,
@@ -776,9 +758,6 @@ static struct tty_ldisc_ops sp_ldisc = {
776 .open = sixpack_open, 758 .open = sixpack_open,
777 .close = sixpack_close, 759 .close = sixpack_close,
778 .ioctl = sixpack_ioctl, 760 .ioctl = sixpack_ioctl,
779#ifdef CONFIG_COMPAT
780 .compat_ioctl = sixpack_compat_ioctl,
781#endif
782 .receive_buf = sixpack_receive_buf, 761 .receive_buf = sixpack_receive_buf,
783 .write_wakeup = sixpack_write_wakeup, 762 .write_wakeup = sixpack_write_wakeup,
784}; 763};
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 13e4c1eff353..802233d41b25 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -35,7 +35,6 @@
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <linux/if_arp.h> 36#include <linux/if_arp.h>
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/compat.h>
39 38
40#include <net/ax25.h> 39#include <net/ax25.h>
41 40
@@ -875,23 +874,6 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
875 return err; 874 return err;
876} 875}
877 876
878#ifdef CONFIG_COMPAT
879static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file,
880 unsigned int cmd, unsigned long arg)
881{
882 switch (cmd) {
883 case SIOCGIFNAME:
884 case SIOCGIFENCAP:
885 case SIOCSIFENCAP:
886 case SIOCSIFHWADDR:
887 return mkiss_ioctl(tty, file, cmd,
888 (unsigned long)compat_ptr(arg));
889 }
890
891 return -ENOIOCTLCMD;
892}
893#endif
894
895/* 877/*
896 * Handle the 'receiver data ready' interrupt. 878 * Handle the 'receiver data ready' interrupt.
897 * This function is called by the 'tty_io' module in the kernel when 879 * This function is called by the 'tty_io' module in the kernel when
@@ -966,9 +948,6 @@ static struct tty_ldisc_ops ax_ldisc = {
966 .open = mkiss_open, 948 .open = mkiss_open,
967 .close = mkiss_close, 949 .close = mkiss_close,
968 .ioctl = mkiss_ioctl, 950 .ioctl = mkiss_ioctl,
969#ifdef CONFIG_COMPAT
970 .compat_ioctl = mkiss_compat_ioctl,
971#endif
972 .receive_buf = mkiss_receive_buf, 951 .receive_buf = mkiss_receive_buf,
973 .write_wakeup = mkiss_write_wakeup 952 .write_wakeup = mkiss_write_wakeup
974}; 953};
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index b008266e91ea..9757f1fc104f 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -79,7 +79,6 @@
79#include <linux/rtnetlink.h> 79#include <linux/rtnetlink.h>
80#include <linux/if_arp.h> 80#include <linux/if_arp.h>
81#include <linux/if_slip.h> 81#include <linux/if_slip.h>
82#include <linux/compat.h>
83#include <linux/delay.h> 82#include <linux/delay.h>
84#include <linux/init.h> 83#include <linux/init.h>
85#include <linux/slab.h> 84#include <linux/slab.h>
@@ -1167,27 +1166,6 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file,
1167 } 1166 }
1168} 1167}
1169 1168
1170#ifdef CONFIG_COMPAT
1171static long slip_compat_ioctl(struct tty_struct *tty, struct file *file,
1172 unsigned int cmd, unsigned long arg)
1173{
1174 switch (cmd) {
1175 case SIOCGIFNAME:
1176 case SIOCGIFENCAP:
1177 case SIOCSIFENCAP:
1178 case SIOCSIFHWADDR:
1179 case SIOCSKEEPALIVE:
1180 case SIOCGKEEPALIVE:
1181 case SIOCSOUTFILL:
1182 case SIOCGOUTFILL:
1183 return slip_ioctl(tty, file, cmd,
1184 (unsigned long)compat_ptr(arg));
1185 }
1186
1187 return -ENOIOCTLCMD;
1188}
1189#endif
1190
1191/* VSV changes start here */ 1169/* VSV changes start here */
1192#ifdef CONFIG_SLIP_SMART 1170#ifdef CONFIG_SLIP_SMART
1193/* function do_ioctl called from net/core/dev.c 1171/* function do_ioctl called from net/core/dev.c
@@ -1280,9 +1258,6 @@ static struct tty_ldisc_ops sl_ldisc = {
1280 .close = slip_close, 1258 .close = slip_close,
1281 .hangup = slip_hangup, 1259 .hangup = slip_hangup,
1282 .ioctl = slip_ioctl, 1260 .ioctl = slip_ioctl,
1283#ifdef CONFIG_COMPAT
1284 .compat_ioctl = slip_compat_ioctl,
1285#endif
1286 .receive_buf = slip_receive_buf, 1261 .receive_buf = slip_receive_buf,
1287 .write_wakeup = slip_write_wakeup, 1262 .write_wakeup = slip_write_wakeup,
1288}; 1263};
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 74c06a5f586f..1098263ab862 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -33,7 +33,6 @@
33#include <linux/lapb.h> 33#include <linux/lapb.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/rtnetlink.h> 35#include <linux/rtnetlink.h>
36#include <linux/compat.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include <net/x25device.h> 37#include <net/x25device.h>
39#include "x25_asy.h" 38#include "x25_asy.h"
@@ -703,21 +702,6 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file,
703 } 702 }
704} 703}
705 704
706#ifdef CONFIG_COMPAT
707static long x25_asy_compat_ioctl(struct tty_struct *tty, struct file *file,
708 unsigned int cmd, unsigned long arg)
709{
710 switch (cmd) {
711 case SIOCGIFNAME:
712 case SIOCSIFHWADDR:
713 return x25_asy_ioctl(tty, file, cmd,
714 (unsigned long)compat_ptr(arg));
715 }
716
717 return -ENOIOCTLCMD;
718}
719#endif
720
721static int x25_asy_open_dev(struct net_device *dev) 705static int x25_asy_open_dev(struct net_device *dev)
722{ 706{
723 struct x25_asy *sl = netdev_priv(dev); 707 struct x25_asy *sl = netdev_priv(dev);
@@ -769,9 +753,6 @@ static struct tty_ldisc_ops x25_ldisc = {
769 .open = x25_asy_open_tty, 753 .open = x25_asy_open_tty,
770 .close = x25_asy_close_tty, 754 .close = x25_asy_close_tty,
771 .ioctl = x25_asy_ioctl, 755 .ioctl = x25_asy_ioctl,
772#ifdef CONFIG_COMPAT
773 .compat_ioctl = x25_asy_compat_ioctl,
774#endif
775 .receive_buf = x25_asy_receive_buf, 756 .receive_buf = x25_asy_receive_buf,
776 .write_wakeup = x25_asy_write_wakeup, 757 .write_wakeup = x25_asy_write_wakeup,
777}; 758};
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index f91eaa1c3b67..b8f865018950 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -60,10 +60,6 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty);
60static void dgnc_tty_flush_chars(struct tty_struct *tty); 60static void dgnc_tty_flush_chars(struct tty_struct *tty);
61static void dgnc_tty_flush_buffer(struct tty_struct *tty); 61static void dgnc_tty_flush_buffer(struct tty_struct *tty);
62static void dgnc_tty_hangup(struct tty_struct *tty); 62static void dgnc_tty_hangup(struct tty_struct *tty);
63static int dgnc_set_modem_info(struct channel_t *ch, unsigned int command,
64 unsigned int __user *value);
65static int dgnc_get_modem_info(struct channel_t *ch,
66 unsigned int __user *value);
67static int dgnc_tty_tiocmget(struct tty_struct *tty); 63static int dgnc_tty_tiocmget(struct tty_struct *tty);
68static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, 64static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set,
69 unsigned int clear); 65 unsigned int clear);
@@ -1701,106 +1697,6 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c)
1701 spin_unlock_irqrestore(&ch->ch_lock, flags); 1697 spin_unlock_irqrestore(&ch->ch_lock, flags);
1702} 1698}
1703 1699
1704/* Return modem signals to ld. */
1705static inline int dgnc_get_mstat(struct channel_t *ch)
1706{
1707 unsigned char mstat;
1708 unsigned long flags;
1709 int rc;
1710
1711 if (!ch)
1712 return -ENXIO;
1713
1714 spin_lock_irqsave(&ch->ch_lock, flags);
1715
1716 mstat = ch->ch_mostat | ch->ch_mistat;
1717
1718 spin_unlock_irqrestore(&ch->ch_lock, flags);
1719
1720 rc = 0;
1721
1722 if (mstat & UART_MCR_DTR)
1723 rc |= TIOCM_DTR;
1724 if (mstat & UART_MCR_RTS)
1725 rc |= TIOCM_RTS;
1726 if (mstat & UART_MSR_CTS)
1727 rc |= TIOCM_CTS;
1728 if (mstat & UART_MSR_DSR)
1729 rc |= TIOCM_DSR;
1730 if (mstat & UART_MSR_RI)
1731 rc |= TIOCM_RI;
1732 if (mstat & UART_MSR_DCD)
1733 rc |= TIOCM_CD;
1734
1735 return rc;
1736}
1737
1738/* Return modem signals to ld. */
1739static int dgnc_get_modem_info(struct channel_t *ch,
1740 unsigned int __user *value)
1741{
1742 return put_user(dgnc_get_mstat(ch), value);
1743}
1744
1745/* Set modem signals, called by ld. */
1746static int dgnc_set_modem_info(struct channel_t *ch,
1747 unsigned int command,
1748 unsigned int __user *value)
1749{
1750 int rc;
1751 unsigned int arg = 0;
1752 unsigned long flags;
1753
1754 rc = get_user(arg, value);
1755 if (rc)
1756 return rc;
1757
1758 switch (command) {
1759 case TIOCMBIS:
1760 if (arg & TIOCM_RTS)
1761 ch->ch_mostat |= UART_MCR_RTS;
1762
1763 if (arg & TIOCM_DTR)
1764 ch->ch_mostat |= UART_MCR_DTR;
1765
1766 break;
1767
1768 case TIOCMBIC:
1769 if (arg & TIOCM_RTS)
1770 ch->ch_mostat &= ~(UART_MCR_RTS);
1771
1772 if (arg & TIOCM_DTR)
1773 ch->ch_mostat &= ~(UART_MCR_DTR);
1774
1775 break;
1776
1777 case TIOCMSET:
1778
1779 if (arg & TIOCM_RTS)
1780 ch->ch_mostat |= UART_MCR_RTS;
1781 else
1782 ch->ch_mostat &= ~(UART_MCR_RTS);
1783
1784 if (arg & TIOCM_DTR)
1785 ch->ch_mostat |= UART_MCR_DTR;
1786 else
1787 ch->ch_mostat &= ~(UART_MCR_DTR);
1788
1789 break;
1790
1791 default:
1792 return -EINVAL;
1793 }
1794
1795 spin_lock_irqsave(&ch->ch_lock, flags);
1796
1797 ch->ch_bd->bd_ops->assert_modem_signals(ch);
1798
1799 spin_unlock_irqrestore(&ch->ch_lock, flags);
1800
1801 return 0;
1802}
1803
1804/* Ioctl to get the information for ditty. */ 1700/* Ioctl to get the information for ditty. */
1805static int dgnc_tty_digigeta(struct tty_struct *tty, 1701static int dgnc_tty_digigeta(struct tty_struct *tty,
1806 struct digi_t __user *retinfo) 1702 struct digi_t __user *retinfo)
@@ -2184,116 +2080,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
2184 } 2080 }
2185 2081
2186 switch (cmd) { 2082 switch (cmd) {
2187 /* Here are all the standard ioctl's that we MUST implement */
2188
2189 case TCSBRK:
2190 /*
2191 * TCSBRK is SVID version: non-zero arg --> no break
2192 * this behaviour is exploited by tcdrain().
2193 *
2194 * According to POSIX.1 spec (7.2.2.1.2) breaks should be
2195 * between 0.25 and 0.5 seconds so we'll ask for something
2196 * in the middle: 0.375 seconds.
2197 */
2198 rc = tty_check_change(tty);
2199 spin_unlock_irqrestore(&ch->ch_lock, flags);
2200 if (rc)
2201 return rc;
2202
2203 rc = ch_bd_ops->drain(tty, 0);
2204 if (rc)
2205 return -EINTR;
2206
2207 spin_lock_irqsave(&ch->ch_lock, flags);
2208
2209 if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP))
2210 ch_bd_ops->send_break(ch, 250);
2211
2212 spin_unlock_irqrestore(&ch->ch_lock, flags);
2213
2214 return 0;
2215
2216 case TCSBRKP:
2217 /*
2218 * support for POSIX tcsendbreak()
2219 * According to POSIX.1 spec (7.2.2.1.2) breaks should be
2220 * between 0.25 and 0.5 seconds so we'll ask for something
2221 * in the middle: 0.375 seconds.
2222 */
2223 rc = tty_check_change(tty);
2224 spin_unlock_irqrestore(&ch->ch_lock, flags);
2225 if (rc)
2226 return rc;
2227
2228 rc = ch_bd_ops->drain(tty, 0);
2229 if (rc)
2230 return -EINTR;
2231
2232 spin_lock_irqsave(&ch->ch_lock, flags);
2233
2234 ch_bd_ops->send_break(ch, 250);
2235
2236 spin_unlock_irqrestore(&ch->ch_lock, flags);
2237
2238 return 0;
2239
2240 case TIOCSBRK:
2241 rc = tty_check_change(tty);
2242 spin_unlock_irqrestore(&ch->ch_lock, flags);
2243 if (rc)
2244 return rc;
2245
2246 rc = ch_bd_ops->drain(tty, 0);
2247 if (rc)
2248 return -EINTR;
2249
2250 spin_lock_irqsave(&ch->ch_lock, flags);
2251
2252 ch_bd_ops->send_break(ch, 250);
2253
2254 spin_unlock_irqrestore(&ch->ch_lock, flags);
2255
2256 return 0;
2257
2258 case TIOCCBRK:
2259 /* Do Nothing */
2260 spin_unlock_irqrestore(&ch->ch_lock, flags);
2261 return 0;
2262
2263 case TIOCGSOFTCAR:
2264
2265 spin_unlock_irqrestore(&ch->ch_lock, flags);
2266
2267 return put_user(C_CLOCAL(tty) ? 1 : 0,
2268 (unsigned long __user *)arg);
2269
2270 case TIOCSSOFTCAR:
2271
2272 spin_unlock_irqrestore(&ch->ch_lock, flags);
2273 rc = get_user(arg, (unsigned long __user *)arg);
2274 if (rc)
2275 return rc;
2276
2277 spin_lock_irqsave(&ch->ch_lock, flags);
2278 tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) |
2279 (arg ? CLOCAL : 0));
2280 ch_bd_ops->param(tty);
2281 spin_unlock_irqrestore(&ch->ch_lock, flags);
2282
2283 return 0;
2284
2285 case TIOCMGET:
2286 spin_unlock_irqrestore(&ch->ch_lock, flags);
2287 return dgnc_get_modem_info(ch, uarg);
2288
2289 case TIOCMBIS:
2290 case TIOCMBIC:
2291 case TIOCMSET:
2292 spin_unlock_irqrestore(&ch->ch_lock, flags);
2293 return dgnc_set_modem_info(ch, cmd, uarg);
2294
2295 /* Here are any additional ioctl's that we want to implement */ 2083 /* Here are any additional ioctl's that we want to implement */
2296
2297 case TCFLSH: 2084 case TCFLSH:
2298 /* 2085 /*
2299 * The linux tty driver doesn't have a flush 2086 * The linux tty driver doesn't have a flush
@@ -2370,11 +2157,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
2370 /* pretend we didn't recognize this */ 2157 /* pretend we didn't recognize this */
2371 return -ENOIOCTLCMD; 2158 return -ENOIOCTLCMD;
2372 2159
2373 case TCXONC:
2374 spin_unlock_irqrestore(&ch->ch_lock, flags);
2375 /* Make the ld do it */
2376 return -ENOIOCTLCMD;
2377
2378 case DIGI_GETA: 2160 case DIGI_GETA:
2379 /* get information for ditty */ 2161 /* get information for ditty */
2380 spin_unlock_irqrestore(&ch->ch_lock, flags); 2162 spin_unlock_irqrestore(&ch->ch_lock, flags);
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index fa0dd425b454..173f451b86b7 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -1209,42 +1209,40 @@ static int wait_msr_change(struct fwtty_port *port, unsigned long mask)
1209 check_msr_delta(port, mask, &prev)); 1209 check_msr_delta(port, mask, &prev));
1210} 1210}
1211 1211
1212static int get_serial_info(struct fwtty_port *port, 1212static int get_serial_info(struct tty_struct *tty,
1213 struct serial_struct __user *info) 1213 struct serial_struct *ss)
1214{ 1214{
1215 struct serial_struct tmp; 1215 struct fwtty_port *port = tty->driver_data;
1216 1216 mutex_lock(&port->port.mutex);
1217 memset(&tmp, 0, sizeof(tmp)); 1217 ss->type = PORT_UNKNOWN;
1218 1218 ss->line = port->port.tty->index;
1219 tmp.type = PORT_UNKNOWN; 1219 ss->flags = port->port.flags;
1220 tmp.line = port->port.tty->index; 1220 ss->xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
1221 tmp.flags = port->port.flags; 1221 ss->baud_base = 400000000;
1222 tmp.xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN; 1222 ss->close_delay = port->port.close_delay;
1223 tmp.baud_base = 400000000; 1223 mutex_unlock(&port->port.mutex);
1224 tmp.close_delay = port->port.close_delay; 1224 return 0;
1225
1226 return (copy_to_user(info, &tmp, sizeof(*info))) ? -EFAULT : 0;
1227} 1225}
1228 1226
1229static int set_serial_info(struct fwtty_port *port, 1227static int set_serial_info(struct tty_struct *tty,
1230 struct serial_struct __user *info) 1228 struct serial_struct *ss)
1231{ 1229{
1232 struct serial_struct tmp; 1230 struct fwtty_port *port = tty->driver_data;
1233
1234 if (copy_from_user(&tmp, info, sizeof(tmp)))
1235 return -EFAULT;
1236 1231
1237 if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 || 1232 if (ss->irq != 0 || ss->port != 0 || ss->custom_divisor != 0 ||
1238 tmp.baud_base != 400000000) 1233 ss->baud_base != 400000000)
1239 return -EPERM; 1234 return -EPERM;
1240 1235
1236 mutex_lock(&port->port.mutex);
1241 if (!capable(CAP_SYS_ADMIN)) { 1237 if (!capable(CAP_SYS_ADMIN)) {
1242 if (((tmp.flags & ~ASYNC_USR_MASK) != 1238 if (((ss->flags & ~ASYNC_USR_MASK) !=
1243 (port->port.flags & ~ASYNC_USR_MASK))) 1239 (port->port.flags & ~ASYNC_USR_MASK))) {
1240 mutex_unlock(&port->port.mutex);
1244 return -EPERM; 1241 return -EPERM;
1245 } else { 1242 }
1246 port->port.close_delay = tmp.close_delay * HZ / 100;
1247 } 1243 }
1244 port->port.close_delay = ss->close_delay * HZ / 100;
1245 mutex_unlock(&port->port.mutex);
1248 1246
1249 return 0; 1247 return 0;
1250} 1248}
@@ -1256,18 +1254,6 @@ static int fwtty_ioctl(struct tty_struct *tty, unsigned int cmd,
1256 int err; 1254 int err;
1257 1255
1258 switch (cmd) { 1256 switch (cmd) {
1259 case TIOCGSERIAL:
1260 mutex_lock(&port->port.mutex);
1261 err = get_serial_info(port, (void __user *)arg);
1262 mutex_unlock(&port->port.mutex);
1263 break;
1264
1265 case TIOCSSERIAL:
1266 mutex_lock(&port->port.mutex);
1267 err = set_serial_info(port, (void __user *)arg);
1268 mutex_unlock(&port->port.mutex);
1269 break;
1270
1271 case TIOCMIWAIT: 1257 case TIOCMIWAIT:
1272 err = wait_msr_change(port, arg); 1258 err = wait_msr_change(port, arg);
1273 break; 1259 break;
@@ -1557,6 +1543,8 @@ static const struct tty_operations fwtty_ops = {
1557 .tiocmget = fwtty_tiocmget, 1543 .tiocmget = fwtty_tiocmget,
1558 .tiocmset = fwtty_tiocmset, 1544 .tiocmset = fwtty_tiocmset,
1559 .get_icount = fwtty_get_icount, 1545 .get_icount = fwtty_get_icount,
1546 .set_serial = set_serial_info,
1547 .get_serial = get_serial_info,
1560 .proc_show = fwtty_proc_show, 1548 .proc_show = fwtty_proc_show,
1561}; 1549};
1562 1550
@@ -1578,6 +1566,8 @@ static const struct tty_operations fwloop_ops = {
1578 .tiocmget = fwtty_tiocmget, 1566 .tiocmget = fwtty_tiocmget,
1579 .tiocmset = fwtty_tiocmset, 1567 .tiocmset = fwtty_tiocmset,
1580 .get_icount = fwtty_get_icount, 1568 .get_icount = fwtty_get_icount,
1569 .set_serial = set_serial_info,
1570 .get_serial = get_serial_info,
1581}; 1571};
1582 1572
1583static inline int mgmt_pkt_expected_len(__be16 code) 1573static inline int mgmt_pkt_expected_len(__be16 code)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 8a006323c3c1..3313cb0b60af 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -616,40 +616,33 @@ static void gb_tty_unthrottle(struct tty_struct *tty)
616 } 616 }
617} 617}
618 618
619static int get_serial_info(struct gb_tty *gb_tty, 619static int get_serial_info(struct tty_struct *tty,
620 struct serial_struct __user *info) 620 struct serial_struct *ss)
621{ 621{
622 struct serial_struct tmp; 622 struct gb_tty *gb_tty = tty->driver_data;
623 623
624 memset(&tmp, 0, sizeof(tmp)); 624 ss->type = PORT_16550A;
625 tmp.type = PORT_16550A; 625 ss->line = gb_tty->minor;
626 tmp.line = gb_tty->minor; 626 ss->xmit_fifo_size = 16;
627 tmp.xmit_fifo_size = 16; 627 ss->baud_base = 9600;
628 tmp.baud_base = 9600; 628 ss->close_delay = gb_tty->port.close_delay / 10;
629 tmp.close_delay = gb_tty->port.close_delay / 10; 629 ss->closing_wait =
630 tmp.closing_wait =
631 gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? 630 gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
632 ASYNC_CLOSING_WAIT_NONE : gb_tty->port.closing_wait / 10; 631 ASYNC_CLOSING_WAIT_NONE : gb_tty->port.closing_wait / 10;
633
634 if (copy_to_user(info, &tmp, sizeof(tmp)))
635 return -EFAULT;
636 return 0; 632 return 0;
637} 633}
638 634
639static int set_serial_info(struct gb_tty *gb_tty, 635static int set_serial_info(struct tty_struct *tty,
640 struct serial_struct __user *newinfo) 636 struct serial_struct *ss)
641{ 637{
642 struct serial_struct new_serial; 638 struct gb_tty *gb_tty = tty->driver_data;
643 unsigned int closing_wait; 639 unsigned int closing_wait;
644 unsigned int close_delay; 640 unsigned int close_delay;
645 int retval = 0; 641 int retval = 0;
646 642
647 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 643 close_delay = ss->close_delay * 10;
648 return -EFAULT; 644 closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ?
649 645 ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10;
650 close_delay = new_serial.close_delay * 10;
651 closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
652 ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
653 646
654 mutex_lock(&gb_tty->port.mutex); 647 mutex_lock(&gb_tty->port.mutex);
655 if (!capable(CAP_SYS_ADMIN)) { 648 if (!capable(CAP_SYS_ADMIN)) {
@@ -728,12 +721,6 @@ static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
728 struct gb_tty *gb_tty = tty->driver_data; 721 struct gb_tty *gb_tty = tty->driver_data;
729 722
730 switch (cmd) { 723 switch (cmd) {
731 case TIOCGSERIAL:
732 return get_serial_info(gb_tty,
733 (struct serial_struct __user *)arg);
734 case TIOCSSERIAL:
735 return set_serial_info(gb_tty,
736 (struct serial_struct __user *)arg);
737 case TIOCMIWAIT: 724 case TIOCMIWAIT:
738 return wait_serial_change(gb_tty, arg); 725 return wait_serial_change(gb_tty, arg);
739 } 726 }
@@ -818,6 +805,8 @@ static const struct tty_operations gb_ops = {
818 .tiocmget = gb_tty_tiocmget, 805 .tiocmget = gb_tty_tiocmget,
819 .tiocmset = gb_tty_tiocmset, 806 .tiocmset = gb_tty_tiocmset,
820 .get_icount = gb_tty_get_icount, 807 .get_icount = gb_tty_get_icount,
808 .set_serial = set_serial_info,
809 .get_serial = get_serial_info,
821}; 810};
822 811
823static const struct tty_port_operations gb_port_ops = { 812static const struct tty_port_operations gb_port_ops = {
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 34dead614149..8330fd809a05 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -996,63 +996,55 @@ static void rs_unthrottle(struct tty_struct * tty)
996 * ------------------------------------------------------------ 996 * ------------------------------------------------------------
997 */ 997 */
998 998
999static int get_serial_info(struct tty_struct *tty, struct serial_state *state, 999static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
1000 struct serial_struct __user * retinfo)
1001{ 1000{
1002 struct serial_struct tmp; 1001 struct serial_state *state = tty->driver_data;
1003 1002
1004 memset(&tmp, 0, sizeof(tmp));
1005 tty_lock(tty); 1003 tty_lock(tty);
1006 tmp.line = tty->index; 1004 ss->line = tty->index;
1007 tmp.port = state->port; 1005 ss->port = state->port;
1008 tmp.flags = state->tport.flags; 1006 ss->flags = state->tport.flags;
1009 tmp.xmit_fifo_size = state->xmit_fifo_size; 1007 ss->xmit_fifo_size = state->xmit_fifo_size;
1010 tmp.baud_base = state->baud_base; 1008 ss->baud_base = state->baud_base;
1011 tmp.close_delay = state->tport.close_delay; 1009 ss->close_delay = state->tport.close_delay;
1012 tmp.closing_wait = state->tport.closing_wait; 1010 ss->closing_wait = state->tport.closing_wait;
1013 tmp.custom_divisor = state->custom_divisor; 1011 ss->custom_divisor = state->custom_divisor;
1014 tty_unlock(tty); 1012 tty_unlock(tty);
1015 if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
1016 return -EFAULT;
1017 return 0; 1013 return 0;
1018} 1014}
1019 1015
1020static int set_serial_info(struct tty_struct *tty, struct serial_state *state, 1016static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
1021 struct serial_struct __user * new_info)
1022{ 1017{
1018 struct serial_state *state = tty->driver_data;
1023 struct tty_port *port = &state->tport; 1019 struct tty_port *port = &state->tport;
1024 struct serial_struct new_serial;
1025 bool change_spd; 1020 bool change_spd;
1026 int retval = 0; 1021 int retval = 0;
1027 1022
1028 if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
1029 return -EFAULT;
1030
1031 tty_lock(tty); 1023 tty_lock(tty);
1032 change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) || 1024 change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) ||
1033 new_serial.custom_divisor != state->custom_divisor; 1025 ss->custom_divisor != state->custom_divisor;
1034 if (new_serial.irq || new_serial.port != state->port || 1026 if (ss->irq || ss->port != state->port ||
1035 new_serial.xmit_fifo_size != state->xmit_fifo_size) { 1027 ss->xmit_fifo_size != state->xmit_fifo_size) {
1036 tty_unlock(tty); 1028 tty_unlock(tty);
1037 return -EINVAL; 1029 return -EINVAL;
1038 } 1030 }
1039 1031
1040 if (!serial_isroot()) { 1032 if (!serial_isroot()) {
1041 if ((new_serial.baud_base != state->baud_base) || 1033 if ((ss->baud_base != state->baud_base) ||
1042 (new_serial.close_delay != port->close_delay) || 1034 (ss->close_delay != port->close_delay) ||
1043 (new_serial.xmit_fifo_size != state->xmit_fifo_size) || 1035 (ss->xmit_fifo_size != state->xmit_fifo_size) ||
1044 ((new_serial.flags & ~ASYNC_USR_MASK) != 1036 ((ss->flags & ~ASYNC_USR_MASK) !=
1045 (port->flags & ~ASYNC_USR_MASK))) { 1037 (port->flags & ~ASYNC_USR_MASK))) {
1046 tty_unlock(tty); 1038 tty_unlock(tty);
1047 return -EPERM; 1039 return -EPERM;
1048 } 1040 }
1049 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1041 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1050 (new_serial.flags & ASYNC_USR_MASK)); 1042 (ss->flags & ASYNC_USR_MASK));
1051 state->custom_divisor = new_serial.custom_divisor; 1043 state->custom_divisor = ss->custom_divisor;
1052 goto check_and_exit; 1044 goto check_and_exit;
1053 } 1045 }
1054 1046
1055 if (new_serial.baud_base < 9600) { 1047 if (ss->baud_base < 9600) {
1056 tty_unlock(tty); 1048 tty_unlock(tty);
1057 return -EINVAL; 1049 return -EINVAL;
1058 } 1050 }
@@ -1062,19 +1054,19 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
1062 * At this point, we start making changes..... 1054 * At this point, we start making changes.....
1063 */ 1055 */
1064 1056
1065 state->baud_base = new_serial.baud_base; 1057 state->baud_base = ss->baud_base;
1066 port->flags = ((port->flags & ~ASYNC_FLAGS) | 1058 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1067 (new_serial.flags & ASYNC_FLAGS)); 1059 (ss->flags & ASYNC_FLAGS));
1068 state->custom_divisor = new_serial.custom_divisor; 1060 state->custom_divisor = ss->custom_divisor;
1069 port->close_delay = new_serial.close_delay * HZ/100; 1061 port->close_delay = ss->close_delay * HZ/100;
1070 port->closing_wait = new_serial.closing_wait * HZ/100; 1062 port->closing_wait = ss->closing_wait * HZ/100;
1071 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1063 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1072 1064
1073check_and_exit: 1065check_and_exit:
1074 if (tty_port_initialized(port)) { 1066 if (tty_port_initialized(port)) {
1075 if (change_spd) { 1067 if (change_spd) {
1076 /* warn about deprecation unless clearing */ 1068 /* warn about deprecation unless clearing */
1077 if (new_serial.flags & ASYNC_SPD_MASK) 1069 if (ss->flags & ASYNC_SPD_MASK)
1078 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); 1070 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n");
1079 change_speed(tty, state, NULL); 1071 change_speed(tty, state, NULL);
1080 } 1072 }
@@ -1084,7 +1076,6 @@ check_and_exit:
1084 return retval; 1076 return retval;
1085} 1077}
1086 1078
1087
1088/* 1079/*
1089 * get_lsr_info - get line status register info 1080 * get_lsr_info - get line status register info
1090 * 1081 *
@@ -1224,30 +1215,19 @@ static int rs_ioctl(struct tty_struct *tty,
1224 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) 1215 if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
1225 return -ENODEV; 1216 return -ENODEV;
1226 1217
1227 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1218 if ((cmd != TIOCSERCONFIG) &&
1228 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
1229 (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 1219 (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
1230 if (tty_io_error(tty)) 1220 if (tty_io_error(tty))
1231 return -EIO; 1221 return -EIO;
1232 } 1222 }
1233 1223
1234 switch (cmd) { 1224 switch (cmd) {
1235 case TIOCGSERIAL:
1236 return get_serial_info(tty, info, argp);
1237 case TIOCSSERIAL:
1238 return set_serial_info(tty, info, argp);
1239 case TIOCSERCONFIG: 1225 case TIOCSERCONFIG:
1240 return 0; 1226 return 0;
1241 1227
1242 case TIOCSERGETLSR: /* Get line status register */ 1228 case TIOCSERGETLSR: /* Get line status register */
1243 return get_lsr_info(info, argp); 1229 return get_lsr_info(info, argp);
1244 1230
1245 case TIOCSERGSTRUCT:
1246 if (copy_to_user(argp,
1247 info, sizeof(struct serial_state)))
1248 return -EFAULT;
1249 return 0;
1250
1251 /* 1231 /*
1252 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 1232 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
1253 * - mask passed in arg for lines of interest 1233 * - mask passed in arg for lines of interest
@@ -1288,12 +1268,6 @@ static int rs_ioctl(struct tty_struct *tty,
1288 finish_wait(&info->tport.delta_msr_wait, &wait); 1268 finish_wait(&info->tport.delta_msr_wait, &wait);
1289 return ret; 1269 return ret;
1290 1270
1291 case TIOCSERGWILD:
1292 case TIOCSERSWILD:
1293 /* "setserial -W" is called in Debian boot */
1294 printk ("TIOCSER?WILD ioctl obsolete, ignored.\n");
1295 return 0;
1296
1297 default: 1271 default:
1298 return -ENOIOCTLCMD; 1272 return -ENOIOCTLCMD;
1299 } 1273 }
@@ -1607,6 +1581,8 @@ static const struct tty_operations serial_ops = {
1607 .tiocmget = rs_tiocmget, 1581 .tiocmget = rs_tiocmget,
1608 .tiocmset = rs_tiocmset, 1582 .tiocmset = rs_tiocmset,
1609 .get_icount = rs_get_icount, 1583 .get_icount = rs_get_icount,
1584 .set_serial = set_serial_info,
1585 .get_serial = get_serial_info,
1610 .proc_show = rs_proc_show, 1586 .proc_show = rs_proc_show,
1611}; 1587};
1612 1588
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 6d3c58051ce3..4562c8060d09 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -2257,44 +2257,45 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
2257 } 2257 }
2258} /* set_line_char */ 2258} /* set_line_char */
2259 2259
2260static int cy_get_serial_info(struct cyclades_port *info, 2260static int cy_get_serial_info(struct tty_struct *tty,
2261 struct serial_struct __user *retinfo) 2261 struct serial_struct *ss)
2262{ 2262{
2263 struct cyclades_port *info = tty->driver_data;
2263 struct cyclades_card *cinfo = info->card; 2264 struct cyclades_card *cinfo = info->card;
2264 struct serial_struct tmp = { 2265
2265 .type = info->type, 2266 if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
2266 .line = info->line, 2267 return -ENODEV;
2267 .port = (info->card - cy_card) * 0x100 + info->line - 2268 ss->type = info->type;
2268 cinfo->first_line, 2269 ss->line = info->line;
2269 .irq = cinfo->irq, 2270 ss->port = (info->card - cy_card) * 0x100 + info->line -
2270 .flags = info->port.flags, 2271 cinfo->first_line;
2271 .close_delay = info->port.close_delay, 2272 ss->irq = cinfo->irq;
2272 .closing_wait = info->port.closing_wait, 2273 ss->flags = info->port.flags;
2273 .baud_base = info->baud, 2274 ss->close_delay = info->port.close_delay;
2274 .custom_divisor = info->custom_divisor, 2275 ss->closing_wait = info->port.closing_wait;
2275 }; 2276 ss->baud_base = info->baud;
2276 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 2277 ss->custom_divisor = info->custom_divisor;
2278 return 0;
2277} 2279}
2278 2280
2279static int 2281static int cy_set_serial_info(struct tty_struct *tty,
2280cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty, 2282 struct serial_struct *ss)
2281 struct serial_struct __user *new_info)
2282{ 2283{
2283 struct serial_struct new_serial; 2284 struct cyclades_port *info = tty->driver_data;
2284 int old_flags; 2285 int old_flags;
2285 int ret; 2286 int ret;
2286 2287
2287 if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2288 if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
2288 return -EFAULT; 2289 return -ENODEV;
2289 2290
2290 mutex_lock(&info->port.mutex); 2291 mutex_lock(&info->port.mutex);
2291 2292
2292 old_flags = info->port.flags; 2293 old_flags = info->port.flags;
2293 2294
2294 if (!capable(CAP_SYS_ADMIN)) { 2295 if (!capable(CAP_SYS_ADMIN)) {
2295 if (new_serial.close_delay != info->port.close_delay || 2296 if (ss->close_delay != info->port.close_delay ||
2296 new_serial.baud_base != info->baud || 2297 ss->baud_base != info->baud ||
2297 (new_serial.flags & ASYNC_FLAGS & 2298 (ss->flags & ASYNC_FLAGS &
2298 ~ASYNC_USR_MASK) != 2299 ~ASYNC_USR_MASK) !=
2299 (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) 2300 (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
2300 { 2301 {
@@ -2302,9 +2303,9 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
2302 return -EPERM; 2303 return -EPERM;
2303 } 2304 }
2304 info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) | 2305 info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
2305 (new_serial.flags & ASYNC_USR_MASK); 2306 (ss->flags & ASYNC_USR_MASK);
2306 info->baud = new_serial.baud_base; 2307 info->baud = ss->baud_base;
2307 info->custom_divisor = new_serial.custom_divisor; 2308 info->custom_divisor = ss->custom_divisor;
2308 goto check_and_exit; 2309 goto check_and_exit;
2309 } 2310 }
2310 2311
@@ -2313,18 +2314,18 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
2313 * At this point, we start making changes..... 2314 * At this point, we start making changes.....
2314 */ 2315 */
2315 2316
2316 info->baud = new_serial.baud_base; 2317 info->baud = ss->baud_base;
2317 info->custom_divisor = new_serial.custom_divisor; 2318 info->custom_divisor = ss->custom_divisor;
2318 info->port.flags = (info->port.flags & ~ASYNC_FLAGS) | 2319 info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
2319 (new_serial.flags & ASYNC_FLAGS); 2320 (ss->flags & ASYNC_FLAGS);
2320 info->port.close_delay = new_serial.close_delay * HZ / 100; 2321 info->port.close_delay = ss->close_delay * HZ / 100;
2321 info->port.closing_wait = new_serial.closing_wait * HZ / 100; 2322 info->port.closing_wait = ss->closing_wait * HZ / 100;
2322 2323
2323check_and_exit: 2324check_and_exit:
2324 if (tty_port_initialized(&info->port)) { 2325 if (tty_port_initialized(&info->port)) {
2325 if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) { 2326 if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) {
2326 /* warn about deprecation unless clearing */ 2327 /* warn about deprecation unless clearing */
2327 if (new_serial.flags & ASYNC_SPD_MASK) 2328 if (ss->flags & ASYNC_SPD_MASK)
2328 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); 2329 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n");
2329 } 2330 }
2330 cy_set_line_char(info, tty); 2331 cy_set_line_char(info, tty);
@@ -2698,12 +2699,6 @@ cy_ioctl(struct tty_struct *tty,
2698 case CYGETWAIT: 2699 case CYGETWAIT:
2699 ret_val = info->port.closing_wait / (HZ / 100); 2700 ret_val = info->port.closing_wait / (HZ / 100);
2700 break; 2701 break;
2701 case TIOCGSERIAL:
2702 ret_val = cy_get_serial_info(info, argp);
2703 break;
2704 case TIOCSSERIAL:
2705 ret_val = cy_set_serial_info(info, tty, argp);
2706 break;
2707 case TIOCSERGETLSR: /* Get line status register */ 2702 case TIOCSERGETLSR: /* Get line status register */
2708 ret_val = get_lsr_info(info, argp); 2703 ret_val = get_lsr_info(info, argp);
2709 break; 2704 break;
@@ -4011,6 +4006,8 @@ static const struct tty_operations cy_ops = {
4011 .tiocmget = cy_tiocmget, 4006 .tiocmget = cy_tiocmget,
4012 .tiocmset = cy_tiocmset, 4007 .tiocmset = cy_tiocmset,
4013 .get_icount = cy_get_icount, 4008 .get_icount = cy_get_icount,
4009 .set_serial = cy_set_serial_info,
4010 .get_serial = cy_get_serial_info,
4014 .proc_show = cyclades_proc_show, 4011 .proc_show = cyclades_proc_show,
4015}; 4012};
4016 4013
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index 1ef751c27ac6..fad3401e604d 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -248,22 +248,29 @@ static int ipw_write_room(struct tty_struct *linux_tty)
248 return room; 248 return room;
249} 249}
250 250
251static int ipwireless_get_serial_info(struct ipw_tty *tty, 251static int ipwireless_get_serial_info(struct tty_struct *linux_tty,
252 struct serial_struct __user *retinfo) 252 struct serial_struct *ss)
253{ 253{
254 struct serial_struct tmp; 254 struct ipw_tty *tty = linux_tty->driver_data;
255 255
256 memset(&tmp, 0, sizeof(tmp)); 256 if (!tty)
257 tmp.type = PORT_UNKNOWN; 257 return -ENODEV;
258 tmp.line = tty->index;
259 tmp.baud_base = 115200;
260 258
261 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 259 if (!tty->port.count)
262 return -EFAULT; 260 return -EINVAL;
263 261
262 ss->type = PORT_UNKNOWN;
263 ss->line = tty->index;
264 ss->baud_base = 115200;
264 return 0; 265 return 0;
265} 266}
266 267
268static int ipwireless_set_serial_info(struct tty_struct *linux_tty,
269 struct serial_struct *ss)
270{
271 return 0; /* Keeps the PCMCIA scripts happy. */
272}
273
267static int ipw_chars_in_buffer(struct tty_struct *linux_tty) 274static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
268{ 275{
269 struct ipw_tty *tty = linux_tty->driver_data; 276 struct ipw_tty *tty = linux_tty->driver_data;
@@ -386,15 +393,6 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
386 return -EINVAL; 393 return -EINVAL;
387 394
388 /* FIXME: Exactly how is the tty object locked here .. */ 395 /* FIXME: Exactly how is the tty object locked here .. */
389
390 switch (cmd) {
391 case TIOCGSERIAL:
392 return ipwireless_get_serial_info(tty, (void __user *) arg);
393
394 case TIOCSSERIAL:
395 return 0; /* Keeps the PCMCIA scripts happy. */
396 }
397
398 if (tty->tty_type == TTYTYPE_MODEM) { 396 if (tty->tty_type == TTYTYPE_MODEM) {
399 switch (cmd) { 397 switch (cmd) {
400 case PPPIOCGCHAN: 398 case PPPIOCGCHAN:
@@ -561,6 +559,8 @@ static const struct tty_operations tty_ops = {
561 .chars_in_buffer = ipw_chars_in_buffer, 559 .chars_in_buffer = ipw_chars_in_buffer,
562 .tiocmget = ipw_tiocmget, 560 .tiocmget = ipw_tiocmget,
563 .tiocmset = ipw_tiocmset, 561 .tiocmset = ipw_tiocmset,
562 .set_serial = ipwireless_set_serial_info,
563 .get_serial = ipwireless_get_serial_info,
564}; 564};
565 565
566int ipwireless_tty_init(void) 566int ipwireless_tty_init(void)
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index 8d96e86966f1..e04a43e89f6b 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -1091,34 +1091,33 @@ static int isicom_tiocmset(struct tty_struct *tty,
1091} 1091}
1092 1092
1093static int isicom_set_serial_info(struct tty_struct *tty, 1093static int isicom_set_serial_info(struct tty_struct *tty,
1094 struct serial_struct __user *info) 1094 struct serial_struct *ss)
1095{ 1095{
1096 struct isi_port *port = tty->driver_data; 1096 struct isi_port *port = tty->driver_data;
1097 struct serial_struct newinfo;
1098 int reconfig_port; 1097 int reconfig_port;
1099 1098
1100 if (copy_from_user(&newinfo, info, sizeof(newinfo))) 1099 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl"))
1101 return -EFAULT; 1100 return -ENODEV;
1102 1101
1103 mutex_lock(&port->port.mutex); 1102 mutex_lock(&port->port.mutex);
1104 reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) != 1103 reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) !=
1105 (newinfo.flags & ASYNC_SPD_MASK)); 1104 (ss->flags & ASYNC_SPD_MASK));
1106 1105
1107 if (!capable(CAP_SYS_ADMIN)) { 1106 if (!capable(CAP_SYS_ADMIN)) {
1108 if ((newinfo.close_delay != port->port.close_delay) || 1107 if ((ss->close_delay != port->port.close_delay) ||
1109 (newinfo.closing_wait != port->port.closing_wait) || 1108 (ss->closing_wait != port->port.closing_wait) ||
1110 ((newinfo.flags & ~ASYNC_USR_MASK) != 1109 ((ss->flags & ~ASYNC_USR_MASK) !=
1111 (port->port.flags & ~ASYNC_USR_MASK))) { 1110 (port->port.flags & ~ASYNC_USR_MASK))) {
1112 mutex_unlock(&port->port.mutex); 1111 mutex_unlock(&port->port.mutex);
1113 return -EPERM; 1112 return -EPERM;
1114 } 1113 }
1115 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | 1114 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
1116 (newinfo.flags & ASYNC_USR_MASK)); 1115 (ss->flags & ASYNC_USR_MASK));
1117 } else { 1116 } else {
1118 port->port.close_delay = newinfo.close_delay; 1117 port->port.close_delay = ss->close_delay;
1119 port->port.closing_wait = newinfo.closing_wait; 1118 port->port.closing_wait = ss->closing_wait;
1120 port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) | 1119 port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
1121 (newinfo.flags & ASYNC_FLAGS)); 1120 (ss->flags & ASYNC_FLAGS));
1122 } 1121 }
1123 if (reconfig_port) { 1122 if (reconfig_port) {
1124 unsigned long flags; 1123 unsigned long flags;
@@ -1130,46 +1129,24 @@ static int isicom_set_serial_info(struct tty_struct *tty,
1130 return 0; 1129 return 0;
1131} 1130}
1132 1131
1133static int isicom_get_serial_info(struct isi_port *port, 1132static int isicom_get_serial_info(struct tty_struct *tty,
1134 struct serial_struct __user *info) 1133 struct serial_struct *ss)
1135{
1136 struct serial_struct out_info;
1137
1138 mutex_lock(&port->port.mutex);
1139 memset(&out_info, 0, sizeof(out_info));
1140/* out_info.type = ? */
1141 out_info.line = port - isi_ports;
1142 out_info.port = port->card->base;
1143 out_info.irq = port->card->irq;
1144 out_info.flags = port->port.flags;
1145/* out_info.baud_base = ? */
1146 out_info.close_delay = port->port.close_delay;
1147 out_info.closing_wait = port->port.closing_wait;
1148 mutex_unlock(&port->port.mutex);
1149 if (copy_to_user(info, &out_info, sizeof(out_info)))
1150 return -EFAULT;
1151 return 0;
1152}
1153
1154static int isicom_ioctl(struct tty_struct *tty,
1155 unsigned int cmd, unsigned long arg)
1156{ 1134{
1157 struct isi_port *port = tty->driver_data; 1135 struct isi_port *port = tty->driver_data;
1158 void __user *argp = (void __user *)arg;
1159 1136
1160 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) 1137 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl"))
1161 return -ENODEV; 1138 return -ENODEV;
1162 1139
1163 switch (cmd) { 1140 mutex_lock(&port->port.mutex);
1164 case TIOCGSERIAL: 1141/* ss->type = ? */
1165 return isicom_get_serial_info(port, argp); 1142 ss->line = port - isi_ports;
1166 1143 ss->port = port->card->base;
1167 case TIOCSSERIAL: 1144 ss->irq = port->card->irq;
1168 return isicom_set_serial_info(tty, argp); 1145 ss->flags = port->port.flags;
1169 1146/* ss->baud_base = ? */
1170 default: 1147 ss->close_delay = port->port.close_delay;
1171 return -ENOIOCTLCMD; 1148 ss->closing_wait = port->port.closing_wait;
1172 } 1149 mutex_unlock(&port->port.mutex);
1173 return 0; 1150 return 0;
1174} 1151}
1175 1152
@@ -1273,7 +1250,6 @@ static const struct tty_operations isicom_ops = {
1273 .flush_chars = isicom_flush_chars, 1250 .flush_chars = isicom_flush_chars,
1274 .write_room = isicom_write_room, 1251 .write_room = isicom_write_room,
1275 .chars_in_buffer = isicom_chars_in_buffer, 1252 .chars_in_buffer = isicom_chars_in_buffer,
1276 .ioctl = isicom_ioctl,
1277 .set_termios = isicom_set_termios, 1253 .set_termios = isicom_set_termios,
1278 .throttle = isicom_throttle, 1254 .throttle = isicom_throttle,
1279 .unthrottle = isicom_unthrottle, 1255 .unthrottle = isicom_unthrottle,
@@ -1284,6 +1260,8 @@ static const struct tty_operations isicom_ops = {
1284 .tiocmget = isicom_tiocmget, 1260 .tiocmget = isicom_tiocmget,
1285 .tiocmset = isicom_tiocmset, 1261 .tiocmset = isicom_tiocmset,
1286 .break_ctl = isicom_send_break, 1262 .break_ctl = isicom_send_break,
1263 .get_serial = isicom_get_serial_info,
1264 .set_serial = isicom_set_serial_info,
1287}; 1265};
1288 1266
1289static const struct tty_port_operations isicom_port_ops = { 1267static const struct tty_port_operations isicom_port_ops = {
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 250a19f042d7..3a1a5e0ee93f 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -221,8 +221,8 @@ static int MoxaPortRxQueue(struct moxa_port *);
221static int MoxaPortTxFree(struct moxa_port *); 221static int MoxaPortTxFree(struct moxa_port *);
222static void MoxaPortTxDisable(struct moxa_port *); 222static void MoxaPortTxDisable(struct moxa_port *);
223static void MoxaPortTxEnable(struct moxa_port *); 223static void MoxaPortTxEnable(struct moxa_port *);
224static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *); 224static int moxa_get_serial_info(struct tty_struct *, struct serial_struct *);
225static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *); 225static int moxa_set_serial_info(struct tty_struct *, struct serial_struct *);
226static void MoxaSetFifo(struct moxa_port *port, int enable); 226static void MoxaSetFifo(struct moxa_port *port, int enable);
227 227
228/* 228/*
@@ -375,16 +375,6 @@ copy:
375 } 375 }
376 break; 376 break;
377 } 377 }
378 case TIOCGSERIAL:
379 mutex_lock(&ch->port.mutex);
380 ret = moxa_get_serial_info(ch, argp);
381 mutex_unlock(&ch->port.mutex);
382 break;
383 case TIOCSSERIAL:
384 mutex_lock(&ch->port.mutex);
385 ret = moxa_set_serial_info(ch, argp);
386 mutex_unlock(&ch->port.mutex);
387 break;
388 default: 378 default:
389 ret = -ENOIOCTLCMD; 379 ret = -ENOIOCTLCMD;
390 } 380 }
@@ -415,6 +405,8 @@ static const struct tty_operations moxa_ops = {
415 .break_ctl = moxa_break_ctl, 405 .break_ctl = moxa_break_ctl,
416 .tiocmget = moxa_tiocmget, 406 .tiocmget = moxa_tiocmget,
417 .tiocmset = moxa_tiocmset, 407 .tiocmset = moxa_tiocmset,
408 .set_serial = moxa_set_serial_info,
409 .get_serial = moxa_get_serial_info,
418}; 410};
419 411
420static const struct tty_port_operations moxa_port_ops = { 412static const struct tty_port_operations moxa_port_ops = {
@@ -2034,46 +2026,55 @@ static void MoxaPortTxEnable(struct moxa_port *port)
2034 moxafunc(port->tableAddr, FC_SetXonState, Magic_code); 2026 moxafunc(port->tableAddr, FC_SetXonState, Magic_code);
2035} 2027}
2036 2028
2037static int moxa_get_serial_info(struct moxa_port *info, 2029static int moxa_get_serial_info(struct tty_struct *tty,
2038 struct serial_struct __user *retinfo) 2030 struct serial_struct *ss)
2039{ 2031{
2040 struct serial_struct tmp = { 2032 struct moxa_port *info = tty->driver_data;
2041 .type = info->type, 2033
2042 .line = info->port.tty->index, 2034 if (tty->index == MAX_PORTS)
2043 .flags = info->port.flags, 2035 return -EINVAL;
2044 .baud_base = 921600, 2036 if (!info)
2045 .close_delay = info->port.close_delay 2037 return -ENODEV;
2046 }; 2038 mutex_lock(&info->port.mutex);
2047 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 2039 ss->type = info->type,
2040 ss->line = info->port.tty->index,
2041 ss->flags = info->port.flags,
2042 ss->baud_base = 921600,
2043 ss->close_delay = info->port.close_delay;
2044 mutex_unlock(&info->port.mutex);
2045 return 0;
2048} 2046}
2049 2047
2050 2048
2051static int moxa_set_serial_info(struct moxa_port *info, 2049static int moxa_set_serial_info(struct tty_struct *tty,
2052 struct serial_struct __user *new_info) 2050 struct serial_struct *ss)
2053{ 2051{
2054 struct serial_struct new_serial; 2052 struct moxa_port *info = tty->driver_data;
2055 2053
2056 if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2054 if (tty->index == MAX_PORTS)
2057 return -EFAULT; 2055 return -EINVAL;
2056 if (!info)
2057 return -ENODEV;
2058 2058
2059 if (new_serial.irq != 0 || new_serial.port != 0 || 2059 if (ss->irq != 0 || ss->port != 0 ||
2060 new_serial.custom_divisor != 0 || 2060 ss->custom_divisor != 0 ||
2061 new_serial.baud_base != 921600) 2061 ss->baud_base != 921600)
2062 return -EPERM; 2062 return -EPERM;
2063 2063
2064 mutex_lock(&info->port.mutex);
2064 if (!capable(CAP_SYS_ADMIN)) { 2065 if (!capable(CAP_SYS_ADMIN)) {
2065 if (((new_serial.flags & ~ASYNC_USR_MASK) != 2066 if (((ss->flags & ~ASYNC_USR_MASK) !=
2066 (info->port.flags & ~ASYNC_USR_MASK))) 2067 (info->port.flags & ~ASYNC_USR_MASK))) {
2068 mutex_unlock(&info->port.mutex);
2067 return -EPERM; 2069 return -EPERM;
2068 } else 2070 }
2069 info->port.close_delay = new_serial.close_delay * HZ / 100; 2071 }
2070 2072 info->port.close_delay = ss->close_delay * HZ / 100;
2071 new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS);
2072 new_serial.flags |= (info->port.flags & ASYNC_FLAGS);
2073 2073
2074 MoxaSetFifo(info, new_serial.type == PORT_16550A); 2074 MoxaSetFifo(info, ss->type == PORT_16550A);
2075 2075
2076 info->type = new_serial.type; 2076 info->type = ss->type;
2077 mutex_unlock(&info->port.mutex);
2077 return 0; 2078 return 0;
2078} 2079}
2079 2080
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 8bc15cb67a58..9d00ff5ef961 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1207,76 +1207,90 @@ static int mxser_chars_in_buffer(struct tty_struct *tty)
1207 * ------------------------------------------------------------ 1207 * ------------------------------------------------------------
1208 */ 1208 */
1209static int mxser_get_serial_info(struct tty_struct *tty, 1209static int mxser_get_serial_info(struct tty_struct *tty,
1210 struct serial_struct __user *retinfo) 1210 struct serial_struct *ss)
1211{ 1211{
1212 struct mxser_port *info = tty->driver_data; 1212 struct mxser_port *info = tty->driver_data;
1213 struct serial_struct tmp = { 1213 struct tty_port *port = &info->port;
1214 .type = info->type, 1214
1215 .line = tty->index, 1215 if (tty->index == MXSER_PORTS)
1216 .port = info->ioaddr, 1216 return -ENOTTY;
1217 .irq = info->board->irq, 1217
1218 .flags = info->port.flags, 1218 mutex_lock(&port->mutex);
1219 .baud_base = info->baud_base, 1219 ss->type = info->type,
1220 .close_delay = info->port.close_delay, 1220 ss->line = tty->index,
1221 .closing_wait = info->port.closing_wait, 1221 ss->port = info->ioaddr,
1222 .custom_divisor = info->custom_divisor, 1222 ss->irq = info->board->irq,
1223 }; 1223 ss->flags = info->port.flags,
1224 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1224 ss->baud_base = info->baud_base,
1225 return -EFAULT; 1225 ss->close_delay = info->port.close_delay,
1226 ss->closing_wait = info->port.closing_wait,
1227 ss->custom_divisor = info->custom_divisor,
1228 mutex_unlock(&port->mutex);
1226 return 0; 1229 return 0;
1227} 1230}
1228 1231
1229static int mxser_set_serial_info(struct tty_struct *tty, 1232static int mxser_set_serial_info(struct tty_struct *tty,
1230 struct serial_struct __user *new_info) 1233 struct serial_struct *ss)
1231{ 1234{
1232 struct mxser_port *info = tty->driver_data; 1235 struct mxser_port *info = tty->driver_data;
1233 struct tty_port *port = &info->port; 1236 struct tty_port *port = &info->port;
1234 struct serial_struct new_serial;
1235 speed_t baud; 1237 speed_t baud;
1236 unsigned long sl_flags; 1238 unsigned long sl_flags;
1237 unsigned int flags; 1239 unsigned int flags;
1238 int retval = 0; 1240 int retval = 0;
1239 1241
1240 if (!new_info || !info->ioaddr) 1242 if (tty->index == MXSER_PORTS)
1243 return -ENOTTY;
1244 if (tty_io_error(tty))
1245 return -EIO;
1246
1247 mutex_lock(&port->mutex);
1248 if (!info->ioaddr) {
1249 mutex_unlock(&port->mutex);
1241 return -ENODEV; 1250 return -ENODEV;
1242 if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 1251 }
1243 return -EFAULT;
1244 1252
1245 if (new_serial.irq != info->board->irq || 1253 if (ss->irq != info->board->irq ||
1246 new_serial.port != info->ioaddr) 1254 ss->port != info->ioaddr) {
1255 mutex_unlock(&port->mutex);
1247 return -EINVAL; 1256 return -EINVAL;
1257 }
1248 1258
1249 flags = port->flags & ASYNC_SPD_MASK; 1259 flags = port->flags & ASYNC_SPD_MASK;
1250 1260
1251 if (!capable(CAP_SYS_ADMIN)) { 1261 if (!capable(CAP_SYS_ADMIN)) {
1252 if ((new_serial.baud_base != info->baud_base) || 1262 if ((ss->baud_base != info->baud_base) ||
1253 (new_serial.close_delay != info->port.close_delay) || 1263 (ss->close_delay != info->port.close_delay) ||
1254 ((new_serial.flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) 1264 ((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) {
1265 mutex_unlock(&port->mutex);
1255 return -EPERM; 1266 return -EPERM;
1267 }
1256 info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) | 1268 info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
1257 (new_serial.flags & ASYNC_USR_MASK)); 1269 (ss->flags & ASYNC_USR_MASK));
1258 } else { 1270 } else {
1259 /* 1271 /*
1260 * OK, past this point, all the error checking has been done. 1272 * OK, past this point, all the error checking has been done.
1261 * At this point, we start making changes..... 1273 * At this point, we start making changes.....
1262 */ 1274 */
1263 port->flags = ((port->flags & ~ASYNC_FLAGS) | 1275 port->flags = ((port->flags & ~ASYNC_FLAGS) |
1264 (new_serial.flags & ASYNC_FLAGS)); 1276 (ss->flags & ASYNC_FLAGS));
1265 port->close_delay = new_serial.close_delay * HZ / 100; 1277 port->close_delay = ss->close_delay * HZ / 100;
1266 port->closing_wait = new_serial.closing_wait * HZ / 100; 1278 port->closing_wait = ss->closing_wait * HZ / 100;
1267 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1279 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1268 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && 1280 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
1269 (new_serial.baud_base != info->baud_base || 1281 (ss->baud_base != info->baud_base ||
1270 new_serial.custom_divisor != 1282 ss->custom_divisor !=
1271 info->custom_divisor)) { 1283 info->custom_divisor)) {
1272 if (new_serial.custom_divisor == 0) 1284 if (ss->custom_divisor == 0) {
1285 mutex_unlock(&port->mutex);
1273 return -EINVAL; 1286 return -EINVAL;
1274 baud = new_serial.baud_base / new_serial.custom_divisor; 1287 }
1288 baud = ss->baud_base / ss->custom_divisor;
1275 tty_encode_baud_rate(tty, baud, baud); 1289 tty_encode_baud_rate(tty, baud, baud);
1276 } 1290 }
1277 } 1291 }
1278 1292
1279 info->type = new_serial.type; 1293 info->type = ss->type;
1280 1294
1281 process_txrx_fifo(info); 1295 process_txrx_fifo(info);
1282 1296
@@ -1291,6 +1305,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
1291 if (retval == 0) 1305 if (retval == 0)
1292 tty_port_set_initialized(port, 1); 1306 tty_port_set_initialized(port, 1);
1293 } 1307 }
1308 mutex_unlock(&port->mutex);
1294 return retval; 1309 return retval;
1295} 1310}
1296 1311
@@ -1660,11 +1675,9 @@ static int mxser_ioctl(struct tty_struct *tty,
1660 unsigned int cmd, unsigned long arg) 1675 unsigned int cmd, unsigned long arg)
1661{ 1676{
1662 struct mxser_port *info = tty->driver_data; 1677 struct mxser_port *info = tty->driver_data;
1663 struct tty_port *port = &info->port;
1664 struct async_icount cnow; 1678 struct async_icount cnow;
1665 unsigned long flags; 1679 unsigned long flags;
1666 void __user *argp = (void __user *)arg; 1680 void __user *argp = (void __user *)arg;
1667 int retval;
1668 1681
1669 if (tty->index == MXSER_PORTS) 1682 if (tty->index == MXSER_PORTS)
1670 return mxser_ioctl_special(cmd, argp); 1683 return mxser_ioctl_special(cmd, argp);
@@ -1708,20 +1721,10 @@ static int mxser_ioctl(struct tty_struct *tty,
1708 return 0; 1721 return 0;
1709 } 1722 }
1710 1723
1711 if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && tty_io_error(tty)) 1724 if (cmd != TIOCMIWAIT && tty_io_error(tty))
1712 return -EIO; 1725 return -EIO;
1713 1726
1714 switch (cmd) { 1727 switch (cmd) {
1715 case TIOCGSERIAL:
1716 mutex_lock(&port->mutex);
1717 retval = mxser_get_serial_info(tty, argp);
1718 mutex_unlock(&port->mutex);
1719 return retval;
1720 case TIOCSSERIAL:
1721 mutex_lock(&port->mutex);
1722 retval = mxser_set_serial_info(tty, argp);
1723 mutex_unlock(&port->mutex);
1724 return retval;
1725 case TIOCSERGETLSR: /* Get line status register */ 1728 case TIOCSERGETLSR: /* Get line status register */
1726 return mxser_get_lsr_info(info, argp); 1729 return mxser_get_lsr_info(info, argp);
1727 /* 1730 /*
@@ -2325,6 +2328,8 @@ static const struct tty_operations mxser_ops = {
2325 .wait_until_sent = mxser_wait_until_sent, 2328 .wait_until_sent = mxser_wait_until_sent,
2326 .tiocmget = mxser_tiocmget, 2329 .tiocmget = mxser_tiocmget,
2327 .tiocmset = mxser_tiocmset, 2330 .tiocmset = mxser_tiocmset,
2331 .set_serial = mxser_set_serial_info,
2332 .get_serial = mxser_get_serial_info,
2328 .get_icount = mxser_get_icount, 2333 .get_icount = mxser_get_icount,
2329}; 2334};
2330 2335
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 86b7e20ffd7f..6f7da9a9d76f 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2614,14 +2614,6 @@ static int gsmld_ioctl(struct tty_struct *tty, struct file *file,
2614 } 2614 }
2615} 2615}
2616 2616
2617#ifdef CONFIG_COMPAT
2618static long gsmld_compat_ioctl(struct tty_struct *tty, struct file *file,
2619 unsigned int cmd, unsigned long arg)
2620{
2621 return gsmld_ioctl(tty, file, cmd, arg);
2622}
2623#endif
2624
2625/* 2617/*
2626 * Network interface 2618 * Network interface
2627 * 2619 *
@@ -2833,9 +2825,6 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
2833 .flush_buffer = gsmld_flush_buffer, 2825 .flush_buffer = gsmld_flush_buffer,
2834 .read = gsmld_read, 2826 .read = gsmld_read,
2835 .write = gsmld_write, 2827 .write = gsmld_write,
2836#ifdef CONFIG_COMPAT
2837 .compat_ioctl = gsmld_compat_ioctl,
2838#endif
2839 .ioctl = gsmld_ioctl, 2828 .ioctl = gsmld_ioctl,
2840 .poll = gsmld_poll, 2829 .poll = gsmld_poll,
2841 .receive_buf = gsmld_receive_buf, 2830 .receive_buf = gsmld_receive_buf,
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index dbf1ab36758e..749a608c40b0 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -134,6 +134,10 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
134 const unsigned char *buf, size_t nr); 134 const unsigned char *buf, size_t nr);
135static int r3964_ioctl(struct tty_struct *tty, struct file *file, 135static int r3964_ioctl(struct tty_struct *tty, struct file *file,
136 unsigned int cmd, unsigned long arg); 136 unsigned int cmd, unsigned long arg);
137#ifdef CONFIG_COMPAT
138static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file,
139 unsigned int cmd, unsigned long arg);
140#endif
137static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old); 141static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
138static __poll_t r3964_poll(struct tty_struct *tty, struct file *file, 142static __poll_t r3964_poll(struct tty_struct *tty, struct file *file,
139 struct poll_table_struct *wait); 143 struct poll_table_struct *wait);
@@ -149,6 +153,9 @@ static struct tty_ldisc_ops tty_ldisc_N_R3964 = {
149 .read = r3964_read, 153 .read = r3964_read,
150 .write = r3964_write, 154 .write = r3964_write,
151 .ioctl = r3964_ioctl, 155 .ioctl = r3964_ioctl,
156#ifdef CONFIG_COMPAT
157 .compat_ioctl = r3964_compat_ioctl,
158#endif
152 .set_termios = r3964_set_termios, 159 .set_termios = r3964_set_termios,
153 .poll = r3964_poll, 160 .poll = r3964_poll,
154 .receive_buf = r3964_receive_buf, 161 .receive_buf = r3964_receive_buf,
@@ -1210,6 +1217,21 @@ static int r3964_ioctl(struct tty_struct *tty, struct file *file,
1210 } 1217 }
1211} 1218}
1212 1219
1220#ifdef CONFIG_COMPAT
1221static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file,
1222 unsigned int cmd, unsigned long arg)
1223{
1224 switch (cmd) {
1225 case R3964_ENABLE_SIGNALS:
1226 case R3964_SETPRIORITY:
1227 case R3964_USE_BCC:
1228 return r3964_ioctl(tty, file, cmd, arg);
1229 default:
1230 return -ENOIOCTLCMD;
1231 }
1232}
1233#endif
1234
1213static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old) 1235static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old)
1214{ 1236{
1215 TRACE_L("set_termios"); 1237 TRACE_L("set_termios");
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 678406e0948b..00099a8439d2 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -28,6 +28,7 @@
28#include <linux/mount.h> 28#include <linux/mount.h>
29#include <linux/file.h> 29#include <linux/file.h>
30#include <linux/ioctl.h> 30#include <linux/ioctl.h>
31#include <linux/compat.h>
31 32
32#undef TTY_DEBUG_HANGUP 33#undef TTY_DEBUG_HANGUP
33#ifdef TTY_DEBUG_HANGUP 34#ifdef TTY_DEBUG_HANGUP
@@ -488,6 +489,7 @@ static int pty_bsd_ioctl(struct tty_struct *tty,
488 return -ENOIOCTLCMD; 489 return -ENOIOCTLCMD;
489} 490}
490 491
492#ifdef CONFIG_COMPAT
491static long pty_bsd_compat_ioctl(struct tty_struct *tty, 493static long pty_bsd_compat_ioctl(struct tty_struct *tty,
492 unsigned int cmd, unsigned long arg) 494 unsigned int cmd, unsigned long arg)
493{ 495{
@@ -495,8 +497,11 @@ static long pty_bsd_compat_ioctl(struct tty_struct *tty,
495 * PTY ioctls don't require any special translation between 32-bit and 497 * PTY ioctls don't require any special translation between 32-bit and
496 * 64-bit userspace, they are already compatible. 498 * 64-bit userspace, they are already compatible.
497 */ 499 */
498 return pty_bsd_ioctl(tty, cmd, arg); 500 return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg));
499} 501}
502#else
503#define pty_bsd_compat_ioctl NULL
504#endif
500 505
501static int legacy_count = CONFIG_LEGACY_PTY_COUNT; 506static int legacy_count = CONFIG_LEGACY_PTY_COUNT;
502/* 507/*
@@ -676,6 +681,7 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
676 return -ENOIOCTLCMD; 681 return -ENOIOCTLCMD;
677} 682}
678 683
684#ifdef CONFIG_COMPAT
679static long pty_unix98_compat_ioctl(struct tty_struct *tty, 685static long pty_unix98_compat_ioctl(struct tty_struct *tty,
680 unsigned int cmd, unsigned long arg) 686 unsigned int cmd, unsigned long arg)
681{ 687{
@@ -683,8 +689,12 @@ static long pty_unix98_compat_ioctl(struct tty_struct *tty,
683 * PTY ioctls don't require any special translation between 32-bit and 689 * PTY ioctls don't require any special translation between 32-bit and
684 * 64-bit userspace, they are already compatible. 690 * 64-bit userspace, they are already compatible.
685 */ 691 */
686 return pty_unix98_ioctl(tty, cmd, arg); 692 return pty_unix98_ioctl(tty, cmd,
693 cmd == TIOCSIG ? arg : (unsigned long)compat_ptr(arg));
687} 694}
695#else
696#define pty_unix98_compat_ioctl NULL
697#endif
688 698
689/** 699/**
690 * ptm_unix98_lookup - find a pty master 700 * ptm_unix98_lookup - find a pty master
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 80bb56facfb6..54726c3f74c6 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -778,17 +778,13 @@ out:
778 return ret; 778 return ret;
779} 779}
780 780
781static int uart_get_info_user(struct tty_port *port, 781static int uart_get_info_user(struct tty_struct *tty,
782 struct serial_struct __user *retinfo) 782 struct serial_struct *ss)
783{ 783{
784 struct serial_struct tmp; 784 struct uart_state *state = tty->driver_data;
785 785 struct tty_port *port = &state->port;
786 if (uart_get_info(port, &tmp) < 0)
787 return -EIO;
788 786
789 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 787 return uart_get_info(port, ss) < 0 ? -EIO : 0;
790 return -EFAULT;
791 return 0;
792} 788}
793 789
794static int uart_set_info(struct tty_struct *tty, struct tty_port *port, 790static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
@@ -990,16 +986,13 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
990 return retval; 986 return retval;
991} 987}
992 988
993static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state, 989static int uart_set_info_user(struct tty_struct *tty, struct serial_struct *ss)
994 struct serial_struct __user *newinfo)
995{ 990{
996 struct serial_struct new_serial; 991 struct uart_state *state = tty->driver_data;
997 struct tty_port *port = &state->port; 992 struct tty_port *port = &state->port;
998 int retval; 993 int retval;
999 994
1000 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 995 down_write(&tty->termios_rwsem);
1001 return -EFAULT;
1002
1003 /* 996 /*
1004 * This semaphore protects port->count. It is also 997 * This semaphore protects port->count. It is also
1005 * very useful to prevent opens. Also, take the 998 * very useful to prevent opens. Also, take the
@@ -1008,8 +1001,9 @@ static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state,
1008 * under us. 1001 * under us.
1009 */ 1002 */
1010 mutex_lock(&port->mutex); 1003 mutex_lock(&port->mutex);
1011 retval = uart_set_info(tty, port, state, &new_serial); 1004 retval = uart_set_info(tty, port, state, ss);
1012 mutex_unlock(&port->mutex); 1005 mutex_unlock(&port->mutex);
1006 up_write(&tty->termios_rwsem);
1013 return retval; 1007 return retval;
1014} 1008}
1015 1009
@@ -1325,26 +1319,11 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
1325 * These ioctls don't rely on the hardware to be present. 1319 * These ioctls don't rely on the hardware to be present.
1326 */ 1320 */
1327 switch (cmd) { 1321 switch (cmd) {
1328 case TIOCGSERIAL:
1329 ret = uart_get_info_user(port, uarg);
1330 break;
1331
1332 case TIOCSSERIAL:
1333 down_write(&tty->termios_rwsem);
1334 ret = uart_set_info_user(tty, state, uarg);
1335 up_write(&tty->termios_rwsem);
1336 break;
1337
1338 case TIOCSERCONFIG: 1322 case TIOCSERCONFIG:
1339 down_write(&tty->termios_rwsem); 1323 down_write(&tty->termios_rwsem);
1340 ret = uart_do_autoconfig(tty, state); 1324 ret = uart_do_autoconfig(tty, state);
1341 up_write(&tty->termios_rwsem); 1325 up_write(&tty->termios_rwsem);
1342 break; 1326 break;
1343
1344 case TIOCSERGWILD: /* obsolete */
1345 case TIOCSERSWILD: /* obsolete */
1346 ret = 0;
1347 break;
1348 } 1327 }
1349 1328
1350 if (ret != -ENOIOCTLCMD) 1329 if (ret != -ENOIOCTLCMD)
@@ -2413,6 +2392,8 @@ static const struct tty_operations uart_ops = {
2413#endif 2392#endif
2414 .tiocmget = uart_tiocmget, 2393 .tiocmget = uart_tiocmget,
2415 .tiocmset = uart_tiocmset, 2394 .tiocmset = uart_tiocmset,
2395 .set_serial = uart_set_info_user,
2396 .get_serial = uart_get_info_user,
2416 .get_icount = uart_get_icount, 2397 .get_icount = uart_get_icount,
2417#ifdef CONFIG_CONSOLE_POLL 2398#ifdef CONFIG_CONSOLE_POLL
2418 .poll_init = uart_poll_init, 2399 .poll_init = uart_poll_init,
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index fbdf4d01c6a9..d55c858d6058 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -2959,8 +2959,7 @@ static int mgsl_ioctl(struct tty_struct *tty,
2959 if (mgsl_paranoia_check(info, tty->name, "mgsl_ioctl")) 2959 if (mgsl_paranoia_check(info, tty->name, "mgsl_ioctl"))
2960 return -ENODEV; 2960 return -ENODEV;
2961 2961
2962 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 2962 if (cmd != TIOCMIWAIT) {
2963 (cmd != TIOCMIWAIT)) {
2964 if (tty_io_error(tty)) 2963 if (tty_io_error(tty))
2965 return -EIO; 2964 return -EIO;
2966 } 2965 }
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index a94086597ebd..e8a9047de451 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -1029,8 +1029,7 @@ static int ioctl(struct tty_struct *tty,
1029 return -ENODEV; 1029 return -ENODEV;
1030 DBGINFO(("%s ioctl() cmd=%08X\n", info->device_name, cmd)); 1030 DBGINFO(("%s ioctl() cmd=%08X\n", info->device_name, cmd));
1031 1031
1032 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1032 if (cmd != TIOCMIWAIT) {
1033 (cmd != TIOCMIWAIT)) {
1034 if (tty_io_error(tty)) 1033 if (tty_io_error(tty))
1035 return -EIO; 1034 return -EIO;
1036 } 1035 }
@@ -1186,14 +1185,13 @@ static long slgt_compat_ioctl(struct tty_struct *tty,
1186 unsigned int cmd, unsigned long arg) 1185 unsigned int cmd, unsigned long arg)
1187{ 1186{
1188 struct slgt_info *info = tty->driver_data; 1187 struct slgt_info *info = tty->driver_data;
1189 int rc = -ENOIOCTLCMD; 1188 int rc;
1190 1189
1191 if (sanity_check(info, tty->name, "compat_ioctl")) 1190 if (sanity_check(info, tty->name, "compat_ioctl"))
1192 return -ENODEV; 1191 return -ENODEV;
1193 DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd)); 1192 DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd));
1194 1193
1195 switch (cmd) { 1194 switch (cmd) {
1196
1197 case MGSL_IOCSPARAMS32: 1195 case MGSL_IOCSPARAMS32:
1198 rc = set_params32(info, compat_ptr(arg)); 1196 rc = set_params32(info, compat_ptr(arg));
1199 break; 1197 break;
@@ -1213,18 +1211,11 @@ static long slgt_compat_ioctl(struct tty_struct *tty,
1213 case MGSL_IOCWAITGPIO: 1211 case MGSL_IOCWAITGPIO:
1214 case MGSL_IOCGXSYNC: 1212 case MGSL_IOCGXSYNC:
1215 case MGSL_IOCGXCTRL: 1213 case MGSL_IOCGXCTRL:
1216 case MGSL_IOCSTXIDLE: 1214 rc = ioctl(tty, cmd, (unsigned long)compat_ptr(arg));
1217 case MGSL_IOCTXENABLE:
1218 case MGSL_IOCRXENABLE:
1219 case MGSL_IOCTXABORT:
1220 case TIOCMIWAIT:
1221 case MGSL_IOCSIF:
1222 case MGSL_IOCSXSYNC:
1223 case MGSL_IOCSXCTRL:
1224 rc = ioctl(tty, cmd, arg);
1225 break; 1215 break;
1216 default:
1217 rc = ioctl(tty, cmd, arg);
1226 } 1218 }
1227
1228 DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc)); 1219 DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc));
1229 return rc; 1220 return rc;
1230} 1221}
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index 1e4d5b9c981a..fcb91bf7a15b 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -1259,8 +1259,7 @@ static int ioctl(struct tty_struct *tty,
1259 if (sanity_check(info, tty->name, "ioctl")) 1259 if (sanity_check(info, tty->name, "ioctl"))
1260 return -ENODEV; 1260 return -ENODEV;
1261 1261
1262 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1262 if (cmd != TIOCMIWAIT) {
1263 (cmd != TIOCMIWAIT)) {
1264 if (tty_io_error(tty)) 1263 if (tty_io_error(tty))
1265 return -EIO; 1264 return -EIO;
1266 } 1265 }
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 816d8ba971a2..da3c1c2f73c4 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -97,6 +97,7 @@
97#include <linux/seq_file.h> 97#include <linux/seq_file.h>
98#include <linux/serial.h> 98#include <linux/serial.h>
99#include <linux/ratelimit.h> 99#include <linux/ratelimit.h>
100#include <linux/compat.h>
100 101
101#include <linux/uaccess.h> 102#include <linux/uaccess.h>
102 103
@@ -2293,34 +2294,6 @@ static int tioccons(struct file *file)
2293} 2294}
2294 2295
2295/** 2296/**
2296 * fionbio - non blocking ioctl
2297 * @file: file to set blocking value
2298 * @p: user parameter
2299 *
2300 * Historical tty interfaces had a blocking control ioctl before
2301 * the generic functionality existed. This piece of history is preserved
2302 * in the expected tty API of posix OS's.
2303 *
2304 * Locking: none, the open file handle ensures it won't go away.
2305 */
2306
2307static int fionbio(struct file *file, int __user *p)
2308{
2309 int nonblock;
2310
2311 if (get_user(nonblock, p))
2312 return -EFAULT;
2313
2314 spin_lock(&file->f_lock);
2315 if (nonblock)
2316 file->f_flags |= O_NONBLOCK;
2317 else
2318 file->f_flags &= ~O_NONBLOCK;
2319 spin_unlock(&file->f_lock);
2320 return 0;
2321}
2322
2323/**
2324 * tiocsetd - set line discipline 2297 * tiocsetd - set line discipline
2325 * @tty: tty device 2298 * @tty: tty device
2326 * @p: pointer to user data 2299 * @p: pointer to user data
@@ -2488,22 +2461,40 @@ static int tty_tiocgicount(struct tty_struct *tty, void __user *arg)
2488 return 0; 2461 return 0;
2489} 2462}
2490 2463
2491static void tty_warn_deprecated_flags(struct serial_struct __user *ss) 2464static int tty_tiocsserial(struct tty_struct *tty, struct serial_struct __user *ss)
2492{ 2465{
2493 static DEFINE_RATELIMIT_STATE(depr_flags, 2466 static DEFINE_RATELIMIT_STATE(depr_flags,
2494 DEFAULT_RATELIMIT_INTERVAL, 2467 DEFAULT_RATELIMIT_INTERVAL,
2495 DEFAULT_RATELIMIT_BURST); 2468 DEFAULT_RATELIMIT_BURST);
2496 char comm[TASK_COMM_LEN]; 2469 char comm[TASK_COMM_LEN];
2470 struct serial_struct v;
2497 int flags; 2471 int flags;
2498 2472
2499 if (get_user(flags, &ss->flags)) 2473 if (copy_from_user(&v, ss, sizeof(struct serial_struct)))
2500 return; 2474 return -EFAULT;
2501 2475
2502 flags &= ASYNC_DEPRECATED; 2476 flags = v.flags & ASYNC_DEPRECATED;
2503 2477
2504 if (flags && __ratelimit(&depr_flags)) 2478 if (flags && __ratelimit(&depr_flags))
2505 pr_warn("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n", 2479 pr_warn("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n",
2506 __func__, get_task_comm(comm, current), flags); 2480 __func__, get_task_comm(comm, current), flags);
2481 if (!tty->ops->set_serial)
2482 return -ENOTTY;
2483 return tty->ops->set_serial(tty, &v);
2484}
2485
2486static int tty_tiocgserial(struct tty_struct *tty, struct serial_struct __user *ss)
2487{
2488 struct serial_struct v;
2489 int err;
2490
2491 memset(&v, 0, sizeof(struct serial_struct));
2492 if (!tty->ops->get_serial)
2493 return -ENOTTY;
2494 err = tty->ops->get_serial(tty, &v);
2495 if (!err && copy_to_user(ss, &v, sizeof(struct serial_struct)))
2496 err = -EFAULT;
2497 return err;
2507} 2498}
2508 2499
2509/* 2500/*
@@ -2566,8 +2557,6 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2566 return tiocswinsz(real_tty, p); 2557 return tiocswinsz(real_tty, p);
2567 case TIOCCONS: 2558 case TIOCCONS:
2568 return real_tty != tty ? -EINVAL : tioccons(file); 2559 return real_tty != tty ? -EINVAL : tioccons(file);
2569 case FIONBIO:
2570 return fionbio(file, p);
2571 case TIOCEXCL: 2560 case TIOCEXCL:
2572 set_bit(TTY_EXCLUSIVE, &tty->flags); 2561 set_bit(TTY_EXCLUSIVE, &tty->flags);
2573 return 0; 2562 return 0;
@@ -2622,11 +2611,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2622 case TIOCMBIS: 2611 case TIOCMBIS:
2623 return tty_tiocmset(tty, cmd, p); 2612 return tty_tiocmset(tty, cmd, p);
2624 case TIOCGICOUNT: 2613 case TIOCGICOUNT:
2625 retval = tty_tiocgicount(tty, p); 2614 return tty_tiocgicount(tty, p);
2626 /* For the moment allow fall through to the old method */
2627 if (retval != -EINVAL)
2628 return retval;
2629 break;
2630 case TCFLSH: 2615 case TCFLSH:
2631 switch (arg) { 2616 switch (arg) {
2632 case TCIFLUSH: 2617 case TCIFLUSH:
@@ -2637,8 +2622,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2637 } 2622 }
2638 break; 2623 break;
2639 case TIOCSSERIAL: 2624 case TIOCSSERIAL:
2640 tty_warn_deprecated_flags(p); 2625 return tty_tiocsserial(tty, p);
2641 break; 2626 case TIOCGSERIAL:
2627 return tty_tiocgserial(tty, p);
2642 case TIOCGPTPEER: 2628 case TIOCGPTPEER:
2643 /* Special because the struct file is needed */ 2629 /* Special because the struct file is needed */
2644 return ptm_open_peer(file, tty, (int)arg); 2630 return ptm_open_peer(file, tty, (int)arg);
@@ -2666,6 +2652,81 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2666} 2652}
2667 2653
2668#ifdef CONFIG_COMPAT 2654#ifdef CONFIG_COMPAT
2655
2656struct serial_struct32 {
2657 compat_int_t type;
2658 compat_int_t line;
2659 compat_uint_t port;
2660 compat_int_t irq;
2661 compat_int_t flags;
2662 compat_int_t xmit_fifo_size;
2663 compat_int_t custom_divisor;
2664 compat_int_t baud_base;
2665 unsigned short close_delay;
2666 char io_type;
2667 char reserved_char[1];
2668 compat_int_t hub6;
2669 unsigned short closing_wait; /* time to wait before closing */
2670 unsigned short closing_wait2; /* no longer used... */
2671 compat_uint_t iomem_base;
2672 unsigned short iomem_reg_shift;
2673 unsigned int port_high;
2674 /* compat_ulong_t iomap_base FIXME */
2675 compat_int_t reserved[1];
2676};
2677
2678static int compat_tty_tiocsserial(struct tty_struct *tty,
2679 struct serial_struct32 __user *ss)
2680{
2681 static DEFINE_RATELIMIT_STATE(depr_flags,
2682 DEFAULT_RATELIMIT_INTERVAL,
2683 DEFAULT_RATELIMIT_BURST);
2684 char comm[TASK_COMM_LEN];
2685 struct serial_struct32 v32;
2686 struct serial_struct v;
2687 int flags;
2688
2689 if (copy_from_user(&v32, ss, sizeof(struct serial_struct32)))
2690 return -EFAULT;
2691
2692 memcpy(&v, &v32, offsetof(struct serial_struct32, iomem_base));
2693 v.iomem_base = compat_ptr(v32.iomem_base);
2694 v.iomem_reg_shift = v32.iomem_reg_shift;
2695 v.port_high = v32.port_high;
2696 v.iomap_base = 0;
2697
2698 flags = v.flags & ASYNC_DEPRECATED;
2699
2700 if (flags && __ratelimit(&depr_flags))
2701 pr_warn("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n",
2702 __func__, get_task_comm(comm, current), flags);
2703 if (!tty->ops->set_serial)
2704 return -ENOTTY;
2705 return tty->ops->set_serial(tty, &v);
2706}
2707
2708static int compat_tty_tiocgserial(struct tty_struct *tty,
2709 struct serial_struct32 __user *ss)
2710{
2711 struct serial_struct32 v32;
2712 struct serial_struct v;
2713 int err;
2714 memset(&v, 0, sizeof(struct serial_struct));
2715
2716 if (!tty->ops->set_serial)
2717 return -ENOTTY;
2718 err = tty->ops->get_serial(tty, &v);
2719 if (!err) {
2720 memcpy(&v32, &v, offsetof(struct serial_struct32, iomem_base));
2721 v32.iomem_base = (unsigned long)v.iomem_base >> 32 ?
2722 0xfffffff : ptr_to_compat(v.iomem_base);
2723 v32.iomem_reg_shift = v.iomem_reg_shift;
2724 v32.port_high = v.port_high;
2725 if (copy_to_user(ss, &v32, sizeof(struct serial_struct32)))
2726 err = -EFAULT;
2727 }
2728 return err;
2729}
2669static long tty_compat_ioctl(struct file *file, unsigned int cmd, 2730static long tty_compat_ioctl(struct file *file, unsigned int cmd,
2670 unsigned long arg) 2731 unsigned long arg)
2671{ 2732{
@@ -2673,9 +2734,90 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
2673 struct tty_ldisc *ld; 2734 struct tty_ldisc *ld;
2674 int retval = -ENOIOCTLCMD; 2735 int retval = -ENOIOCTLCMD;
2675 2736
2737 switch (cmd) {
2738 case TIOCSTI:
2739 case TIOCGWINSZ:
2740 case TIOCSWINSZ:
2741 case TIOCGEXCL:
2742 case TIOCGETD:
2743 case TIOCSETD:
2744 case TIOCGDEV:
2745 case TIOCMGET:
2746 case TIOCMSET:
2747 case TIOCMBIC:
2748 case TIOCMBIS:
2749 case TIOCGICOUNT:
2750 case TIOCGPGRP:
2751 case TIOCSPGRP:
2752 case TIOCGSID:
2753 case TIOCSERGETLSR:
2754 case TIOCGRS485:
2755 case TIOCSRS485:
2756#ifdef TIOCGETP
2757 case TIOCGETP:
2758 case TIOCSETP:
2759 case TIOCSETN:
2760#endif
2761#ifdef TIOCGETC
2762 case TIOCGETC:
2763 case TIOCSETC:
2764#endif
2765#ifdef TIOCGLTC
2766 case TIOCGLTC:
2767 case TIOCSLTC:
2768#endif
2769 case TCSETSF:
2770 case TCSETSW:
2771 case TCSETS:
2772 case TCGETS:
2773#ifdef TCGETS2
2774 case TCGETS2:
2775 case TCSETSF2:
2776 case TCSETSW2:
2777 case TCSETS2:
2778#endif
2779 case TCGETA:
2780 case TCSETAF:
2781 case TCSETAW:
2782 case TCSETA:
2783 case TIOCGLCKTRMIOS:
2784 case TIOCSLCKTRMIOS:
2785#ifdef TCGETX
2786 case TCGETX:
2787 case TCSETX:
2788 case TCSETXW:
2789 case TCSETXF:
2790#endif
2791 case TIOCGSOFTCAR:
2792 case TIOCSSOFTCAR:
2793 return tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
2794 case TIOCCONS:
2795 case TIOCEXCL:
2796 case TIOCNXCL:
2797 case TIOCVHANGUP:
2798 case TIOCSBRK:
2799 case TIOCCBRK:
2800 case TCSBRK:
2801 case TCSBRKP:
2802 case TCFLSH:
2803 case TIOCGPTPEER:
2804 case TIOCNOTTY:
2805 case TIOCSCTTY:
2806 case TCXONC:
2807 case TIOCMIWAIT:
2808 case TIOCSERCONFIG:
2809 return tty_ioctl(file, cmd, arg);
2810 }
2811
2676 if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) 2812 if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl"))
2677 return -EINVAL; 2813 return -EINVAL;
2678 2814
2815 switch (cmd) {
2816 case TIOCSSERIAL:
2817 return compat_tty_tiocsserial(tty, compat_ptr(arg));
2818 case TIOCGSERIAL:
2819 return compat_tty_tiocgserial(tty, compat_ptr(arg));
2820 }
2679 if (tty->ops->compat_ioctl) { 2821 if (tty->ops->compat_ioctl) {
2680 retval = tty->ops->compat_ioctl(tty, cmd, arg); 2822 retval = tty->ops->compat_ioctl(tty, cmd, arg);
2681 if (retval != -ENOIOCTLCMD) 2823 if (retval != -ENOIOCTLCMD)
@@ -2687,8 +2829,9 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
2687 return hung_up_tty_compat_ioctl(file, cmd, arg); 2829 return hung_up_tty_compat_ioctl(file, cmd, arg);
2688 if (ld->ops->compat_ioctl) 2830 if (ld->ops->compat_ioctl)
2689 retval = ld->ops->compat_ioctl(tty, file, cmd, arg); 2831 retval = ld->ops->compat_ioctl(tty, file, cmd, arg);
2690 else 2832 if (retval == -ENOIOCTLCMD && ld->ops->ioctl)
2691 retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg); 2833 retval = ld->ops->ioctl(tty, file,
2834 (unsigned long)compat_ptr(cmd), arg);
2692 tty_ldisc_deref(ld); 2835 tty_ldisc_deref(ld);
2693 2836
2694 return retval; 2837 return retval;
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index d99fec44036c..9245fffdbceb 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -941,19 +941,3 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
941 } 941 }
942} 942}
943EXPORT_SYMBOL(n_tty_ioctl_helper); 943EXPORT_SYMBOL(n_tty_ioctl_helper);
944
945#ifdef CONFIG_COMPAT
946long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
947 unsigned int cmd, unsigned long arg)
948{
949 switch (cmd) {
950 case TIOCGLCKTRMIOS:
951 case TIOCSLCKTRMIOS:
952 return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg));
953 default:
954 return -ENOIOCTLCMD;
955 }
956}
957EXPORT_SYMBOL(n_tty_compat_ioctl_helper);
958#endif
959
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 73cdc0d633dd..8b0ed139592f 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -1175,17 +1175,13 @@ long vt_compat_ioctl(struct tty_struct *tty,
1175{ 1175{
1176 struct vc_data *vc = tty->driver_data; 1176 struct vc_data *vc = tty->driver_data;
1177 struct console_font_op op; /* used in multiple places here */ 1177 struct console_font_op op; /* used in multiple places here */
1178 unsigned int console; 1178 unsigned int console = vc->vc_num;
1179 void __user *up = (void __user *)arg; 1179 void __user *up = compat_ptr(arg);
1180 int perm; 1180 int perm;
1181 int ret = 0;
1182 1181
1183 console = vc->vc_num;
1184 1182
1185 if (!vc_cons_allocated(console)) { /* impossible? */ 1183 if (!vc_cons_allocated(console)) /* impossible? */
1186 ret = -ENOIOCTLCMD; 1184 return -ENOIOCTLCMD;
1187 goto out;
1188 }
1189 1185
1190 /* 1186 /*
1191 * To have permissions to do most of the vt ioctls, we either have 1187 * To have permissions to do most of the vt ioctls, we either have
@@ -1201,17 +1197,14 @@ long vt_compat_ioctl(struct tty_struct *tty,
1201 */ 1197 */
1202 case PIO_FONTX: 1198 case PIO_FONTX:
1203 case GIO_FONTX: 1199 case GIO_FONTX:
1204 ret = compat_fontx_ioctl(cmd, up, perm, &op); 1200 return compat_fontx_ioctl(cmd, up, perm, &op);
1205 break;
1206 1201
1207 case KDFONTOP: 1202 case KDFONTOP:
1208 ret = compat_kdfontop_ioctl(up, perm, &op, vc); 1203 return compat_kdfontop_ioctl(up, perm, &op, vc);
1209 break;
1210 1204
1211 case PIO_UNIMAP: 1205 case PIO_UNIMAP:
1212 case GIO_UNIMAP: 1206 case GIO_UNIMAP:
1213 ret = compat_unimap_ioctl(cmd, up, perm, vc); 1207 return compat_unimap_ioctl(cmd, up, perm, vc);
1214 break;
1215 1208
1216 /* 1209 /*
1217 * all these treat 'arg' as an integer 1210 * all these treat 'arg' as an integer
@@ -1236,21 +1229,15 @@ long vt_compat_ioctl(struct tty_struct *tty,
1236 case VT_DISALLOCATE: 1229 case VT_DISALLOCATE:
1237 case VT_RESIZE: 1230 case VT_RESIZE:
1238 case VT_RESIZEX: 1231 case VT_RESIZEX:
1239 goto fallback; 1232 return vt_ioctl(tty, cmd, arg);
1240 1233
1241 /* 1234 /*
1242 * the rest has a compatible data structure behind arg, 1235 * the rest has a compatible data structure behind arg,
1243 * but we have to convert it to a proper 64 bit pointer. 1236 * but we have to convert it to a proper 64 bit pointer.
1244 */ 1237 */
1245 default: 1238 default:
1246 arg = (unsigned long)compat_ptr(arg); 1239 return vt_ioctl(tty, cmd, (unsigned long)up);
1247 goto fallback;
1248 } 1240 }
1249out:
1250 return ret;
1251
1252fallback:
1253 return vt_ioctl(tty, cmd, arg);
1254} 1241}
1255 1242
1256 1243
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 9ede35cecb12..47d75c20c211 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -884,37 +884,28 @@ static int acm_tty_tiocmset(struct tty_struct *tty,
884 return acm_set_control(acm, acm->ctrlout = newctrl); 884 return acm_set_control(acm, acm->ctrlout = newctrl);
885} 885}
886 886
887static int get_serial_info(struct acm *acm, struct serial_struct __user *info) 887static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
888{ 888{
889 struct serial_struct tmp; 889 struct acm *acm = tty->driver_data;
890 890
891 memset(&tmp, 0, sizeof(tmp)); 891 ss->xmit_fifo_size = acm->writesize;
892 tmp.xmit_fifo_size = acm->writesize; 892 ss->baud_base = le32_to_cpu(acm->line.dwDTERate);
893 tmp.baud_base = le32_to_cpu(acm->line.dwDTERate); 893 ss->close_delay = acm->port.close_delay / 10;
894 tmp.close_delay = acm->port.close_delay / 10; 894 ss->closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
895 tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
896 ASYNC_CLOSING_WAIT_NONE : 895 ASYNC_CLOSING_WAIT_NONE :
897 acm->port.closing_wait / 10; 896 acm->port.closing_wait / 10;
898 897 return 0;
899 if (copy_to_user(info, &tmp, sizeof(tmp)))
900 return -EFAULT;
901 else
902 return 0;
903} 898}
904 899
905static int set_serial_info(struct acm *acm, 900static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
906 struct serial_struct __user *newinfo)
907{ 901{
908 struct serial_struct new_serial; 902 struct acm *acm = tty->driver_data;
909 unsigned int closing_wait, close_delay; 903 unsigned int closing_wait, close_delay;
910 int retval = 0; 904 int retval = 0;
911 905
912 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 906 close_delay = ss->close_delay * 10;
913 return -EFAULT; 907 closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ?
914 908 ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10;
915 close_delay = new_serial.close_delay * 10;
916 closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
917 ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
918 909
919 mutex_lock(&acm->port.mutex); 910 mutex_lock(&acm->port.mutex);
920 911
@@ -999,12 +990,6 @@ static int acm_tty_ioctl(struct tty_struct *tty,
999 int rv = -ENOIOCTLCMD; 990 int rv = -ENOIOCTLCMD;
1000 991
1001 switch (cmd) { 992 switch (cmd) {
1002 case TIOCGSERIAL: /* gets serial port data */
1003 rv = get_serial_info(acm, (struct serial_struct __user *) arg);
1004 break;
1005 case TIOCSSERIAL:
1006 rv = set_serial_info(acm, (struct serial_struct __user *) arg);
1007 break;
1008 case TIOCMIWAIT: 993 case TIOCMIWAIT:
1009 rv = usb_autopm_get_interface(acm->control); 994 rv = usb_autopm_get_interface(acm->control);
1010 if (rv < 0) { 995 if (rv < 0) {
@@ -1931,6 +1916,8 @@ static const struct tty_operations acm_ops = {
1931 .set_termios = acm_tty_set_termios, 1916 .set_termios = acm_tty_set_termios,
1932 .tiocmget = acm_tty_tiocmget, 1917 .tiocmget = acm_tty_tiocmget,
1933 .tiocmset = acm_tty_tiocmset, 1918 .tiocmset = acm_tty_tiocmset,
1919 .get_serial = get_serial_info,
1920 .set_serial = set_serial_info,
1934 .get_icount = acm_tty_get_icount, 1921 .get_icount = acm_tty_get_icount,
1935}; 1922};
1936 1923
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 7796ad8e33c6..ff38aa8963cf 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -397,38 +397,16 @@ err_free:
397 return result; 397 return result;
398} 398}
399 399
400static int ark3116_get_serial_info(struct usb_serial_port *port, 400static int ark3116_get_serial_info(struct tty_struct *tty,
401 struct serial_struct __user *retinfo) 401 struct serial_struct *ss)
402{
403 struct serial_struct tmp;
404
405 memset(&tmp, 0, sizeof(tmp));
406
407 tmp.type = PORT_16654;
408 tmp.line = port->minor;
409 tmp.port = port->port_number;
410 tmp.baud_base = 460800;
411
412 if (copy_to_user(retinfo, &tmp, sizeof(tmp)))
413 return -EFAULT;
414
415 return 0;
416}
417
418static int ark3116_ioctl(struct tty_struct *tty,
419 unsigned int cmd, unsigned long arg)
420{ 402{
421 struct usb_serial_port *port = tty->driver_data; 403 struct usb_serial_port *port = tty->driver_data;
422 void __user *user_arg = (void __user *)arg;
423
424 switch (cmd) {
425 case TIOCGSERIAL:
426 return ark3116_get_serial_info(port, user_arg);
427 default:
428 break;
429 }
430 404
431 return -ENOIOCTLCMD; 405 ss->type = PORT_16654;
406 ss->line = port->minor;
407 ss->port = port->port_number;
408 ss->baud_base = 460800;
409 return 0;
432} 410}
433 411
434static int ark3116_tiocmget(struct tty_struct *tty) 412static int ark3116_tiocmget(struct tty_struct *tty)
@@ -668,7 +646,7 @@ static struct usb_serial_driver ark3116_device = {
668 .port_remove = ark3116_port_remove, 646 .port_remove = ark3116_port_remove,
669 .set_termios = ark3116_set_termios, 647 .set_termios = ark3116_set_termios,
670 .init_termios = ark3116_init_termios, 648 .init_termios = ark3116_init_termios,
671 .ioctl = ark3116_ioctl, 649 .get_serial = ark3116_get_serial_info,
672 .tiocmget = ark3116_tiocmget, 650 .tiocmget = ark3116_tiocmget,
673 .tiocmset = ark3116_tiocmset, 651 .tiocmset = ark3116_tiocmset,
674 .tiocmiwait = usb_serial_generic_tiocmiwait, 652 .tiocmiwait = usb_serial_generic_tiocmiwait,
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 96036f87b1de..0dcdcb4b2cde 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -583,36 +583,16 @@ static int f81232_carrier_raised(struct usb_serial_port *port)
583 return 0; 583 return 0;
584} 584}
585 585
586static int f81232_get_serial_info(struct usb_serial_port *port, 586static int f81232_get_serial_info(struct tty_struct *tty,
587 unsigned long arg) 587 struct serial_struct *ss)
588{
589 struct serial_struct ser;
590
591 memset(&ser, 0, sizeof(ser));
592
593 ser.type = PORT_16550A;
594 ser.line = port->minor;
595 ser.port = port->port_number;
596 ser.baud_base = F81232_MAX_BAUDRATE;
597
598 if (copy_to_user((void __user *)arg, &ser, sizeof(ser)))
599 return -EFAULT;
600
601 return 0;
602}
603
604static int f81232_ioctl(struct tty_struct *tty,
605 unsigned int cmd, unsigned long arg)
606{ 588{
607 struct usb_serial_port *port = tty->driver_data; 589 struct usb_serial_port *port = tty->driver_data;
608 590
609 switch (cmd) { 591 ss->type = PORT_16550A;
610 case TIOCGSERIAL: 592 ss->line = port->minor;
611 return f81232_get_serial_info(port, arg); 593 ss->port = port->port_number;
612 default: 594 ss->baud_base = F81232_MAX_BAUDRATE;
613 break; 595 return 0;
614 }
615 return -ENOIOCTLCMD;
616} 596}
617 597
618static void f81232_interrupt_work(struct work_struct *work) 598static void f81232_interrupt_work(struct work_struct *work)
@@ -665,7 +645,7 @@ static struct usb_serial_driver f81232_device = {
665 .close = f81232_close, 645 .close = f81232_close,
666 .dtr_rts = f81232_dtr_rts, 646 .dtr_rts = f81232_dtr_rts,
667 .carrier_raised = f81232_carrier_raised, 647 .carrier_raised = f81232_carrier_raised,
668 .ioctl = f81232_ioctl, 648 .get_serial = f81232_get_serial_info,
669 .break_ctl = f81232_break_ctl, 649 .break_ctl = f81232_break_ctl,
670 .set_termios = f81232_set_termios, 650 .set_termios = f81232_set_termios,
671 .tiocmget = f81232_tiocmget, 651 .tiocmget = f81232_tiocmget,
diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 4dfbff20bda4..380933db34dd 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -1139,43 +1139,21 @@ static void f81534_close(struct usb_serial_port *port)
1139 mutex_unlock(&serial_priv->urb_mutex); 1139 mutex_unlock(&serial_priv->urb_mutex);
1140} 1140}
1141 1141
1142static int f81534_get_serial_info(struct usb_serial_port *port, 1142static int f81534_get_serial_info(struct tty_struct *tty,
1143 struct serial_struct __user *retinfo) 1143 struct serial_struct *ss)
1144{ 1144{
1145 struct usb_serial_port *port = tty->driver_data;
1145 struct f81534_port_private *port_priv; 1146 struct f81534_port_private *port_priv;
1146 struct serial_struct tmp;
1147 1147
1148 port_priv = usb_get_serial_port_data(port); 1148 port_priv = usb_get_serial_port_data(port);
1149 1149
1150 memset(&tmp, 0, sizeof(tmp)); 1150 ss->type = PORT_16550A;
1151 1151 ss->port = port->port_number;
1152 tmp.type = PORT_16550A; 1152 ss->line = port->minor;
1153 tmp.port = port->port_number; 1153 ss->baud_base = port_priv->baud_base;
1154 tmp.line = port->minor;
1155 tmp.baud_base = port_priv->baud_base;
1156
1157 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1158 return -EFAULT;
1159
1160 return 0; 1154 return 0;
1161} 1155}
1162 1156
1163static int f81534_ioctl(struct tty_struct *tty, unsigned int cmd,
1164 unsigned long arg)
1165{
1166 struct usb_serial_port *port = tty->driver_data;
1167 struct serial_struct __user *buf = (struct serial_struct __user *)arg;
1168
1169 switch (cmd) {
1170 case TIOCGSERIAL:
1171 return f81534_get_serial_info(port, buf);
1172 default:
1173 break;
1174 }
1175
1176 return -ENOIOCTLCMD;
1177}
1178
1179static void f81534_process_per_serial_block(struct usb_serial_port *port, 1157static void f81534_process_per_serial_block(struct usb_serial_port *port,
1180 u8 *data) 1158 u8 *data)
1181{ 1159{
@@ -1581,7 +1559,7 @@ static struct usb_serial_driver f81534_device = {
1581 .break_ctl = f81534_break_ctl, 1559 .break_ctl = f81534_break_ctl,
1582 .dtr_rts = f81534_dtr_rts, 1560 .dtr_rts = f81534_dtr_rts,
1583 .process_read_urb = f81534_process_read_urb, 1561 .process_read_urb = f81534_process_read_urb,
1584 .ioctl = f81534_ioctl, 1562 .get_serial = f81534_get_serial_info,
1585 .tiocmget = f81534_tiocmget, 1563 .tiocmget = f81534_tiocmget,
1586 .tiocmset = f81534_tiocmset, 1564 .tiocmset = f81534_tiocmset,
1587 .write_bulk_callback = f81534_write_usb_callback, 1565 .write_bulk_callback = f81534_write_usb_callback,
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index b5cef322826f..758ba789e997 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1055,6 +1055,10 @@ static int ftdi_tiocmset(struct tty_struct *tty,
1055 unsigned int set, unsigned int clear); 1055 unsigned int set, unsigned int clear);
1056static int ftdi_ioctl(struct tty_struct *tty, 1056static int ftdi_ioctl(struct tty_struct *tty,
1057 unsigned int cmd, unsigned long arg); 1057 unsigned int cmd, unsigned long arg);
1058static int get_serial_info(struct tty_struct *tty,
1059 struct serial_struct *ss);
1060static int set_serial_info(struct tty_struct *tty,
1061 struct serial_struct *ss);
1058static void ftdi_break_ctl(struct tty_struct *tty, int break_state); 1062static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
1059static bool ftdi_tx_empty(struct usb_serial_port *port); 1063static bool ftdi_tx_empty(struct usb_serial_port *port);
1060static int ftdi_get_modem_status(struct usb_serial_port *port, 1064static int ftdi_get_modem_status(struct usb_serial_port *port,
@@ -1091,6 +1095,8 @@ static struct usb_serial_driver ftdi_sio_device = {
1091 .tiocmiwait = usb_serial_generic_tiocmiwait, 1095 .tiocmiwait = usb_serial_generic_tiocmiwait,
1092 .get_icount = usb_serial_generic_get_icount, 1096 .get_icount = usb_serial_generic_get_icount,
1093 .ioctl = ftdi_ioctl, 1097 .ioctl = ftdi_ioctl,
1098 .get_serial = get_serial_info,
1099 .set_serial = set_serial_info,
1094 .set_termios = ftdi_set_termios, 1100 .set_termios = ftdi_set_termios,
1095 .break_ctl = ftdi_break_ctl, 1101 .break_ctl = ftdi_break_ctl,
1096 .tx_empty = ftdi_tx_empty, 1102 .tx_empty = ftdi_tx_empty,
@@ -1443,48 +1449,42 @@ static int read_latency_timer(struct usb_serial_port *port)
1443 return 0; 1449 return 0;
1444} 1450}
1445 1451
1446static int get_serial_info(struct usb_serial_port *port, 1452static int get_serial_info(struct tty_struct *tty,
1447 struct serial_struct __user *retinfo) 1453 struct serial_struct *ss)
1448{ 1454{
1455 struct usb_serial_port *port = tty->driver_data;
1449 struct ftdi_private *priv = usb_get_serial_port_data(port); 1456 struct ftdi_private *priv = usb_get_serial_port_data(port);
1450 struct serial_struct tmp;
1451 1457
1452 memset(&tmp, 0, sizeof(tmp)); 1458 ss->flags = priv->flags;
1453 tmp.flags = priv->flags; 1459 ss->baud_base = priv->baud_base;
1454 tmp.baud_base = priv->baud_base; 1460 ss->custom_divisor = priv->custom_divisor;
1455 tmp.custom_divisor = priv->custom_divisor;
1456 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1457 return -EFAULT;
1458 return 0; 1461 return 0;
1459} 1462}
1460 1463
1461static int set_serial_info(struct tty_struct *tty, 1464static int set_serial_info(struct tty_struct *tty,
1462 struct usb_serial_port *port, struct serial_struct __user *newinfo) 1465 struct serial_struct *ss)
1463{ 1466{
1467 struct usb_serial_port *port = tty->driver_data;
1464 struct ftdi_private *priv = usb_get_serial_port_data(port); 1468 struct ftdi_private *priv = usb_get_serial_port_data(port);
1465 struct serial_struct new_serial;
1466 struct ftdi_private old_priv; 1469 struct ftdi_private old_priv;
1467 1470
1468 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
1469 return -EFAULT;
1470
1471 mutex_lock(&priv->cfg_lock); 1471 mutex_lock(&priv->cfg_lock);
1472 old_priv = *priv; 1472 old_priv = *priv;
1473 1473
1474 /* Do error checking and permission checking */ 1474 /* Do error checking and permission checking */
1475 1475
1476 if (!capable(CAP_SYS_ADMIN)) { 1476 if (!capable(CAP_SYS_ADMIN)) {
1477 if ((new_serial.flags ^ priv->flags) & ~ASYNC_USR_MASK) { 1477 if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) {
1478 mutex_unlock(&priv->cfg_lock); 1478 mutex_unlock(&priv->cfg_lock);
1479 return -EPERM; 1479 return -EPERM;
1480 } 1480 }
1481 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1481 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
1482 (new_serial.flags & ASYNC_USR_MASK)); 1482 (ss->flags & ASYNC_USR_MASK));
1483 priv->custom_divisor = new_serial.custom_divisor; 1483 priv->custom_divisor = ss->custom_divisor;
1484 goto check_and_exit; 1484 goto check_and_exit;
1485 } 1485 }
1486 1486
1487 if (new_serial.baud_base != priv->baud_base) { 1487 if (ss->baud_base != priv->baud_base) {
1488 mutex_unlock(&priv->cfg_lock); 1488 mutex_unlock(&priv->cfg_lock);
1489 return -EINVAL; 1489 return -EINVAL;
1490 } 1490 }
@@ -1492,8 +1492,8 @@ static int set_serial_info(struct tty_struct *tty,
1492 /* Make the changes - these are privileged changes! */ 1492 /* Make the changes - these are privileged changes! */
1493 1493
1494 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 1494 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
1495 (new_serial.flags & ASYNC_FLAGS)); 1495 (ss->flags & ASYNC_FLAGS));
1496 priv->custom_divisor = new_serial.custom_divisor; 1496 priv->custom_divisor = ss->custom_divisor;
1497 1497
1498check_and_exit: 1498check_and_exit:
1499 write_latency_timer(port); 1499 write_latency_timer(port);
@@ -1507,10 +1507,8 @@ check_and_exit:
1507 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n"); 1507 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n");
1508 1508
1509 change_speed(tty, port); 1509 change_speed(tty, port);
1510 mutex_unlock(&priv->cfg_lock);
1511 } 1510 }
1512 else 1511 mutex_unlock(&priv->cfg_lock);
1513 mutex_unlock(&priv->cfg_lock);
1514 return 0; 1512 return 0;
1515} 1513}
1516 1514
@@ -2452,10 +2450,6 @@ static int ftdi_ioctl(struct tty_struct *tty,
2452 void __user *argp = (void __user *)arg; 2450 void __user *argp = (void __user *)arg;
2453 2451
2454 switch (cmd) { 2452 switch (cmd) {
2455 case TIOCGSERIAL:
2456 return get_serial_info(port, argp);
2457 case TIOCSSERIAL:
2458 return set_serial_info(tty, port, argp);
2459 case TIOCSERGETLSR: 2453 case TIOCSERGETLSR:
2460 return get_lsr_info(port, argp); 2454 return get_lsr_info(port, argp);
2461 default: 2455 default:
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 97c69d373ca6..4ca31c0e4174 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1637,24 +1637,20 @@ static int edge_tiocmget(struct tty_struct *tty)
1637 return result; 1637 return result;
1638} 1638}
1639 1639
1640static int get_serial_info(struct edgeport_port *edge_port, 1640static int get_serial_info(struct tty_struct *tty,
1641 struct serial_struct __user *retinfo) 1641 struct serial_struct *ss)
1642{ 1642{
1643 struct serial_struct tmp; 1643 struct usb_serial_port *port = tty->driver_data;
1644 1644 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1645 memset(&tmp, 0, sizeof(tmp));
1646
1647 tmp.type = PORT_16550A;
1648 tmp.line = edge_port->port->minor;
1649 tmp.port = edge_port->port->port_number;
1650 tmp.irq = 0;
1651 tmp.xmit_fifo_size = edge_port->maxTxCredits;
1652 tmp.baud_base = 9600;
1653 tmp.close_delay = 5*HZ;
1654 tmp.closing_wait = 30*HZ;
1655 1645
1656 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1646 ss->type = PORT_16550A;
1657 return -EFAULT; 1647 ss->line = edge_port->port->minor;
1648 ss->port = edge_port->port->port_number;
1649 ss->irq = 0;
1650 ss->xmit_fifo_size = edge_port->maxTxCredits;
1651 ss->baud_base = 9600;
1652 ss->close_delay = 5*HZ;
1653 ss->closing_wait = 30*HZ;
1658 return 0; 1654 return 0;
1659} 1655}
1660 1656
@@ -1667,17 +1663,12 @@ static int edge_ioctl(struct tty_struct *tty,
1667 unsigned int cmd, unsigned long arg) 1663 unsigned int cmd, unsigned long arg)
1668{ 1664{
1669 struct usb_serial_port *port = tty->driver_data; 1665 struct usb_serial_port *port = tty->driver_data;
1670 DEFINE_WAIT(wait);
1671 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1666 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1672 1667
1673 switch (cmd) { 1668 switch (cmd) {
1674 case TIOCSERGETLSR: 1669 case TIOCSERGETLSR:
1675 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); 1670 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__);
1676 return get_lsr_info(edge_port, (unsigned int __user *) arg); 1671 return get_lsr_info(edge_port, (unsigned int __user *) arg);
1677
1678 case TIOCGSERIAL:
1679 dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__);
1680 return get_serial_info(edge_port, (struct serial_struct __user *) arg);
1681 } 1672 }
1682 return -ENOIOCTLCMD; 1673 return -ENOIOCTLCMD;
1683} 1674}
@@ -3126,6 +3117,7 @@ static struct usb_serial_driver edgeport_2port_device = {
3126 .set_termios = edge_set_termios, 3117 .set_termios = edge_set_termios,
3127 .tiocmget = edge_tiocmget, 3118 .tiocmget = edge_tiocmget,
3128 .tiocmset = edge_tiocmset, 3119 .tiocmset = edge_tiocmset,
3120 .get_serial = get_serial_info,
3129 .tiocmiwait = usb_serial_generic_tiocmiwait, 3121 .tiocmiwait = usb_serial_generic_tiocmiwait,
3130 .get_icount = usb_serial_generic_get_icount, 3122 .get_icount = usb_serial_generic_get_icount,
3131 .write = edge_write, 3123 .write = edge_write,
@@ -3161,6 +3153,7 @@ static struct usb_serial_driver edgeport_4port_device = {
3161 .set_termios = edge_set_termios, 3153 .set_termios = edge_set_termios,
3162 .tiocmget = edge_tiocmget, 3154 .tiocmget = edge_tiocmget,
3163 .tiocmset = edge_tiocmset, 3155 .tiocmset = edge_tiocmset,
3156 .get_serial = get_serial_info,
3164 .tiocmiwait = usb_serial_generic_tiocmiwait, 3157 .tiocmiwait = usb_serial_generic_tiocmiwait,
3165 .get_icount = usb_serial_generic_get_icount, 3158 .get_icount = usb_serial_generic_get_icount,
3166 .write = edge_write, 3159 .write = edge_write,
@@ -3196,6 +3189,7 @@ static struct usb_serial_driver edgeport_8port_device = {
3196 .set_termios = edge_set_termios, 3189 .set_termios = edge_set_termios,
3197 .tiocmget = edge_tiocmget, 3190 .tiocmget = edge_tiocmget,
3198 .tiocmset = edge_tiocmset, 3191 .tiocmset = edge_tiocmset,
3192 .get_serial = get_serial_info,
3199 .tiocmiwait = usb_serial_generic_tiocmiwait, 3193 .tiocmiwait = usb_serial_generic_tiocmiwait,
3200 .get_icount = usb_serial_generic_get_icount, 3194 .get_icount = usb_serial_generic_get_icount,
3201 .write = edge_write, 3195 .write = edge_write,
@@ -3231,6 +3225,7 @@ static struct usb_serial_driver epic_device = {
3231 .set_termios = edge_set_termios, 3225 .set_termios = edge_set_termios,
3232 .tiocmget = edge_tiocmget, 3226 .tiocmget = edge_tiocmget,
3233 .tiocmset = edge_tiocmset, 3227 .tiocmset = edge_tiocmset,
3228 .get_serial = get_serial_info,
3234 .tiocmiwait = usb_serial_generic_tiocmiwait, 3229 .tiocmiwait = usb_serial_generic_tiocmiwait,
3235 .get_icount = usb_serial_generic_get_icount, 3230 .get_icount = usb_serial_generic_get_icount,
3236 .write = edge_write, 3231 .write = edge_write,
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 6d1d6efa3055..c327d4cf7928 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2437,47 +2437,28 @@ static int edge_tiocmget(struct tty_struct *tty)
2437 return result; 2437 return result;
2438} 2438}
2439 2439
2440static int get_serial_info(struct edgeport_port *edge_port, 2440static int get_serial_info(struct tty_struct *tty,
2441 struct serial_struct __user *retinfo) 2441 struct serial_struct *ss)
2442{ 2442{
2443 struct serial_struct tmp; 2443 struct usb_serial_port *port = tty->driver_data;
2444 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2444 unsigned cwait; 2445 unsigned cwait;
2445 2446
2446 cwait = edge_port->port->port.closing_wait; 2447 cwait = edge_port->port->port.closing_wait;
2447 if (cwait != ASYNC_CLOSING_WAIT_NONE) 2448 if (cwait != ASYNC_CLOSING_WAIT_NONE)
2448 cwait = jiffies_to_msecs(cwait) / 10; 2449 cwait = jiffies_to_msecs(cwait) / 10;
2449 2450
2450 memset(&tmp, 0, sizeof(tmp)); 2451 ss->type = PORT_16550A;
2451 2452 ss->line = edge_port->port->minor;
2452 tmp.type = PORT_16550A; 2453 ss->port = edge_port->port->port_number;
2453 tmp.line = edge_port->port->minor; 2454 ss->irq = 0;
2454 tmp.port = edge_port->port->port_number; 2455 ss->xmit_fifo_size = edge_port->port->bulk_out_size;
2455 tmp.irq = 0; 2456 ss->baud_base = 9600;
2456 tmp.xmit_fifo_size = edge_port->port->bulk_out_size; 2457 ss->close_delay = 5*HZ;
2457 tmp.baud_base = 9600; 2458 ss->closing_wait = cwait;
2458 tmp.close_delay = 5*HZ;
2459 tmp.closing_wait = cwait;
2460
2461 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
2462 return -EFAULT;
2463 return 0; 2459 return 0;
2464} 2460}
2465 2461
2466static int edge_ioctl(struct tty_struct *tty,
2467 unsigned int cmd, unsigned long arg)
2468{
2469 struct usb_serial_port *port = tty->driver_data;
2470 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2471
2472 switch (cmd) {
2473 case TIOCGSERIAL:
2474 dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__);
2475 return get_serial_info(edge_port,
2476 (struct serial_struct __user *) arg);
2477 }
2478 return -ENOIOCTLCMD;
2479}
2480
2481static void edge_break(struct tty_struct *tty, int break_state) 2462static void edge_break(struct tty_struct *tty, int break_state)
2482{ 2463{
2483 struct usb_serial_port *port = tty->driver_data; 2464 struct usb_serial_port *port = tty->driver_data;
@@ -2738,7 +2719,7 @@ static struct usb_serial_driver edgeport_1port_device = {
2738 .release = edge_release, 2719 .release = edge_release,
2739 .port_probe = edge_port_probe, 2720 .port_probe = edge_port_probe,
2740 .port_remove = edge_port_remove, 2721 .port_remove = edge_port_remove,
2741 .ioctl = edge_ioctl, 2722 .get_serial = get_serial_info,
2742 .set_termios = edge_set_termios, 2723 .set_termios = edge_set_termios,
2743 .tiocmget = edge_tiocmget, 2724 .tiocmget = edge_tiocmget,
2744 .tiocmset = edge_tiocmset, 2725 .tiocmset = edge_tiocmset,
@@ -2777,7 +2758,7 @@ static struct usb_serial_driver edgeport_2port_device = {
2777 .release = edge_release, 2758 .release = edge_release,
2778 .port_probe = edge_port_probe, 2759 .port_probe = edge_port_probe,
2779 .port_remove = edge_port_remove, 2760 .port_remove = edge_port_remove,
2780 .ioctl = edge_ioctl, 2761 .get_serial = get_serial_info,
2781 .set_termios = edge_set_termios, 2762 .set_termios = edge_set_termios,
2782 .tiocmget = edge_tiocmget, 2763 .tiocmget = edge_tiocmget,
2783 .tiocmset = edge_tiocmset, 2764 .tiocmset = edge_tiocmset,
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 27109522fd8b..fc52ac75fbf6 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1786,69 +1786,20 @@ static int mos7720_tiocmset(struct tty_struct *tty,
1786 return 0; 1786 return 0;
1787} 1787}
1788 1788
1789static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, 1789static int get_serial_info(struct tty_struct *tty,
1790 unsigned int __user *value) 1790 struct serial_struct *ss)
1791{ 1791{
1792 unsigned int mcr; 1792 struct usb_serial_port *port = tty->driver_data;
1793 unsigned int arg; 1793 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
1794
1795 struct usb_serial_port *port;
1796
1797 if (mos7720_port == NULL)
1798 return -1;
1799
1800 port = (struct usb_serial_port *)mos7720_port->port;
1801 mcr = mos7720_port->shadowMCR;
1802
1803 if (copy_from_user(&arg, value, sizeof(int)))
1804 return -EFAULT;
1805
1806 switch (cmd) {
1807 case TIOCMBIS:
1808 if (arg & TIOCM_RTS)
1809 mcr |= UART_MCR_RTS;
1810 if (arg & TIOCM_DTR)
1811 mcr |= UART_MCR_RTS;
1812 if (arg & TIOCM_LOOP)
1813 mcr |= UART_MCR_LOOP;
1814 break;
1815
1816 case TIOCMBIC:
1817 if (arg & TIOCM_RTS)
1818 mcr &= ~UART_MCR_RTS;
1819 if (arg & TIOCM_DTR)
1820 mcr &= ~UART_MCR_RTS;
1821 if (arg & TIOCM_LOOP)
1822 mcr &= ~UART_MCR_LOOP;
1823 break;
1824
1825 }
1826
1827 mos7720_port->shadowMCR = mcr;
1828 write_mos_reg(port->serial, port->port_number, MOS7720_MCR,
1829 mos7720_port->shadowMCR);
1830
1831 return 0;
1832}
1833
1834static int get_serial_info(struct moschip_port *mos7720_port,
1835 struct serial_struct __user *retinfo)
1836{
1837 struct serial_struct tmp;
1838
1839 memset(&tmp, 0, sizeof(tmp));
1840
1841 tmp.type = PORT_16550A;
1842 tmp.line = mos7720_port->port->minor;
1843 tmp.port = mos7720_port->port->port_number;
1844 tmp.irq = 0;
1845 tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
1846 tmp.baud_base = 9600;
1847 tmp.close_delay = 5*HZ;
1848 tmp.closing_wait = 30*HZ;
1849 1794
1850 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1795 ss->type = PORT_16550A;
1851 return -EFAULT; 1796 ss->line = mos7720_port->port->minor;
1797 ss->port = mos7720_port->port->port_number;
1798 ss->irq = 0;
1799 ss->xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
1800 ss->baud_base = 9600;
1801 ss->close_delay = 5*HZ;
1802 ss->closing_wait = 30*HZ;
1852 return 0; 1803 return 0;
1853} 1804}
1854 1805
@@ -1867,18 +1818,6 @@ static int mos7720_ioctl(struct tty_struct *tty,
1867 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); 1818 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__);
1868 return get_lsr_info(tty, mos7720_port, 1819 return get_lsr_info(tty, mos7720_port,
1869 (unsigned int __user *)arg); 1820 (unsigned int __user *)arg);
1870
1871 /* FIXME: These should be using the mode methods */
1872 case TIOCMBIS:
1873 case TIOCMBIC:
1874 dev_dbg(&port->dev, "%s TIOCMSET/TIOCMBIC/TIOCMSET\n", __func__);
1875 return set_modem_info(mos7720_port, cmd,
1876 (unsigned int __user *)arg);
1877
1878 case TIOCGSERIAL:
1879 dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__);
1880 return get_serial_info(mos7720_port,
1881 (struct serial_struct __user *)arg);
1882 } 1821 }
1883 1822
1884 return -ENOIOCTLCMD; 1823 return -ENOIOCTLCMD;
@@ -2015,6 +1954,7 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2015 .ioctl = mos7720_ioctl, 1954 .ioctl = mos7720_ioctl,
2016 .tiocmget = mos7720_tiocmget, 1955 .tiocmget = mos7720_tiocmget,
2017 .tiocmset = mos7720_tiocmset, 1956 .tiocmset = mos7720_tiocmset,
1957 .get_serial = get_serial_info,
2018 .set_termios = mos7720_set_termios, 1958 .set_termios = mos7720_set_termios,
2019 .write = mos7720_write, 1959 .write = mos7720_write,
2020 .write_room = mos7720_write_room, 1960 .write_room = mos7720_write_room,
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index b42bad85097a..88828b4b8c44 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1931,27 +1931,20 @@ static int mos7840_get_lsr_info(struct tty_struct *tty,
1931 * function to get information about serial port 1931 * function to get information about serial port
1932 *****************************************************************************/ 1932 *****************************************************************************/
1933 1933
1934static int mos7840_get_serial_info(struct moschip_port *mos7840_port, 1934static int mos7840_get_serial_info(struct tty_struct *tty,
1935 struct serial_struct __user *retinfo) 1935 struct serial_struct *ss)
1936{ 1936{
1937 struct serial_struct tmp; 1937 struct usb_serial_port *port = tty->driver_data;
1938 1938 struct moschip_port *mos7840_port = mos7840_get_port_private(port);
1939 if (mos7840_port == NULL)
1940 return -1;
1941
1942 memset(&tmp, 0, sizeof(tmp));
1943
1944 tmp.type = PORT_16550A;
1945 tmp.line = mos7840_port->port->minor;
1946 tmp.port = mos7840_port->port->port_number;
1947 tmp.irq = 0;
1948 tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
1949 tmp.baud_base = 9600;
1950 tmp.close_delay = 5 * HZ;
1951 tmp.closing_wait = 30 * HZ;
1952 1939
1953 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1940 ss->type = PORT_16550A;
1954 return -EFAULT; 1941 ss->line = mos7840_port->port->minor;
1942 ss->port = mos7840_port->port->port_number;
1943 ss->irq = 0;
1944 ss->xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
1945 ss->baud_base = 9600;
1946 ss->close_delay = 5 * HZ;
1947 ss->closing_wait = 30 * HZ;
1955 return 0; 1948 return 0;
1956} 1949}
1957 1950
@@ -1982,13 +1975,6 @@ static int mos7840_ioctl(struct tty_struct *tty,
1982 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); 1975 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__);
1983 return mos7840_get_lsr_info(tty, argp); 1976 return mos7840_get_lsr_info(tty, argp);
1984 1977
1985 case TIOCGSERIAL:
1986 dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__);
1987 return mos7840_get_serial_info(mos7840_port, argp);
1988
1989 case TIOCSSERIAL:
1990 dev_dbg(&port->dev, "%s TIOCSSERIAL\n", __func__);
1991 break;
1992 default: 1978 default:
1993 break; 1979 break;
1994 } 1980 }
@@ -2376,6 +2362,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
2376 .calc_num_ports = mos7840_calc_num_ports, 2362 .calc_num_ports = mos7840_calc_num_ports,
2377 .probe = mos7840_probe, 2363 .probe = mos7840_probe,
2378 .ioctl = mos7840_ioctl, 2364 .ioctl = mos7840_ioctl,
2365 .get_serial = mos7840_get_serial_info,
2379 .set_termios = mos7840_set_termios, 2366 .set_termios = mos7840_set_termios,
2380 .break_ctl = mos7840_break, 2367 .break_ctl = mos7840_break,
2381 .tiocmget = mos7840_tiocmget, 2368 .tiocmget = mos7840_tiocmget,
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index caa0746326fd..cb7aac9cd9e7 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -328,42 +328,23 @@ static int opticon_tiocmset(struct tty_struct *tty,
328 return 0; 328 return 0;
329} 329}
330 330
331static int get_serial_info(struct usb_serial_port *port, 331static int get_serial_info(struct tty_struct *tty,
332 struct serial_struct __user *serial) 332 struct serial_struct *ss)
333{ 333{
334 struct serial_struct tmp; 334 struct usb_serial_port *port = tty->driver_data;
335
336 memset(&tmp, 0x00, sizeof(tmp));
337 335
338 /* fake emulate a 16550 uart to make userspace code happy */ 336 /* fake emulate a 16550 uart to make userspace code happy */
339 tmp.type = PORT_16550A; 337 ss->type = PORT_16550A;
340 tmp.line = port->minor; 338 ss->line = port->minor;
341 tmp.port = 0; 339 ss->port = 0;
342 tmp.irq = 0; 340 ss->irq = 0;
343 tmp.xmit_fifo_size = 1024; 341 ss->xmit_fifo_size = 1024;
344 tmp.baud_base = 9600; 342 ss->baud_base = 9600;
345 tmp.close_delay = 5*HZ; 343 ss->close_delay = 5*HZ;
346 tmp.closing_wait = 30*HZ; 344 ss->closing_wait = 30*HZ;
347
348 if (copy_to_user(serial, &tmp, sizeof(*serial)))
349 return -EFAULT;
350 return 0; 345 return 0;
351} 346}
352 347
353static int opticon_ioctl(struct tty_struct *tty,
354 unsigned int cmd, unsigned long arg)
355{
356 struct usb_serial_port *port = tty->driver_data;
357
358 switch (cmd) {
359 case TIOCGSERIAL:
360 return get_serial_info(port,
361 (struct serial_struct __user *)arg);
362 }
363
364 return -ENOIOCTLCMD;
365}
366
367static int opticon_port_probe(struct usb_serial_port *port) 348static int opticon_port_probe(struct usb_serial_port *port)
368{ 349{
369 struct opticon_private *priv; 350 struct opticon_private *priv;
@@ -404,7 +385,7 @@ static struct usb_serial_driver opticon_device = {
404 .write_room = opticon_write_room, 385 .write_room = opticon_write_room,
405 .throttle = usb_serial_generic_throttle, 386 .throttle = usb_serial_generic_throttle,
406 .unthrottle = usb_serial_generic_unthrottle, 387 .unthrottle = usb_serial_generic_unthrottle,
407 .ioctl = opticon_ioctl, 388 .get_serial = get_serial_info,
408 .tiocmget = opticon_tiocmget, 389 .tiocmget = opticon_tiocmget,
409 .tiocmset = opticon_tiocmset, 390 .tiocmset = opticon_tiocmset,
410 .process_read_urb = opticon_process_read_urb, 391 .process_read_urb = opticon_process_read_urb,
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index e72ad9f81c73..e24ff16d4147 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1966,7 +1966,8 @@ static struct usb_serial_driver option_1port_device = {
1966 .chars_in_buffer = usb_wwan_chars_in_buffer, 1966 .chars_in_buffer = usb_wwan_chars_in_buffer,
1967 .tiocmget = usb_wwan_tiocmget, 1967 .tiocmget = usb_wwan_tiocmget,
1968 .tiocmset = usb_wwan_tiocmset, 1968 .tiocmset = usb_wwan_tiocmset,
1969 .ioctl = usb_wwan_ioctl, 1969 .get_serial = usb_wwan_get_serial_info,
1970 .set_serial = usb_wwan_set_serial_info,
1970 .attach = option_attach, 1971 .attach = option_attach,
1971 .release = option_release, 1972 .release = option_release,
1972 .port_probe = usb_wwan_port_probe, 1973 .port_probe = usb_wwan_port_probe,
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index e41f725ac7aa..a4e0d13fc121 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -808,29 +808,16 @@ static int pl2303_carrier_raised(struct usb_serial_port *port)
808 return 0; 808 return 0;
809} 809}
810 810
811static int pl2303_ioctl(struct tty_struct *tty, 811static int pl2303_get_serial(struct tty_struct *tty,
812 unsigned int cmd, unsigned long arg) 812 struct serial_struct *ss)
813{ 813{
814 struct serial_struct ser;
815 struct usb_serial_port *port = tty->driver_data; 814 struct usb_serial_port *port = tty->driver_data;
816 815
817 switch (cmd) { 816 ss->type = PORT_16654;
818 case TIOCGSERIAL: 817 ss->line = port->minor;
819 memset(&ser, 0, sizeof ser); 818 ss->port = port->port_number;
820 ser.type = PORT_16654; 819 ss->baud_base = 460800;
821 ser.line = port->minor; 820 return 0;
822 ser.port = port->port_number;
823 ser.baud_base = 460800;
824
825 if (copy_to_user((void __user *)arg, &ser, sizeof ser))
826 return -EFAULT;
827
828 return 0;
829 default:
830 break;
831 }
832
833 return -ENOIOCTLCMD;
834} 821}
835 822
836static void pl2303_set_break(struct usb_serial_port *port, bool enable) 823static void pl2303_set_break(struct usb_serial_port *port, bool enable)
@@ -1016,7 +1003,7 @@ static struct usb_serial_driver pl2303_device = {
1016 .close = pl2303_close, 1003 .close = pl2303_close,
1017 .dtr_rts = pl2303_dtr_rts, 1004 .dtr_rts = pl2303_dtr_rts,
1018 .carrier_raised = pl2303_carrier_raised, 1005 .carrier_raised = pl2303_carrier_raised,
1019 .ioctl = pl2303_ioctl, 1006 .get_serial = pl2303_get_serial,
1020 .break_ctl = pl2303_break_ctl, 1007 .break_ctl = pl2303_break_ctl,
1021 .set_termios = pl2303_set_termios, 1008 .set_termios = pl2303_set_termios,
1022 .tiocmget = pl2303_tiocmget, 1009 .tiocmget = pl2303_tiocmget,
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index b61c2a9b6b11..f2fbe1ec9701 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -453,39 +453,19 @@ static void qt2_disconnect(struct usb_serial *serial)
453 usb_kill_urb(serial_priv->read_urb); 453 usb_kill_urb(serial_priv->read_urb);
454} 454}
455 455
456static int get_serial_info(struct usb_serial_port *port, 456static int get_serial_info(struct tty_struct *tty,
457 struct serial_struct __user *retinfo) 457 struct serial_struct *ss)
458{
459 struct serial_struct tmp;
460
461 memset(&tmp, 0, sizeof(tmp));
462 tmp.line = port->minor;
463 tmp.port = 0;
464 tmp.irq = 0;
465 tmp.xmit_fifo_size = port->bulk_out_size;
466 tmp.baud_base = 9600;
467 tmp.close_delay = 5*HZ;
468 tmp.closing_wait = 30*HZ;
469
470 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
471 return -EFAULT;
472 return 0;
473}
474
475static int qt2_ioctl(struct tty_struct *tty,
476 unsigned int cmd, unsigned long arg)
477{ 458{
478 struct usb_serial_port *port = tty->driver_data; 459 struct usb_serial_port *port = tty->driver_data;
479 460
480 switch (cmd) { 461 ss->line = port->minor;
481 case TIOCGSERIAL: 462 ss->port = 0;
482 return get_serial_info(port, 463 ss->irq = 0;
483 (struct serial_struct __user *)arg); 464 ss->xmit_fifo_size = port->bulk_out_size;
484 default: 465 ss->baud_base = 9600;
485 break; 466 ss->close_delay = 5*HZ;
486 } 467 ss->closing_wait = 30*HZ;
487 468 return 0;
488 return -ENOIOCTLCMD;
489} 469}
490 470
491static void qt2_process_status(struct usb_serial_port *port, unsigned char *ch) 471static void qt2_process_status(struct usb_serial_port *port, unsigned char *ch)
@@ -1013,7 +993,7 @@ static struct usb_serial_driver qt2_device = {
1013 .tiocmset = qt2_tiocmset, 993 .tiocmset = qt2_tiocmset,
1014 .tiocmiwait = usb_serial_generic_tiocmiwait, 994 .tiocmiwait = usb_serial_generic_tiocmiwait,
1015 .get_icount = usb_serial_generic_get_icount, 995 .get_icount = usb_serial_generic_get_icount,
1016 .ioctl = qt2_ioctl, 996 .get_serial = get_serial_info,
1017 .set_termios = qt2_set_termios, 997 .set_termios = qt2_set_termios,
1018}; 998};
1019 999
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 0900b47b5f57..f6aea9f1be1a 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -331,39 +331,19 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)
331 return usb_serial_generic_open(tty, port); 331 return usb_serial_generic_open(tty, port);
332} 332}
333 333
334static int get_serial_info(struct usb_serial_port *port, 334static int get_serial_info(struct tty_struct *tty,
335 struct serial_struct __user *retinfo) 335 struct serial_struct *ss)
336{
337 struct serial_struct tmp;
338
339 memset(&tmp, 0, sizeof(tmp));
340 tmp.line = port->minor;
341 tmp.port = 0;
342 tmp.irq = 0;
343 tmp.xmit_fifo_size = port->bulk_out_size;
344 tmp.baud_base = 9600;
345 tmp.close_delay = 5*HZ;
346 tmp.closing_wait = 30*HZ;
347
348 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
349 return -EFAULT;
350 return 0;
351}
352
353static int ssu100_ioctl(struct tty_struct *tty,
354 unsigned int cmd, unsigned long arg)
355{ 336{
356 struct usb_serial_port *port = tty->driver_data; 337 struct usb_serial_port *port = tty->driver_data;
357 338
358 switch (cmd) { 339 ss->line = port->minor;
359 case TIOCGSERIAL: 340 ss->port = 0;
360 return get_serial_info(port, 341 ss->irq = 0;
361 (struct serial_struct __user *) arg); 342 ss->xmit_fifo_size = port->bulk_out_size;
362 default: 343 ss->baud_base = 9600;
363 break; 344 ss->close_delay = 5*HZ;
364 } 345 ss->closing_wait = 30*HZ;
365 346 return 0;
366 return -ENOIOCTLCMD;
367} 347}
368 348
369static int ssu100_attach(struct usb_serial *serial) 349static int ssu100_attach(struct usb_serial *serial)
@@ -566,7 +546,7 @@ static struct usb_serial_driver ssu100_device = {
566 .tiocmset = ssu100_tiocmset, 546 .tiocmset = ssu100_tiocmset,
567 .tiocmiwait = usb_serial_generic_tiocmiwait, 547 .tiocmiwait = usb_serial_generic_tiocmiwait,
568 .get_icount = usb_serial_generic_get_icount, 548 .get_icount = usb_serial_generic_get_icount,
569 .ioctl = ssu100_ioctl, 549 .get_serial = get_serial_info,
570 .set_termios = ssu100_set_termios, 550 .set_termios = ssu100_set_termios,
571}; 551};
572 552
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index e3c5832337e0..dd0ad67aa71e 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -313,8 +313,6 @@ static int ti_chars_in_buffer(struct tty_struct *tty);
313static bool ti_tx_empty(struct usb_serial_port *port); 313static bool ti_tx_empty(struct usb_serial_port *port);
314static void ti_throttle(struct tty_struct *tty); 314static void ti_throttle(struct tty_struct *tty);
315static void ti_unthrottle(struct tty_struct *tty); 315static void ti_unthrottle(struct tty_struct *tty);
316static int ti_ioctl(struct tty_struct *tty,
317 unsigned int cmd, unsigned long arg);
318static void ti_set_termios(struct tty_struct *tty, 316static void ti_set_termios(struct tty_struct *tty,
319 struct usb_serial_port *port, struct ktermios *old_termios); 317 struct usb_serial_port *port, struct ktermios *old_termios);
320static int ti_tiocmget(struct tty_struct *tty); 318static int ti_tiocmget(struct tty_struct *tty);
@@ -330,10 +328,10 @@ static void ti_recv(struct usb_serial_port *port, unsigned char *data,
330static void ti_send(struct ti_port *tport); 328static void ti_send(struct ti_port *tport);
331static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); 329static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
332static int ti_get_lsr(struct ti_port *tport, u8 *lsr); 330static int ti_get_lsr(struct ti_port *tport, u8 *lsr);
333static int ti_get_serial_info(struct ti_port *tport, 331static int ti_get_serial_info(struct tty_struct *tty,
334 struct serial_struct __user *ret_arg); 332 struct serial_struct *ss);
335static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, 333static int ti_set_serial_info(struct tty_struct *tty,
336 struct serial_struct __user *new_arg); 334 struct serial_struct *ss);
337static void ti_handle_new_msr(struct ti_port *tport, u8 msr); 335static void ti_handle_new_msr(struct ti_port *tport, u8 msr);
338 336
339static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty); 337static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty);
@@ -436,7 +434,8 @@ static struct usb_serial_driver ti_1port_device = {
436 .tx_empty = ti_tx_empty, 434 .tx_empty = ti_tx_empty,
437 .throttle = ti_throttle, 435 .throttle = ti_throttle,
438 .unthrottle = ti_unthrottle, 436 .unthrottle = ti_unthrottle,
439 .ioctl = ti_ioctl, 437 .get_serial = ti_get_serial_info,
438 .set_serial = ti_set_serial_info,
440 .set_termios = ti_set_termios, 439 .set_termios = ti_set_termios,
441 .tiocmget = ti_tiocmget, 440 .tiocmget = ti_tiocmget,
442 .tiocmset = ti_tiocmset, 441 .tiocmset = ti_tiocmset,
@@ -469,7 +468,8 @@ static struct usb_serial_driver ti_2port_device = {
469 .tx_empty = ti_tx_empty, 468 .tx_empty = ti_tx_empty,
470 .throttle = ti_throttle, 469 .throttle = ti_throttle,
471 .unthrottle = ti_unthrottle, 470 .unthrottle = ti_unthrottle,
472 .ioctl = ti_ioctl, 471 .get_serial = ti_get_serial_info,
472 .set_serial = ti_set_serial_info,
473 .set_termios = ti_set_termios, 473 .set_termios = ti_set_termios,
474 .tiocmget = ti_tiocmget, 474 .tiocmget = ti_tiocmget,
475 .tiocmset = ti_tiocmset, 475 .tiocmset = ti_tiocmset,
@@ -902,24 +902,6 @@ static void ti_unthrottle(struct tty_struct *tty)
902 } 902 }
903} 903}
904 904
905static int ti_ioctl(struct tty_struct *tty,
906 unsigned int cmd, unsigned long arg)
907{
908 struct usb_serial_port *port = tty->driver_data;
909 struct ti_port *tport = usb_get_serial_port_data(port);
910
911 switch (cmd) {
912 case TIOCGSERIAL:
913 return ti_get_serial_info(tport,
914 (struct serial_struct __user *)arg);
915 case TIOCSSERIAL:
916 return ti_set_serial_info(tty, tport,
917 (struct serial_struct __user *)arg);
918 }
919 return -ENOIOCTLCMD;
920}
921
922
923static void ti_set_termios(struct tty_struct *tty, 905static void ti_set_termios(struct tty_struct *tty,
924 struct usb_serial_port *port, struct ktermios *old_termios) 906 struct usb_serial_port *port, struct ktermios *old_termios)
925{ 907{
@@ -1417,45 +1399,37 @@ free_data:
1417} 1399}
1418 1400
1419 1401
1420static int ti_get_serial_info(struct ti_port *tport, 1402static int ti_get_serial_info(struct tty_struct *tty,
1421 struct serial_struct __user *ret_arg) 1403 struct serial_struct *ss)
1422{ 1404{
1423 struct usb_serial_port *port = tport->tp_port; 1405 struct usb_serial_port *port = tty->driver_data;
1424 struct serial_struct ret_serial; 1406 struct ti_port *tport = usb_get_serial_port_data(port);
1425 unsigned cwait; 1407 unsigned cwait;
1426 1408
1427 cwait = port->port.closing_wait; 1409 cwait = port->port.closing_wait;
1428 if (cwait != ASYNC_CLOSING_WAIT_NONE) 1410 if (cwait != ASYNC_CLOSING_WAIT_NONE)
1429 cwait = jiffies_to_msecs(cwait) / 10; 1411 cwait = jiffies_to_msecs(cwait) / 10;
1430 1412
1431 memset(&ret_serial, 0, sizeof(ret_serial)); 1413 ss->type = PORT_16550A;
1432 1414 ss->line = port->minor;
1433 ret_serial.type = PORT_16550A; 1415 ss->port = port->port_number;
1434 ret_serial.line = port->minor; 1416 ss->xmit_fifo_size = kfifo_size(&port->write_fifo);
1435 ret_serial.port = port->port_number; 1417 ss->baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800;
1436 ret_serial.xmit_fifo_size = kfifo_size(&port->write_fifo); 1418 ss->closing_wait = cwait;
1437 ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800;
1438 ret_serial.closing_wait = cwait;
1439
1440 if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg)))
1441 return -EFAULT;
1442
1443 return 0; 1419 return 0;
1444} 1420}
1445 1421
1446 1422
1447static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, 1423static int ti_set_serial_info(struct tty_struct *tty,
1448 struct serial_struct __user *new_arg) 1424 struct serial_struct *ss)
1449{ 1425{
1450 struct serial_struct new_serial; 1426 struct usb_serial_port *port = tty->driver_data;
1427 struct ti_port *tport = usb_get_serial_port_data(port);
1451 unsigned cwait; 1428 unsigned cwait;
1452 1429
1453 if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) 1430 cwait = ss->closing_wait;
1454 return -EFAULT;
1455
1456 cwait = new_serial.closing_wait;
1457 if (cwait != ASYNC_CLOSING_WAIT_NONE) 1431 if (cwait != ASYNC_CLOSING_WAIT_NONE)
1458 cwait = msecs_to_jiffies(10 * new_serial.closing_wait); 1432 cwait = msecs_to_jiffies(10 * ss->closing_wait);
1459 1433
1460 tport->tp_port->port.closing_wait = cwait; 1434 tport->tp_port->port.closing_wait = cwait;
1461 1435
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index f7aaa7f079e1..7e89efbf2c28 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -396,6 +396,24 @@ static void serial_unthrottle(struct tty_struct *tty)
396 port->serial->type->unthrottle(tty); 396 port->serial->type->unthrottle(tty);
397} 397}
398 398
399static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss)
400{
401 struct usb_serial_port *port = tty->driver_data;
402
403 if (port->serial->type->get_serial)
404 return port->serial->type->get_serial(tty, ss);
405 return -ENOTTY;
406}
407
408static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss)
409{
410 struct usb_serial_port *port = tty->driver_data;
411
412 if (port->serial->type->set_serial)
413 return port->serial->type->set_serial(tty, ss);
414 return -ENOTTY;
415}
416
399static int serial_ioctl(struct tty_struct *tty, 417static int serial_ioctl(struct tty_struct *tty,
400 unsigned int cmd, unsigned long arg) 418 unsigned int cmd, unsigned long arg)
401{ 419{
@@ -1177,6 +1195,8 @@ static const struct tty_operations serial_ops = {
1177 .tiocmget = serial_tiocmget, 1195 .tiocmget = serial_tiocmget,
1178 .tiocmset = serial_tiocmset, 1196 .tiocmset = serial_tiocmset,
1179 .get_icount = serial_get_icount, 1197 .get_icount = serial_get_icount,
1198 .set_serial = serial_set_serial,
1199 .get_serial = serial_get_serial,
1180 .cleanup = serial_cleanup, 1200 .cleanup = serial_cleanup,
1181 .install = serial_install, 1201 .install = serial_install,
1182 .proc_show = serial_proc_show, 1202 .proc_show = serial_proc_show,
diff --git a/drivers/usb/serial/usb-wwan.h b/drivers/usb/serial/usb-wwan.h
index d28dab4b9eff..1c120eaf4091 100644
--- a/drivers/usb/serial/usb-wwan.h
+++ b/drivers/usb/serial/usb-wwan.h
@@ -15,8 +15,10 @@ extern int usb_wwan_write_room(struct tty_struct *tty);
15extern int usb_wwan_tiocmget(struct tty_struct *tty); 15extern int usb_wwan_tiocmget(struct tty_struct *tty);
16extern int usb_wwan_tiocmset(struct tty_struct *tty, 16extern int usb_wwan_tiocmset(struct tty_struct *tty,
17 unsigned int set, unsigned int clear); 17 unsigned int set, unsigned int clear);
18extern int usb_wwan_ioctl(struct tty_struct *tty, 18extern int usb_wwan_get_serial_info(struct tty_struct *tty,
19 unsigned int cmd, unsigned long arg); 19 struct serial_struct *ss);
20extern int usb_wwan_set_serial_info(struct tty_struct *tty,
21 struct serial_struct *ss);
20extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, 22extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
21 const unsigned char *buf, int count); 23 const unsigned char *buf, int count);
22extern int usb_wwan_chars_in_buffer(struct tty_struct *tty); 24extern int usb_wwan_chars_in_buffer(struct tty_struct *tty);
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 912472f26e4f..7e855c87e4f7 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -132,38 +132,32 @@ int usb_wwan_tiocmset(struct tty_struct *tty,
132} 132}
133EXPORT_SYMBOL(usb_wwan_tiocmset); 133EXPORT_SYMBOL(usb_wwan_tiocmset);
134 134
135static int get_serial_info(struct usb_serial_port *port, 135int usb_wwan_get_serial_info(struct tty_struct *tty,
136 struct serial_struct __user *retinfo) 136 struct serial_struct *ss)
137{ 137{
138 struct serial_struct tmp; 138 struct usb_serial_port *port = tty->driver_data;
139 139
140 memset(&tmp, 0, sizeof(tmp)); 140 ss->line = port->minor;
141 tmp.line = port->minor; 141 ss->port = port->port_number;
142 tmp.port = port->port_number; 142 ss->baud_base = tty_get_baud_rate(port->port.tty);
143 tmp.baud_base = tty_get_baud_rate(port->port.tty); 143 ss->close_delay = port->port.close_delay / 10;
144 tmp.close_delay = port->port.close_delay / 10; 144 ss->closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
145 tmp.closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
146 ASYNC_CLOSING_WAIT_NONE : 145 ASYNC_CLOSING_WAIT_NONE :
147 port->port.closing_wait / 10; 146 port->port.closing_wait / 10;
148
149 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
150 return -EFAULT;
151 return 0; 147 return 0;
152} 148}
149EXPORT_SYMBOL(usb_wwan_get_serial_info);
153 150
154static int set_serial_info(struct usb_serial_port *port, 151int usb_wwan_set_serial_info(struct tty_struct *tty,
155 struct serial_struct __user *newinfo) 152 struct serial_struct *ss)
156{ 153{
157 struct serial_struct new_serial; 154 struct usb_serial_port *port = tty->driver_data;
158 unsigned int closing_wait, close_delay; 155 unsigned int closing_wait, close_delay;
159 int retval = 0; 156 int retval = 0;
160 157
161 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 158 close_delay = ss->close_delay * 10;
162 return -EFAULT; 159 closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ?
163 160 ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10;
164 close_delay = new_serial.close_delay * 10;
165 closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
166 ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
167 161
168 mutex_lock(&port->port.mutex); 162 mutex_lock(&port->port.mutex);
169 163
@@ -181,30 +175,7 @@ static int set_serial_info(struct usb_serial_port *port,
181 mutex_unlock(&port->port.mutex); 175 mutex_unlock(&port->port.mutex);
182 return retval; 176 return retval;
183} 177}
184 178EXPORT_SYMBOL(usb_wwan_set_serial_info);
185int usb_wwan_ioctl(struct tty_struct *tty,
186 unsigned int cmd, unsigned long arg)
187{
188 struct usb_serial_port *port = tty->driver_data;
189
190 dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
191
192 switch (cmd) {
193 case TIOCGSERIAL:
194 return get_serial_info(port,
195 (struct serial_struct __user *) arg);
196 case TIOCSSERIAL:
197 return set_serial_info(port,
198 (struct serial_struct __user *) arg);
199 default:
200 break;
201 }
202
203 dev_dbg(&port->dev, "%s arg not supported\n", __func__);
204
205 return -ENOIOCTLCMD;
206}
207EXPORT_SYMBOL(usb_wwan_ioctl);
208 179
209int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, 180int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
210 const unsigned char *buf, int count) 181 const unsigned char *buf, int count)
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 1c7b46a8620c..aefd84f88b59 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -83,8 +83,8 @@ static int whiteheat_port_remove(struct usb_serial_port *port);
83static int whiteheat_open(struct tty_struct *tty, 83static int whiteheat_open(struct tty_struct *tty,
84 struct usb_serial_port *port); 84 struct usb_serial_port *port);
85static void whiteheat_close(struct usb_serial_port *port); 85static void whiteheat_close(struct usb_serial_port *port);
86static int whiteheat_ioctl(struct tty_struct *tty, 86static int whiteheat_get_serial(struct tty_struct *tty,
87 unsigned int cmd, unsigned long arg); 87 struct serial_struct *ss);
88static void whiteheat_set_termios(struct tty_struct *tty, 88static void whiteheat_set_termios(struct tty_struct *tty,
89 struct usb_serial_port *port, struct ktermios *old); 89 struct usb_serial_port *port, struct ktermios *old);
90static int whiteheat_tiocmget(struct tty_struct *tty); 90static int whiteheat_tiocmget(struct tty_struct *tty);
@@ -120,7 +120,7 @@ static struct usb_serial_driver whiteheat_device = {
120 .port_remove = whiteheat_port_remove, 120 .port_remove = whiteheat_port_remove,
121 .open = whiteheat_open, 121 .open = whiteheat_open,
122 .close = whiteheat_close, 122 .close = whiteheat_close,
123 .ioctl = whiteheat_ioctl, 123 .get_serial = whiteheat_get_serial,
124 .set_termios = whiteheat_set_termios, 124 .set_termios = whiteheat_set_termios,
125 .break_ctl = whiteheat_break_ctl, 125 .break_ctl = whiteheat_break_ctl,
126 .tiocmget = whiteheat_tiocmget, 126 .tiocmget = whiteheat_tiocmget,
@@ -442,33 +442,21 @@ static int whiteheat_tiocmset(struct tty_struct *tty,
442} 442}
443 443
444 444
445static int whiteheat_ioctl(struct tty_struct *tty, 445static int whiteheat_get_serial(struct tty_struct *tty,
446 unsigned int cmd, unsigned long arg) 446 struct serial_struct *ss)
447{ 447{
448 struct usb_serial_port *port = tty->driver_data; 448 struct usb_serial_port *port = tty->driver_data;
449 struct serial_struct serstruct;
450 void __user *user_arg = (void __user *)arg;
451
452 switch (cmd) {
453 case TIOCGSERIAL:
454 memset(&serstruct, 0, sizeof(serstruct));
455 serstruct.type = PORT_16654;
456 serstruct.line = port->minor;
457 serstruct.port = port->port_number;
458 serstruct.xmit_fifo_size = kfifo_size(&port->write_fifo);
459 serstruct.custom_divisor = 0;
460 serstruct.baud_base = 460800;
461 serstruct.close_delay = CLOSING_DELAY;
462 serstruct.closing_wait = CLOSING_DELAY;
463
464 if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
465 return -EFAULT;
466 break;
467 default:
468 break;
469 }
470 449
471 return -ENOIOCTLCMD; 450 ss->type = PORT_16654;
451 ss->line = port->minor;
452 ss->port = port->port_number;
453 ss->xmit_fifo_size = kfifo_size(&port->write_fifo);
454 ss->custom_divisor = 0;
455 ss->baud_base = 460800;
456 ss->close_delay = CLOSING_DELAY;
457 ss->closing_wait = CLOSING_DELAY;
458
459 return 0;
472} 460}
473 461
474 462
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a9b00942e87d..0c445a03e682 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -560,69 +560,6 @@ static int mt_ioctl_trans(struct file *file,
560#define HIDPGETCONNLIST _IOR('H', 210, int) 560#define HIDPGETCONNLIST _IOR('H', 210, int)
561#define HIDPGETCONNINFO _IOR('H', 211, int) 561#define HIDPGETCONNINFO _IOR('H', 211, int)
562 562
563
564struct serial_struct32 {
565 compat_int_t type;
566 compat_int_t line;
567 compat_uint_t port;
568 compat_int_t irq;
569 compat_int_t flags;
570 compat_int_t xmit_fifo_size;
571 compat_int_t custom_divisor;
572 compat_int_t baud_base;
573 unsigned short close_delay;
574 char io_type;
575 char reserved_char[1];
576 compat_int_t hub6;
577 unsigned short closing_wait; /* time to wait before closing */
578 unsigned short closing_wait2; /* no longer used... */
579 compat_uint_t iomem_base;
580 unsigned short iomem_reg_shift;
581 unsigned int port_high;
582 /* compat_ulong_t iomap_base FIXME */
583 compat_int_t reserved[1];
584};
585
586static int serial_struct_ioctl(struct file *file,
587 unsigned cmd, struct serial_struct32 __user *ss32)
588{
589 typedef struct serial_struct32 SS32;
590 int err;
591 struct serial_struct __user *ss = compat_alloc_user_space(sizeof(*ss));
592 __u32 udata;
593 unsigned int base;
594 unsigned char *iomem_base;
595
596 if (ss == NULL)
597 return -EFAULT;
598 if (cmd == TIOCSSERIAL) {
599 if (copy_in_user(ss, ss32, offsetof(SS32, iomem_base)) ||
600 get_user(udata, &ss32->iomem_base))
601 return -EFAULT;
602 iomem_base = compat_ptr(udata);
603 if (put_user(iomem_base, &ss->iomem_base) ||
604 convert_in_user(&ss32->iomem_reg_shift,
605 &ss->iomem_reg_shift) ||
606 convert_in_user(&ss32->port_high, &ss->port_high) ||
607 put_user(0UL, &ss->iomap_base))
608 return -EFAULT;
609 }
610 err = do_ioctl(file, cmd, (unsigned long)ss);
611 if (cmd == TIOCGSERIAL && err >= 0) {
612 if (copy_in_user(ss32, ss, offsetof(SS32, iomem_base)) ||
613 get_user(iomem_base, &ss->iomem_base))
614 return -EFAULT;
615 base = (unsigned long)iomem_base >> 32 ?
616 0xffffffff : (unsigned)(unsigned long)iomem_base;
617 if (put_user(base, &ss32->iomem_base) ||
618 convert_in_user(&ss->iomem_reg_shift,
619 &ss32->iomem_reg_shift) ||
620 convert_in_user(&ss->port_high, &ss32->port_high))
621 return -EFAULT;
622 }
623 return err;
624}
625
626#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) 563#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
627#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) 564#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
628#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) 565#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
@@ -707,60 +644,8 @@ static int compat_ioctl_preallocate(struct file *file,
707 644
708static unsigned int ioctl_pointer[] = { 645static unsigned int ioctl_pointer[] = {
709/* compatible ioctls first */ 646/* compatible ioctls first */
710COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
711COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
712
713/* Big T */
714COMPATIBLE_IOCTL(TCGETA)
715COMPATIBLE_IOCTL(TCSETA)
716COMPATIBLE_IOCTL(TCSETAW)
717COMPATIBLE_IOCTL(TCSETAF)
718COMPATIBLE_IOCTL(TCSBRK)
719COMPATIBLE_IOCTL(TCXONC)
720COMPATIBLE_IOCTL(TCFLSH)
721COMPATIBLE_IOCTL(TCGETS)
722COMPATIBLE_IOCTL(TCSETS)
723COMPATIBLE_IOCTL(TCSETSW)
724COMPATIBLE_IOCTL(TCSETSF)
725COMPATIBLE_IOCTL(TIOCLINUX)
726COMPATIBLE_IOCTL(TIOCSBRK)
727COMPATIBLE_IOCTL(TIOCGDEV)
728COMPATIBLE_IOCTL(TIOCCBRK)
729COMPATIBLE_IOCTL(TIOCGSID)
730COMPATIBLE_IOCTL(TIOCGICOUNT)
731COMPATIBLE_IOCTL(TIOCGEXCL)
732/* Little t */ 647/* Little t */
733COMPATIBLE_IOCTL(TIOCGETD)
734COMPATIBLE_IOCTL(TIOCSETD)
735COMPATIBLE_IOCTL(TIOCEXCL)
736COMPATIBLE_IOCTL(TIOCNXCL)
737COMPATIBLE_IOCTL(TIOCCONS)
738COMPATIBLE_IOCTL(TIOCGSOFTCAR)
739COMPATIBLE_IOCTL(TIOCSSOFTCAR)
740COMPATIBLE_IOCTL(TIOCSWINSZ)
741COMPATIBLE_IOCTL(TIOCGWINSZ)
742COMPATIBLE_IOCTL(TIOCMGET)
743COMPATIBLE_IOCTL(TIOCMBIC)
744COMPATIBLE_IOCTL(TIOCMBIS)
745COMPATIBLE_IOCTL(TIOCMSET)
746COMPATIBLE_IOCTL(TIOCNOTTY)
747COMPATIBLE_IOCTL(TIOCSTI)
748COMPATIBLE_IOCTL(TIOCOUTQ) 648COMPATIBLE_IOCTL(TIOCOUTQ)
749COMPATIBLE_IOCTL(TIOCSPGRP)
750COMPATIBLE_IOCTL(TIOCGPGRP)
751COMPATIBLE_IOCTL(TIOCSERGETLSR)
752#ifdef TIOCSRS485
753COMPATIBLE_IOCTL(TIOCSRS485)
754#endif
755#ifdef TIOCGRS485
756COMPATIBLE_IOCTL(TIOCGRS485)
757#endif
758#ifdef TCGETS2
759COMPATIBLE_IOCTL(TCGETS2)
760COMPATIBLE_IOCTL(TCSETS2)
761COMPATIBLE_IOCTL(TCSETSW2)
762COMPATIBLE_IOCTL(TCSETSF2)
763#endif
764/* Little f */ 649/* Little f */
765COMPATIBLE_IOCTL(FIOCLEX) 650COMPATIBLE_IOCTL(FIOCLEX)
766COMPATIBLE_IOCTL(FIONCLEX) 651COMPATIBLE_IOCTL(FIONCLEX)
@@ -775,23 +660,6 @@ COMPATIBLE_IOCTL(FIGETBSZ)
775COMPATIBLE_IOCTL(FIFREEZE) 660COMPATIBLE_IOCTL(FIFREEZE)
776COMPATIBLE_IOCTL(FITHAW) 661COMPATIBLE_IOCTL(FITHAW)
777COMPATIBLE_IOCTL(FITRIM) 662COMPATIBLE_IOCTL(FITRIM)
778COMPATIBLE_IOCTL(KDGETKEYCODE)
779COMPATIBLE_IOCTL(KDSETKEYCODE)
780COMPATIBLE_IOCTL(KDGKBTYPE)
781COMPATIBLE_IOCTL(KDGETMODE)
782COMPATIBLE_IOCTL(KDGKBMODE)
783COMPATIBLE_IOCTL(KDGKBMETA)
784COMPATIBLE_IOCTL(KDGKBENT)
785COMPATIBLE_IOCTL(KDSKBENT)
786COMPATIBLE_IOCTL(KDGKBSENT)
787COMPATIBLE_IOCTL(KDSKBSENT)
788COMPATIBLE_IOCTL(KDGKBDIACR)
789COMPATIBLE_IOCTL(KDSKBDIACR)
790COMPATIBLE_IOCTL(KDGKBDIACRUC)
791COMPATIBLE_IOCTL(KDSKBDIACRUC)
792COMPATIBLE_IOCTL(KDKBDREP)
793COMPATIBLE_IOCTL(KDGKBLED)
794COMPATIBLE_IOCTL(KDGETLED)
795#ifdef CONFIG_BLOCK 663#ifdef CONFIG_BLOCK
796/* Big S */ 664/* Big S */
797COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) 665COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
@@ -1133,11 +1001,6 @@ COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
1133COMPATIBLE_IOCTL(CAPI_CLR_FLAGS) 1001COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
1134COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT) 1002COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
1135COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT) 1003COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
1136/* Siemens Gigaset */
1137COMPATIBLE_IOCTL(GIGASET_REDIR)
1138COMPATIBLE_IOCTL(GIGASET_CONFIG)
1139COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
1140COMPATIBLE_IOCTL(GIGASET_VERSION)
1141/* Misc. */ 1004/* Misc. */
1142COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */ 1005COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
1143COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */ 1006COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
@@ -1223,21 +1086,6 @@ COMPATIBLE_IOCTL(JSIOCGAXES)
1223COMPATIBLE_IOCTL(JSIOCGBUTTONS) 1086COMPATIBLE_IOCTL(JSIOCGBUTTONS)
1224COMPATIBLE_IOCTL(JSIOCGNAME(0)) 1087COMPATIBLE_IOCTL(JSIOCGNAME(0))
1225 1088
1226#ifdef TIOCGLTC
1227COMPATIBLE_IOCTL(TIOCGLTC)
1228COMPATIBLE_IOCTL(TIOCSLTC)
1229#endif
1230#ifdef TIOCSTART
1231/*
1232 * For these two we have definitions in ioctls.h and/or termios.h on
1233 * some architectures but no actual implemention. Some applications
1234 * like bash call them if they are defined in the headers, so we provide
1235 * entries here to avoid syslog message spew.
1236 */
1237COMPATIBLE_IOCTL(TIOCSTART)
1238COMPATIBLE_IOCTL(TIOCSTOP)
1239#endif
1240
1241/* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, 1089/* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
1242 but we don't want warnings on other file systems. So declare 1090 but we don't want warnings on other file systems. So declare
1243 them as compatible here. */ 1091 them as compatible here. */
@@ -1293,10 +1141,6 @@ static long do_ioctl_trans(unsigned int cmd,
1293 case MTIOCPOS32: 1141 case MTIOCPOS32:
1294 return mt_ioctl_trans(file, cmd, argp); 1142 return mt_ioctl_trans(file, cmd, argp);
1295#endif 1143#endif
1296 /* Serial */
1297 case TIOCGSERIAL:
1298 case TIOCSSERIAL:
1299 return serial_struct_ioctl(file, cmd, argp);
1300 /* Not implemented in the native kernel */ 1144 /* Not implemented in the native kernel */
1301 case RTC_IRQP_READ32: 1145 case RTC_IRQP_READ32:
1302 case RTC_IRQP_SET32: 1146 case RTC_IRQP_SET32:
@@ -1316,24 +1160,11 @@ static long do_ioctl_trans(unsigned int cmd,
1316 * so we must not do a compat_ptr() translation. 1160 * so we must not do a compat_ptr() translation.
1317 */ 1161 */
1318 switch (cmd) { 1162 switch (cmd) {
1319 /* Big T */
1320 case TCSBRKP:
1321 case TIOCMIWAIT:
1322 case TIOCSCTTY:
1323 /* RAID */ 1163 /* RAID */
1324 case HOT_REMOVE_DISK: 1164 case HOT_REMOVE_DISK:
1325 case HOT_ADD_DISK: 1165 case HOT_ADD_DISK:
1326 case SET_DISK_FAULTY: 1166 case SET_DISK_FAULTY:
1327 case SET_BITMAP_FILE: 1167 case SET_BITMAP_FILE:
1328 /* Big K */
1329 case KDSIGACCEPT:
1330 case KIOCSOUND:
1331 case KDMKTONE:
1332 case KDSETMODE:
1333 case KDSKBMODE:
1334 case KDSKBMETA:
1335 case KDSKBLED:
1336 case KDSETLED:
1337 return vfs_ioctl(file, cmd, arg); 1168 return vfs_ioctl(file, cmd, arg);
1338 } 1169 }
1339 1170
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c56e3978b00f..414db2bce715 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -746,8 +746,6 @@ static inline int tty_audit_push(void)
746/* tty_ioctl.c */ 746/* tty_ioctl.c */
747extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, 747extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
748 unsigned int cmd, unsigned long arg); 748 unsigned int cmd, unsigned long arg);
749extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
750 unsigned int cmd, unsigned long arg);
751 749
752/* vt.c */ 750/* vt.c */
753 751
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 71dbc891851a..358446247ccd 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -249,6 +249,7 @@
249struct tty_struct; 249struct tty_struct;
250struct tty_driver; 250struct tty_driver;
251struct serial_icounter_struct; 251struct serial_icounter_struct;
252struct serial_struct;
252 253
253struct tty_operations { 254struct tty_operations {
254 struct tty_struct * (*lookup)(struct tty_driver *driver, 255 struct tty_struct * (*lookup)(struct tty_driver *driver,
@@ -287,6 +288,8 @@ struct tty_operations {
287 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); 288 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);
288 int (*get_icount)(struct tty_struct *tty, 289 int (*get_icount)(struct tty_struct *tty,
289 struct serial_icounter_struct *icount); 290 struct serial_icounter_struct *icount);
291 int (*get_serial)(struct tty_struct *tty, struct serial_struct *p);
292 int (*set_serial)(struct tty_struct *tty, struct serial_struct *p);
290 void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); 293 void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m);
291#ifdef CONFIG_CONSOLE_POLL 294#ifdef CONFIG_CONSOLE_POLL
292 int (*poll_init)(struct tty_driver *driver, int line, char *options); 295 int (*poll_init)(struct tty_driver *driver, int line, char *options);
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 840894ca3fc0..b1e6043e9917 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -54,11 +54,17 @@
54 * low-level driver can "grab" an ioctl request before the line 54 * low-level driver can "grab" an ioctl request before the line
55 * discpline has a chance to see it. 55 * discpline has a chance to see it.
56 * 56 *
57 * long (*compat_ioctl)(struct tty_struct * tty, struct file * file, 57 * int (*compat_ioctl)(struct tty_struct * tty, struct file * file,
58 * unsigned int cmd, unsigned long arg); 58 * unsigned int cmd, unsigned long arg);
59 * 59 *
60 * Process ioctl calls from 32-bit process on 64-bit system 60 * Process ioctl calls from 32-bit process on 64-bit system
61 * 61 *
62 * NOTE: only ioctls that are neither "pointer to compatible
63 * structure" nor tty-generic. Something private that takes
64 * an integer or a pointer to wordsize-sensitive structure
65 * belongs here, but most of ldiscs will happily leave
66 * it NULL.
67 *
62 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 68 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
63 * 69 *
64 * This function notifies the line discpline that a change has 70 * This function notifies the line discpline that a change has
@@ -184,7 +190,7 @@ struct tty_ldisc_ops {
184 const unsigned char *buf, size_t nr); 190 const unsigned char *buf, size_t nr);
185 int (*ioctl)(struct tty_struct *tty, struct file *file, 191 int (*ioctl)(struct tty_struct *tty, struct file *file,
186 unsigned int cmd, unsigned long arg); 192 unsigned int cmd, unsigned long arg);
187 long (*compat_ioctl)(struct tty_struct *tty, struct file *file, 193 int (*compat_ioctl)(struct tty_struct *tty, struct file *file,
188 unsigned int cmd, unsigned long arg); 194 unsigned int cmd, unsigned long arg);
189 void (*set_termios)(struct tty_struct *tty, struct ktermios *old); 195 void (*set_termios)(struct tty_struct *tty, struct ktermios *old);
190 __poll_t (*poll)(struct tty_struct *, struct file *, 196 __poll_t (*poll)(struct tty_struct *, struct file *,
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 106551a5616e..1c19f77ed541 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -285,6 +285,8 @@ struct usb_serial_driver {
285 int (*write_room)(struct tty_struct *tty); 285 int (*write_room)(struct tty_struct *tty);
286 int (*ioctl)(struct tty_struct *tty, 286 int (*ioctl)(struct tty_struct *tty,
287 unsigned int cmd, unsigned long arg); 287 unsigned int cmd, unsigned long arg);
288 int (*get_serial)(struct tty_struct *tty, struct serial_struct *ss);
289 int (*set_serial)(struct tty_struct *tty, struct serial_struct *ss);
288 void (*set_termios)(struct tty_struct *tty, 290 void (*set_termios)(struct tty_struct *tty,
289 struct usb_serial_port *port, struct ktermios *old); 291 struct usb_serial_port *port, struct ktermios *old);
290 void (*break_ctl)(struct tty_struct *tty, int break_state); 292 void (*break_ctl)(struct tty_struct *tty, int break_state);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 5e44d842cc5d..0c7d31c6c18c 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -839,18 +839,6 @@ static int rfcomm_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned l
839 BT_DBG("TIOCMIWAIT"); 839 BT_DBG("TIOCMIWAIT");
840 break; 840 break;
841 841
842 case TIOCGSERIAL:
843 BT_ERR("TIOCGSERIAL is not supported");
844 return -ENOIOCTLCMD;
845
846 case TIOCSSERIAL:
847 BT_ERR("TIOCSSERIAL is not supported");
848 return -ENOIOCTLCMD;
849
850 case TIOCSERGSTRUCT:
851 BT_ERR("TIOCSERGSTRUCT is not supported");
852 return -ENOIOCTLCMD;
853
854 case TIOCSERGETLSR: 842 case TIOCSERGETLSR:
855 BT_ERR("TIOCSERGETLSR is not supported"); 843 BT_ERR("TIOCSERGETLSR is not supported");
856 return -ENOIOCTLCMD; 844 return -ENOIOCTLCMD;
diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index 4503937915ad..78fe622eba65 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -463,6 +463,7 @@ static struct tty_ldisc_ops nci_uart_ldisc = {
463 .receive_buf = nci_uart_tty_receive, 463 .receive_buf = nci_uart_tty_receive,
464 .write_wakeup = nci_uart_tty_wakeup, 464 .write_wakeup = nci_uart_tty_wakeup,
465 .ioctl = nci_uart_tty_ioctl, 465 .ioctl = nci_uart_tty_ioctl,
466 .compat_ioctl = nci_uart_tty_ioctl,
466}; 467};
467 468
468static int __init nci_uart_init(void) 469static int __init nci_uart_init(void)