Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull tty ioctl updates from Al Viro:
"This is the compat_ioctl work related to tty ioctls.

Quite a bit of dead code taken out, all tty-related stuff gone from
fs/compat_ioctl.c. A bunch of compat bugs fixed - some still remain,
but all more or less generic tty-related ioctls should be covered
(remaining issues are in things like driver-private ioctls in a pcmcia
serial card driver not getting properly handled in 32bit processes on
64bit host, etc)"

* 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (53 commits)
kill TIOCSERGSTRUCT
change semantics of ldisc ->compat_ioctl()
kill TIOCSER[SG]WILD
synclink_gt(): fix compat_ioctl()
pty: fix compat ioctls
compat_ioctl - kill keyboard ioctl handling
gigaset: add ->compat_ioctl()
vt_compat_ioctl(): clean up, use compat_ptr() properly
gigaset: don't try to printk userland buffer contents
dgnc: don't bother with (empty) stub for TCXONC
dgnc: leave TIOC[GS]SOFTCAR to ldisc
remove fallback to drivers for TIOCGICOUNT
dgnc: break-related ioctls won't reach ->ioctl()
kill the rest of tty COMPAT_IOCTL() entries
dgnc: TIOCM... won't reach ->ioctl()
isdn_tty: TCSBRK{,P} won't reach ->ioctl()
kill capinc_tty_ioctl()
take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()
synclink: reduce pointless checks in ->ioctl()
complete ->[sg]et_serial() switchover
...

+778 -1521
+13 -11
arch/ia64/hp/sim/simserial.c
··· 297 297 printk(KERN_INFO "simrs_unthrottle called\n"); 298 298 } 299 299 300 + static int rs_setserial(struct tty_struct *tty, struct serial_struct *ss) 301 + { 302 + return 0; 303 + } 304 + 305 + static int rs_getserial(struct tty_struct *tty, struct serial_struct *ss) 306 + { 307 + return 0; 308 + } 309 + 300 310 static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) 301 311 { 302 - if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 303 - (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && 304 - (cmd != TIOCMIWAIT)) { 312 + if ((cmd != TIOCSERCONFIG) && (cmd != TIOCMIWAIT)) { 305 313 if (tty_io_error(tty)) 306 314 return -EIO; 307 315 } 308 316 309 317 switch (cmd) { 310 - case TIOCGSERIAL: 311 - case TIOCSSERIAL: 312 - case TIOCSERGSTRUCT: 313 318 case TIOCMIWAIT: 314 319 return 0; 315 320 case TIOCSERCONFIG: 316 321 case TIOCSERGETLSR: /* Get line status register */ 317 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 324 return -ENOIOCTLCMD; 325 325 } ··· 448 448 .throttle = rs_throttle, 449 449 .unthrottle = rs_unthrottle, 450 450 .send_xchar = rs_send_xchar, 451 + .set_serial = rs_setserial, 452 + .get_serial = rs_getserial, 451 453 .hangup = rs_hangup, 452 454 .proc_show = rs_proc_show, 453 455 };
+1
drivers/bluetooth/hci_ldisc.c
··· 823 823 hci_uart_ldisc.read = hci_uart_tty_read; 824 824 hci_uart_ldisc.write = hci_uart_tty_write; 825 825 hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; 826 + hci_uart_ldisc.compat_ioctl = hci_uart_tty_ioctl; 826 827 hci_uart_ldisc.poll = hci_uart_tty_poll; 827 828 hci_uart_ldisc.receive_buf = hci_uart_tty_receive; 828 829 hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup;
+1 -1
drivers/input/serio/serport.c
··· 226 226 227 227 #ifdef CONFIG_COMPAT 228 228 #define COMPAT_SPIOCSTYPE _IOW('q', 0x01, compat_ulong_t) 229 - static long serport_ldisc_compat_ioctl(struct tty_struct *tty, 229 + static int serport_ldisc_compat_ioctl(struct tty_struct *tty, 230 230 struct file *file, 231 231 unsigned int cmd, unsigned long arg) 232 232 {
-7
drivers/isdn/capi/capi.c
··· 1155 1155 return mp->outbytes; 1156 1156 } 1157 1157 1158 - static int capinc_tty_ioctl(struct tty_struct *tty, 1159 - unsigned int cmd, unsigned long arg) 1160 - { 1161 - return -ENOIOCTLCMD; 1162 - } 1163 - 1164 1158 static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old) 1165 1159 { 1166 1160 pr_debug("capinc_tty_set_termios\n"); ··· 1230 1236 .flush_chars = capinc_tty_flush_chars, 1231 1237 .write_room = capinc_tty_write_room, 1232 1238 .chars_in_buffer = capinc_tty_chars_in_buffer, 1233 - .ioctl = capinc_tty_ioctl, 1234 1239 .set_termios = capinc_tty_set_termios, 1235 1240 .throttle = capinc_tty_throttle, 1236 1241 .unthrottle = capinc_tty_unthrottle,
+12 -1
drivers/isdn/gigaset/interface.c
··· 206 206 ? -EFAULT : 0; 207 207 if (retval >= 0) { 208 208 gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", 209 - 6, (const unsigned char *) arg); 209 + 6, buf); 210 210 retval = cs->ops->brkchars(cs, buf); 211 211 } 212 212 break; ··· 232 232 233 233 return retval; 234 234 } 235 + 236 + #ifdef CONFIG_COMPAT 237 + static 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 235 243 236 244 static int if_tiocmget(struct tty_struct *tty) 237 245 { ··· 480 472 .open = if_open, 481 473 .close = if_close, 482 474 .ioctl = if_ioctl, 475 + #ifdef CONFIG_COMPAT 476 + .compat_ioctl = if_compat_ioctl, 477 + #endif 483 478 .write = if_write, 484 479 .write_room = if_write_room, 485 480 .chars_in_buffer = if_chars_in_buffer,
-19
drivers/isdn/i4l/isdn_tty.c
··· 1412 1412 isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg) 1413 1413 { 1414 1414 modem_info *info = (modem_info *) tty->driver_data; 1415 - int retval; 1416 1415 1417 1416 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_ioctl")) 1418 1417 return -ENODEV; 1419 1418 if (tty_io_error(tty)) 1420 1419 return -EIO; 1421 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 1421 case TIOCSERGETLSR: /* Get line status register */ 1441 1422 #ifdef ISDN_DEBUG_MODEM_IOCTL 1442 1423 printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line);
-21
drivers/net/hamradio/6pack.c
··· 34 34 #include <linux/ip.h> 35 35 #include <linux/tcp.h> 36 36 #include <linux/semaphore.h> 37 - #include <linux/compat.h> 38 37 #include <linux/refcount.h> 39 38 40 39 #define SIXPACK_VERSION "Revision: 0.3.0" ··· 751 752 return err; 752 753 } 753 754 754 - #ifdef CONFIG_COMPAT 755 - static long sixpack_compat_ioctl(struct tty_struct * tty, struct file * file, 756 - unsigned int cmd, unsigned long arg) 757 - { 758 - switch (cmd) { 759 - case SIOCGIFNAME: 760 - case SIOCGIFENCAP: 761 - case SIOCSIFENCAP: 762 - case SIOCSIFHWADDR: 763 - return sixpack_ioctl(tty, file, cmd, 764 - (unsigned long)compat_ptr(arg)); 765 - } 766 - 767 - return -ENOIOCTLCMD; 768 - } 769 - #endif 770 - 771 755 static struct tty_ldisc_ops sp_ldisc = { 772 756 .owner = THIS_MODULE, 773 757 .magic = TTY_LDISC_MAGIC, ··· 758 776 .open = sixpack_open, 759 777 .close = sixpack_close, 760 778 .ioctl = sixpack_ioctl, 761 - #ifdef CONFIG_COMPAT 762 - .compat_ioctl = sixpack_compat_ioctl, 763 - #endif 764 779 .receive_buf = sixpack_receive_buf, 765 780 .write_wakeup = sixpack_write_wakeup, 766 781 };
-21
drivers/net/hamradio/mkiss.c
··· 35 35 #include <linux/skbuff.h> 36 36 #include <linux/if_arp.h> 37 37 #include <linux/jiffies.h> 38 - #include <linux/compat.h> 39 38 40 39 #include <net/ax25.h> 41 40 ··· 874 875 return err; 875 876 } 876 877 877 - #ifdef CONFIG_COMPAT 878 - static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file, 879 - unsigned int cmd, unsigned long arg) 880 - { 881 - switch (cmd) { 882 - case SIOCGIFNAME: 883 - case SIOCGIFENCAP: 884 - case SIOCSIFENCAP: 885 - case SIOCSIFHWADDR: 886 - return mkiss_ioctl(tty, file, cmd, 887 - (unsigned long)compat_ptr(arg)); 888 - } 889 - 890 - return -ENOIOCTLCMD; 891 - } 892 - #endif 893 - 894 878 /* 895 879 * Handle the 'receiver data ready' interrupt. 896 880 * This function is called by the 'tty_io' module in the kernel when ··· 948 966 .open = mkiss_open, 949 967 .close = mkiss_close, 950 968 .ioctl = mkiss_ioctl, 951 - #ifdef CONFIG_COMPAT 952 - .compat_ioctl = mkiss_compat_ioctl, 953 - #endif 954 969 .receive_buf = mkiss_receive_buf, 955 970 .write_wakeup = mkiss_write_wakeup 956 971 };
-25
drivers/net/slip/slip.c
··· 79 79 #include <linux/rtnetlink.h> 80 80 #include <linux/if_arp.h> 81 81 #include <linux/if_slip.h> 82 - #include <linux/compat.h> 83 82 #include <linux/delay.h> 84 83 #include <linux/init.h> 85 84 #include <linux/slab.h> ··· 1166 1167 } 1167 1168 } 1168 1169 1169 - #ifdef CONFIG_COMPAT 1170 - static long slip_compat_ioctl(struct tty_struct *tty, struct file *file, 1171 - unsigned int cmd, unsigned long arg) 1172 - { 1173 - switch (cmd) { 1174 - case SIOCGIFNAME: 1175 - case SIOCGIFENCAP: 1176 - case SIOCSIFENCAP: 1177 - case SIOCSIFHWADDR: 1178 - case SIOCSKEEPALIVE: 1179 - case SIOCGKEEPALIVE: 1180 - case SIOCSOUTFILL: 1181 - case SIOCGOUTFILL: 1182 - return slip_ioctl(tty, file, cmd, 1183 - (unsigned long)compat_ptr(arg)); 1184 - } 1185 - 1186 - return -ENOIOCTLCMD; 1187 - } 1188 - #endif 1189 - 1190 1170 /* VSV changes start here */ 1191 1171 #ifdef CONFIG_SLIP_SMART 1192 1172 /* function do_ioctl called from net/core/dev.c ··· 1258 1280 .close = slip_close, 1259 1281 .hangup = slip_hangup, 1260 1282 .ioctl = slip_ioctl, 1261 - #ifdef CONFIG_COMPAT 1262 - .compat_ioctl = slip_compat_ioctl, 1263 - #endif 1264 1283 .receive_buf = slip_receive_buf, 1265 1284 .write_wakeup = slip_write_wakeup, 1266 1285 };
-19
drivers/net/wan/x25_asy.c
··· 33 33 #include <linux/lapb.h> 34 34 #include <linux/init.h> 35 35 #include <linux/rtnetlink.h> 36 - #include <linux/compat.h> 37 36 #include <linux/slab.h> 38 37 #include <net/x25device.h> 39 38 #include "x25_asy.h" ··· 702 703 } 703 704 } 704 705 705 - #ifdef CONFIG_COMPAT 706 - static long x25_asy_compat_ioctl(struct tty_struct *tty, struct file *file, 707 - unsigned int cmd, unsigned long arg) 708 - { 709 - switch (cmd) { 710 - case SIOCGIFNAME: 711 - case SIOCSIFHWADDR: 712 - return x25_asy_ioctl(tty, file, cmd, 713 - (unsigned long)compat_ptr(arg)); 714 - } 715 - 716 - return -ENOIOCTLCMD; 717 - } 718 - #endif 719 - 720 706 static int x25_asy_open_dev(struct net_device *dev) 721 707 { 722 708 struct x25_asy *sl = netdev_priv(dev); ··· 753 769 .open = x25_asy_open_tty, 754 770 .close = x25_asy_close_tty, 755 771 .ioctl = x25_asy_ioctl, 756 - #ifdef CONFIG_COMPAT 757 - .compat_ioctl = x25_asy_compat_ioctl, 758 - #endif 759 772 .receive_buf = x25_asy_receive_buf, 760 773 .write_wakeup = x25_asy_write_wakeup, 761 774 };
-218
drivers/staging/dgnc/dgnc_tty.c
··· 60 60 static void dgnc_tty_flush_chars(struct tty_struct *tty); 61 61 static void dgnc_tty_flush_buffer(struct tty_struct *tty); 62 62 static void dgnc_tty_hangup(struct tty_struct *tty); 63 - static int dgnc_set_modem_info(struct channel_t *ch, unsigned int command, 64 - unsigned int __user *value); 65 - static int dgnc_get_modem_info(struct channel_t *ch, 66 - unsigned int __user *value); 67 63 static int dgnc_tty_tiocmget(struct tty_struct *tty); 68 64 static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, 69 65 unsigned int clear); ··· 1697 1701 spin_unlock_irqrestore(&ch->ch_lock, flags); 1698 1702 } 1699 1703 1700 - /* Return modem signals to ld. */ 1701 - static inline int dgnc_get_mstat(struct channel_t *ch) 1702 - { 1703 - unsigned char mstat; 1704 - unsigned long flags; 1705 - int rc; 1706 - 1707 - if (!ch) 1708 - return -ENXIO; 1709 - 1710 - spin_lock_irqsave(&ch->ch_lock, flags); 1711 - 1712 - mstat = ch->ch_mostat | ch->ch_mistat; 1713 - 1714 - spin_unlock_irqrestore(&ch->ch_lock, flags); 1715 - 1716 - rc = 0; 1717 - 1718 - if (mstat & UART_MCR_DTR) 1719 - rc |= TIOCM_DTR; 1720 - if (mstat & UART_MCR_RTS) 1721 - rc |= TIOCM_RTS; 1722 - if (mstat & UART_MSR_CTS) 1723 - rc |= TIOCM_CTS; 1724 - if (mstat & UART_MSR_DSR) 1725 - rc |= TIOCM_DSR; 1726 - if (mstat & UART_MSR_RI) 1727 - rc |= TIOCM_RI; 1728 - if (mstat & UART_MSR_DCD) 1729 - rc |= TIOCM_CD; 1730 - 1731 - return rc; 1732 - } 1733 - 1734 - /* Return modem signals to ld. */ 1735 - static int dgnc_get_modem_info(struct channel_t *ch, 1736 - unsigned int __user *value) 1737 - { 1738 - return put_user(dgnc_get_mstat(ch), value); 1739 - } 1740 - 1741 - /* Set modem signals, called by ld. */ 1742 - static int dgnc_set_modem_info(struct channel_t *ch, 1743 - unsigned int command, 1744 - unsigned int __user *value) 1745 - { 1746 - int rc; 1747 - unsigned int arg = 0; 1748 - unsigned long flags; 1749 - 1750 - rc = get_user(arg, value); 1751 - if (rc) 1752 - return rc; 1753 - 1754 - switch (command) { 1755 - case TIOCMBIS: 1756 - if (arg & TIOCM_RTS) 1757 - ch->ch_mostat |= UART_MCR_RTS; 1758 - 1759 - if (arg & TIOCM_DTR) 1760 - ch->ch_mostat |= UART_MCR_DTR; 1761 - 1762 - break; 1763 - 1764 - case TIOCMBIC: 1765 - if (arg & TIOCM_RTS) 1766 - ch->ch_mostat &= ~(UART_MCR_RTS); 1767 - 1768 - if (arg & TIOCM_DTR) 1769 - ch->ch_mostat &= ~(UART_MCR_DTR); 1770 - 1771 - break; 1772 - 1773 - case TIOCMSET: 1774 - 1775 - if (arg & TIOCM_RTS) 1776 - ch->ch_mostat |= UART_MCR_RTS; 1777 - else 1778 - ch->ch_mostat &= ~(UART_MCR_RTS); 1779 - 1780 - if (arg & TIOCM_DTR) 1781 - ch->ch_mostat |= UART_MCR_DTR; 1782 - else 1783 - ch->ch_mostat &= ~(UART_MCR_DTR); 1784 - 1785 - break; 1786 - 1787 - default: 1788 - return -EINVAL; 1789 - } 1790 - 1791 - spin_lock_irqsave(&ch->ch_lock, flags); 1792 - 1793 - ch->ch_bd->bd_ops->assert_modem_signals(ch); 1794 - 1795 - spin_unlock_irqrestore(&ch->ch_lock, flags); 1796 - 1797 - return 0; 1798 - } 1799 - 1800 1704 /* Ioctl to get the information for ditty. */ 1801 1705 static int dgnc_tty_digigeta(struct tty_struct *tty, 1802 1706 struct digi_t __user *retinfo) ··· 2080 2184 } 2081 2185 2082 2186 switch (cmd) { 2083 - /* Here are all the standard ioctl's that we MUST implement */ 2084 - 2085 - case TCSBRK: 2086 - /* 2087 - * TCSBRK is SVID version: non-zero arg --> no break 2088 - * this behaviour is exploited by tcdrain(). 2089 - * 2090 - * According to POSIX.1 spec (7.2.2.1.2) breaks should be 2091 - * between 0.25 and 0.5 seconds so we'll ask for something 2092 - * in the middle: 0.375 seconds. 2093 - */ 2094 - rc = tty_check_change(tty); 2095 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2096 - if (rc) 2097 - return rc; 2098 - 2099 - rc = ch_bd_ops->drain(tty, 0); 2100 - if (rc) 2101 - return -EINTR; 2102 - 2103 - spin_lock_irqsave(&ch->ch_lock, flags); 2104 - 2105 - if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) 2106 - ch_bd_ops->send_break(ch, 250); 2107 - 2108 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2109 - 2110 - return 0; 2111 - 2112 - case TCSBRKP: 2113 - /* 2114 - * support for POSIX tcsendbreak() 2115 - * According to POSIX.1 spec (7.2.2.1.2) breaks should be 2116 - * between 0.25 and 0.5 seconds so we'll ask for something 2117 - * in the middle: 0.375 seconds. 2118 - */ 2119 - rc = tty_check_change(tty); 2120 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2121 - if (rc) 2122 - return rc; 2123 - 2124 - rc = ch_bd_ops->drain(tty, 0); 2125 - if (rc) 2126 - return -EINTR; 2127 - 2128 - spin_lock_irqsave(&ch->ch_lock, flags); 2129 - 2130 - ch_bd_ops->send_break(ch, 250); 2131 - 2132 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2133 - 2134 - return 0; 2135 - 2136 - case TIOCSBRK: 2137 - rc = tty_check_change(tty); 2138 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2139 - if (rc) 2140 - return rc; 2141 - 2142 - rc = ch_bd_ops->drain(tty, 0); 2143 - if (rc) 2144 - return -EINTR; 2145 - 2146 - spin_lock_irqsave(&ch->ch_lock, flags); 2147 - 2148 - ch_bd_ops->send_break(ch, 250); 2149 - 2150 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2151 - 2152 - return 0; 2153 - 2154 - case TIOCCBRK: 2155 - /* Do Nothing */ 2156 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2157 - return 0; 2158 - 2159 - case TIOCGSOFTCAR: 2160 - 2161 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2162 - 2163 - return put_user(C_CLOCAL(tty) ? 1 : 0, 2164 - (unsigned long __user *)arg); 2165 - 2166 - case TIOCSSOFTCAR: 2167 - 2168 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2169 - rc = get_user(arg, (unsigned long __user *)arg); 2170 - if (rc) 2171 - return rc; 2172 - 2173 - spin_lock_irqsave(&ch->ch_lock, flags); 2174 - tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | 2175 - (arg ? CLOCAL : 0)); 2176 - ch_bd_ops->param(tty); 2177 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2178 - 2179 - return 0; 2180 - 2181 - case TIOCMGET: 2182 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2183 - return dgnc_get_modem_info(ch, uarg); 2184 - 2185 - case TIOCMBIS: 2186 - case TIOCMBIC: 2187 - case TIOCMSET: 2188 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2189 - return dgnc_set_modem_info(ch, cmd, uarg); 2190 - 2191 2187 /* Here are any additional ioctl's that we want to implement */ 2192 - 2193 2188 case TCFLSH: 2194 2189 /* 2195 2190 * The linux tty driver doesn't have a flush ··· 2155 2368 return -EINTR; 2156 2369 2157 2370 /* pretend we didn't recognize this */ 2158 - return -ENOIOCTLCMD; 2159 - 2160 - case TCXONC: 2161 - spin_unlock_irqrestore(&ch->ch_lock, flags); 2162 - /* Make the ld do it */ 2163 2371 return -ENOIOCTLCMD; 2164 2372 2165 2373 case DIGI_GETA:
+28 -38
drivers/staging/fwserial/fwserial.c
··· 1209 1209 check_msr_delta(port, mask, &prev)); 1210 1210 } 1211 1211 1212 - static int get_serial_info(struct fwtty_port *port, 1213 - struct serial_struct __user *info) 1212 + static int get_serial_info(struct tty_struct *tty, 1213 + struct serial_struct *ss) 1214 1214 { 1215 - struct serial_struct tmp; 1216 - 1217 - memset(&tmp, 0, sizeof(tmp)); 1218 - 1219 - tmp.type = PORT_UNKNOWN; 1220 - tmp.line = port->port.tty->index; 1221 - tmp.flags = port->port.flags; 1222 - tmp.xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN; 1223 - tmp.baud_base = 400000000; 1224 - tmp.close_delay = port->port.close_delay; 1225 - 1226 - return (copy_to_user(info, &tmp, sizeof(*info))) ? -EFAULT : 0; 1215 + struct fwtty_port *port = tty->driver_data; 1216 + mutex_lock(&port->port.mutex); 1217 + ss->type = PORT_UNKNOWN; 1218 + ss->line = port->port.tty->index; 1219 + ss->flags = port->port.flags; 1220 + ss->xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN; 1221 + ss->baud_base = 400000000; 1222 + ss->close_delay = port->port.close_delay; 1223 + mutex_unlock(&port->port.mutex); 1224 + return 0; 1227 1225 } 1228 1226 1229 - static int set_serial_info(struct fwtty_port *port, 1230 - struct serial_struct __user *info) 1227 + static int set_serial_info(struct tty_struct *tty, 1228 + struct serial_struct *ss) 1231 1229 { 1232 - struct serial_struct tmp; 1230 + struct fwtty_port *port = tty->driver_data; 1233 1231 1234 - if (copy_from_user(&tmp, info, sizeof(tmp))) 1235 - return -EFAULT; 1236 - 1237 - if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 || 1238 - tmp.baud_base != 400000000) 1232 + if (ss->irq != 0 || ss->port != 0 || ss->custom_divisor != 0 || 1233 + ss->baud_base != 400000000) 1239 1234 return -EPERM; 1240 1235 1236 + mutex_lock(&port->port.mutex); 1241 1237 if (!capable(CAP_SYS_ADMIN)) { 1242 - if (((tmp.flags & ~ASYNC_USR_MASK) != 1243 - (port->port.flags & ~ASYNC_USR_MASK))) 1238 + if (((ss->flags & ~ASYNC_USR_MASK) != 1239 + (port->port.flags & ~ASYNC_USR_MASK))) { 1240 + mutex_unlock(&port->port.mutex); 1244 1241 return -EPERM; 1245 - } else { 1246 - port->port.close_delay = tmp.close_delay * HZ / 100; 1242 + } 1247 1243 } 1244 + port->port.close_delay = ss->close_delay * HZ / 100; 1245 + mutex_unlock(&port->port.mutex); 1248 1246 1249 1247 return 0; 1250 1248 } ··· 1254 1256 int err; 1255 1257 1256 1258 switch (cmd) { 1257 - case TIOCGSERIAL: 1258 - mutex_lock(&port->port.mutex); 1259 - err = get_serial_info(port, (void __user *)arg); 1260 - mutex_unlock(&port->port.mutex); 1261 - break; 1262 - 1263 - case TIOCSSERIAL: 1264 - mutex_lock(&port->port.mutex); 1265 - err = set_serial_info(port, (void __user *)arg); 1266 - mutex_unlock(&port->port.mutex); 1267 - break; 1268 - 1269 1259 case TIOCMIWAIT: 1270 1260 err = wait_msr_change(port, arg); 1271 1261 break; ··· 1543 1557 .tiocmget = fwtty_tiocmget, 1544 1558 .tiocmset = fwtty_tiocmset, 1545 1559 .get_icount = fwtty_get_icount, 1560 + .set_serial = set_serial_info, 1561 + .get_serial = get_serial_info, 1546 1562 .proc_show = fwtty_proc_show, 1547 1563 }; 1548 1564 ··· 1566 1578 .tiocmget = fwtty_tiocmget, 1567 1579 .tiocmset = fwtty_tiocmset, 1568 1580 .get_icount = fwtty_get_icount, 1581 + .set_serial = set_serial_info, 1582 + .get_serial = get_serial_info, 1569 1583 }; 1570 1584 1571 1585 static inline int mgmt_pkt_expected_len(__be16 code)
+17 -28
drivers/staging/greybus/uart.c
··· 616 616 } 617 617 } 618 618 619 - static int get_serial_info(struct gb_tty *gb_tty, 620 - struct serial_struct __user *info) 619 + static int get_serial_info(struct tty_struct *tty, 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)); 625 - tmp.type = PORT_16550A; 626 - tmp.line = gb_tty->minor; 627 - tmp.xmit_fifo_size = 16; 628 - tmp.baud_base = 9600; 629 - tmp.close_delay = gb_tty->port.close_delay / 10; 630 - tmp.closing_wait = 624 + ss->type = PORT_16550A; 625 + ss->line = gb_tty->minor; 626 + ss->xmit_fifo_size = 16; 627 + ss->baud_base = 9600; 628 + ss->close_delay = gb_tty->port.close_delay / 10; 629 + ss->closing_wait = 631 630 gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? 632 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 632 return 0; 637 633 } 638 634 639 - static int set_serial_info(struct gb_tty *gb_tty, 640 - struct serial_struct __user *newinfo) 635 + static int set_serial_info(struct tty_struct *tty, 636 + struct serial_struct *ss) 641 637 { 642 - struct serial_struct new_serial; 638 + struct gb_tty *gb_tty = tty->driver_data; 643 639 unsigned int closing_wait; 644 640 unsigned int close_delay; 645 641 int retval = 0; 646 642 647 - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 648 - return -EFAULT; 649 - 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; 643 + close_delay = ss->close_delay * 10; 644 + closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ? 645 + ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10; 653 646 654 647 mutex_lock(&gb_tty->port.mutex); 655 648 if (!capable(CAP_SYS_ADMIN)) { ··· 721 728 struct gb_tty *gb_tty = tty->driver_data; 722 729 723 730 switch (cmd) { 724 - case TIOCGSERIAL: 725 - return get_serial_info(gb_tty, 726 - (struct serial_struct __user *)arg); 727 - case TIOCSSERIAL: 728 - return set_serial_info(gb_tty, 729 - (struct serial_struct __user *)arg); 730 731 case TIOCMIWAIT: 731 732 return wait_serial_change(gb_tty, arg); 732 733 } ··· 805 818 .tiocmget = gb_tty_tiocmget, 806 819 .tiocmset = gb_tty_tiocmset, 807 820 .get_icount = gb_tty_get_icount, 821 + .set_serial = set_serial_info, 822 + .get_serial = get_serial_info, 808 823 }; 809 824 810 825 static const struct tty_port_operations gb_port_ops = {
+33 -57
drivers/tty/amiserial.c
··· 996 996 * ------------------------------------------------------------ 997 997 */ 998 998 999 - static int get_serial_info(struct tty_struct *tty, struct serial_state *state, 1000 - struct serial_struct __user * retinfo) 999 + static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss) 1001 1000 { 1002 - struct serial_struct tmp; 1003 - 1004 - memset(&tmp, 0, sizeof(tmp)); 1001 + struct serial_state *state = tty->driver_data; 1002 + 1005 1003 tty_lock(tty); 1006 - tmp.line = tty->index; 1007 - tmp.port = state->port; 1008 - tmp.flags = state->tport.flags; 1009 - tmp.xmit_fifo_size = state->xmit_fifo_size; 1010 - tmp.baud_base = state->baud_base; 1011 - tmp.close_delay = state->tport.close_delay; 1012 - tmp.closing_wait = state->tport.closing_wait; 1013 - tmp.custom_divisor = state->custom_divisor; 1004 + ss->line = tty->index; 1005 + ss->port = state->port; 1006 + ss->flags = state->tport.flags; 1007 + ss->xmit_fifo_size = state->xmit_fifo_size; 1008 + ss->baud_base = state->baud_base; 1009 + ss->close_delay = state->tport.close_delay; 1010 + ss->closing_wait = state->tport.closing_wait; 1011 + ss->custom_divisor = state->custom_divisor; 1014 1012 tty_unlock(tty); 1015 - if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) 1016 - return -EFAULT; 1017 1013 return 0; 1018 1014 } 1019 1015 1020 - static int set_serial_info(struct tty_struct *tty, struct serial_state *state, 1021 - struct serial_struct __user * new_info) 1016 + static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss) 1022 1017 { 1018 + struct serial_state *state = tty->driver_data; 1023 1019 struct tty_port *port = &state->tport; 1024 - struct serial_struct new_serial; 1025 1020 bool change_spd; 1026 1021 int retval = 0; 1027 1022 1028 - if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1029 - return -EFAULT; 1030 - 1031 1023 tty_lock(tty); 1032 - change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) || 1033 - new_serial.custom_divisor != state->custom_divisor; 1034 - if (new_serial.irq || new_serial.port != state->port || 1035 - new_serial.xmit_fifo_size != state->xmit_fifo_size) { 1024 + change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) || 1025 + ss->custom_divisor != state->custom_divisor; 1026 + if (ss->irq || ss->port != state->port || 1027 + ss->xmit_fifo_size != state->xmit_fifo_size) { 1036 1028 tty_unlock(tty); 1037 1029 return -EINVAL; 1038 1030 } 1039 1031 1040 1032 if (!serial_isroot()) { 1041 - if ((new_serial.baud_base != state->baud_base) || 1042 - (new_serial.close_delay != port->close_delay) || 1043 - (new_serial.xmit_fifo_size != state->xmit_fifo_size) || 1044 - ((new_serial.flags & ~ASYNC_USR_MASK) != 1033 + if ((ss->baud_base != state->baud_base) || 1034 + (ss->close_delay != port->close_delay) || 1035 + (ss->xmit_fifo_size != state->xmit_fifo_size) || 1036 + ((ss->flags & ~ASYNC_USR_MASK) != 1045 1037 (port->flags & ~ASYNC_USR_MASK))) { 1046 1038 tty_unlock(tty); 1047 1039 return -EPERM; 1048 1040 } 1049 1041 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1050 - (new_serial.flags & ASYNC_USR_MASK)); 1051 - state->custom_divisor = new_serial.custom_divisor; 1042 + (ss->flags & ASYNC_USR_MASK)); 1043 + state->custom_divisor = ss->custom_divisor; 1052 1044 goto check_and_exit; 1053 1045 } 1054 1046 1055 - if (new_serial.baud_base < 9600) { 1047 + if (ss->baud_base < 9600) { 1056 1048 tty_unlock(tty); 1057 1049 return -EINVAL; 1058 1050 } ··· 1054 1062 * At this point, we start making changes..... 1055 1063 */ 1056 1064 1057 - state->baud_base = new_serial.baud_base; 1065 + state->baud_base = ss->baud_base; 1058 1066 port->flags = ((port->flags & ~ASYNC_FLAGS) | 1059 - (new_serial.flags & ASYNC_FLAGS)); 1060 - state->custom_divisor = new_serial.custom_divisor; 1061 - port->close_delay = new_serial.close_delay * HZ/100; 1062 - port->closing_wait = new_serial.closing_wait * HZ/100; 1067 + (ss->flags & ASYNC_FLAGS)); 1068 + state->custom_divisor = ss->custom_divisor; 1069 + port->close_delay = ss->close_delay * HZ/100; 1070 + port->closing_wait = ss->closing_wait * HZ/100; 1063 1071 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1064 1072 1065 1073 check_and_exit: 1066 1074 if (tty_port_initialized(port)) { 1067 1075 if (change_spd) { 1068 1076 /* warn about deprecation unless clearing */ 1069 - if (new_serial.flags & ASYNC_SPD_MASK) 1077 + if (ss->flags & ASYNC_SPD_MASK) 1070 1078 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); 1071 1079 change_speed(tty, state, NULL); 1072 1080 } ··· 1075 1083 tty_unlock(tty); 1076 1084 return retval; 1077 1085 } 1078 - 1079 1086 1080 1087 /* 1081 1088 * get_lsr_info - get line status register info ··· 1215 1224 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) 1216 1225 return -ENODEV; 1217 1226 1218 - if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1219 - (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && 1227 + if ((cmd != TIOCSERCONFIG) && 1220 1228 (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 1221 1229 if (tty_io_error(tty)) 1222 1230 return -EIO; 1223 1231 } 1224 1232 1225 1233 switch (cmd) { 1226 - case TIOCGSERIAL: 1227 - return get_serial_info(tty, info, argp); 1228 - case TIOCSSERIAL: 1229 - return set_serial_info(tty, info, argp); 1230 1234 case TIOCSERCONFIG: 1231 1235 return 0; 1232 1236 1233 1237 case TIOCSERGETLSR: /* Get line status register */ 1234 1238 return get_lsr_info(info, argp); 1235 - 1236 - case TIOCSERGSTRUCT: 1237 - if (copy_to_user(argp, 1238 - info, sizeof(struct serial_state))) 1239 - return -EFAULT; 1240 - return 0; 1241 1239 1242 1240 /* 1243 1241 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change ··· 1267 1287 } 1268 1288 finish_wait(&info->tport.delta_msr_wait, &wait); 1269 1289 return ret; 1270 - 1271 - case TIOCSERGWILD: 1272 - case TIOCSERSWILD: 1273 - /* "setserial -W" is called in Debian boot */ 1274 - printk ("TIOCSER?WILD ioctl obsolete, ignored.\n"); 1275 - return 0; 1276 1290 1277 1291 default: 1278 1292 return -ENOIOCTLCMD; ··· 1581 1607 .tiocmget = rs_tiocmget, 1582 1608 .tiocmset = rs_tiocmset, 1583 1609 .get_icount = rs_get_icount, 1610 + .set_serial = set_serial_info, 1611 + .get_serial = get_serial_info, 1584 1612 .proc_show = rs_proc_show, 1585 1613 }; 1586 1614
+37 -40
drivers/tty/cyclades.c
··· 2257 2257 } 2258 2258 } /* set_line_char */ 2259 2259 2260 - static int cy_get_serial_info(struct cyclades_port *info, 2261 - struct serial_struct __user *retinfo) 2260 + static int cy_get_serial_info(struct tty_struct *tty, 2261 + struct serial_struct *ss) 2262 2262 { 2263 + struct cyclades_port *info = tty->driver_data; 2263 2264 struct cyclades_card *cinfo = info->card; 2264 - struct serial_struct tmp = { 2265 - .type = info->type, 2266 - .line = info->line, 2267 - .port = (info->card - cy_card) * 0x100 + info->line - 2268 - cinfo->first_line, 2269 - .irq = cinfo->irq, 2270 - .flags = info->port.flags, 2271 - .close_delay = info->port.close_delay, 2272 - .closing_wait = info->port.closing_wait, 2273 - .baud_base = info->baud, 2274 - .custom_divisor = info->custom_divisor, 2275 - }; 2276 - return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 2265 + 2266 + if (serial_paranoia_check(info, tty->name, "cy_ioctl")) 2267 + return -ENODEV; 2268 + ss->type = info->type; 2269 + ss->line = info->line; 2270 + ss->port = (info->card - cy_card) * 0x100 + info->line - 2271 + cinfo->first_line; 2272 + ss->irq = cinfo->irq; 2273 + ss->flags = info->port.flags; 2274 + ss->close_delay = info->port.close_delay; 2275 + ss->closing_wait = info->port.closing_wait; 2276 + ss->baud_base = info->baud; 2277 + ss->custom_divisor = info->custom_divisor; 2278 + return 0; 2277 2279 } 2278 2280 2279 - static int 2280 - cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty, 2281 - struct serial_struct __user *new_info) 2281 + static int cy_set_serial_info(struct tty_struct *tty, 2282 + struct serial_struct *ss) 2282 2283 { 2283 - struct serial_struct new_serial; 2284 + struct cyclades_port *info = tty->driver_data; 2284 2285 int old_flags; 2285 2286 int ret; 2286 2287 2287 - if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2288 - return -EFAULT; 2288 + if (serial_paranoia_check(info, tty->name, "cy_ioctl")) 2289 + return -ENODEV; 2289 2290 2290 2291 mutex_lock(&info->port.mutex); 2291 2292 2292 2293 old_flags = info->port.flags; 2293 2294 2294 2295 if (!capable(CAP_SYS_ADMIN)) { 2295 - if (new_serial.close_delay != info->port.close_delay || 2296 - new_serial.baud_base != info->baud || 2297 - (new_serial.flags & ASYNC_FLAGS & 2296 + if (ss->close_delay != info->port.close_delay || 2297 + ss->baud_base != info->baud || 2298 + (ss->flags & ASYNC_FLAGS & 2298 2299 ~ASYNC_USR_MASK) != 2299 2300 (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) 2300 2301 { ··· 2303 2302 return -EPERM; 2304 2303 } 2305 2304 info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) | 2306 - (new_serial.flags & ASYNC_USR_MASK); 2307 - info->baud = new_serial.baud_base; 2308 - info->custom_divisor = new_serial.custom_divisor; 2305 + (ss->flags & ASYNC_USR_MASK); 2306 + info->baud = ss->baud_base; 2307 + info->custom_divisor = ss->custom_divisor; 2309 2308 goto check_and_exit; 2310 2309 } 2311 2310 ··· 2314 2313 * At this point, we start making changes..... 2315 2314 */ 2316 2315 2317 - info->baud = new_serial.baud_base; 2318 - info->custom_divisor = new_serial.custom_divisor; 2316 + info->baud = ss->baud_base; 2317 + info->custom_divisor = ss->custom_divisor; 2319 2318 info->port.flags = (info->port.flags & ~ASYNC_FLAGS) | 2320 - (new_serial.flags & ASYNC_FLAGS); 2321 - info->port.close_delay = new_serial.close_delay * HZ / 100; 2322 - info->port.closing_wait = new_serial.closing_wait * HZ / 100; 2319 + (ss->flags & ASYNC_FLAGS); 2320 + info->port.close_delay = ss->close_delay * HZ / 100; 2321 + info->port.closing_wait = ss->closing_wait * HZ / 100; 2323 2322 2324 2323 check_and_exit: 2325 2324 if (tty_port_initialized(&info->port)) { 2326 - if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) { 2325 + if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) { 2327 2326 /* warn about deprecation unless clearing */ 2328 - if (new_serial.flags & ASYNC_SPD_MASK) 2327 + if (ss->flags & ASYNC_SPD_MASK) 2329 2328 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); 2330 2329 } 2331 2330 cy_set_line_char(info, tty); ··· 2698 2697 break; 2699 2698 case CYGETWAIT: 2700 2699 ret_val = info->port.closing_wait / (HZ / 100); 2701 - break; 2702 - case TIOCGSERIAL: 2703 - ret_val = cy_get_serial_info(info, argp); 2704 - break; 2705 - case TIOCSSERIAL: 2706 - ret_val = cy_set_serial_info(info, tty, argp); 2707 2700 break; 2708 2701 case TIOCSERGETLSR: /* Get line status register */ 2709 2702 ret_val = get_lsr_info(info, argp); ··· 4006 4011 .tiocmget = cy_tiocmget, 4007 4012 .tiocmset = cy_tiocmset, 4008 4013 .get_icount = cy_get_icount, 4014 + .set_serial = cy_set_serial_info, 4015 + .get_serial = cy_get_serial_info, 4009 4016 .proc_show = cyclades_proc_show, 4010 4017 }; 4011 4018
+18 -18
drivers/tty/ipwireless/tty.c
··· 248 248 return room; 249 249 } 250 250 251 - static int ipwireless_get_serial_info(struct ipw_tty *tty, 252 - struct serial_struct __user *retinfo) 251 + static int ipwireless_get_serial_info(struct tty_struct *linux_tty, 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)); 257 - tmp.type = PORT_UNKNOWN; 258 - tmp.line = tty->index; 259 - tmp.baud_base = 115200; 256 + if (!tty) 257 + return -ENODEV; 260 258 261 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 262 - return -EFAULT; 259 + if (!tty->port.count) 260 + return -EINVAL; 263 261 262 + ss->type = PORT_UNKNOWN; 263 + ss->line = tty->index; 264 + ss->baud_base = 115200; 264 265 return 0; 266 + } 267 + 268 + static int ipwireless_set_serial_info(struct tty_struct *linux_tty, 269 + struct serial_struct *ss) 270 + { 271 + return 0; /* Keeps the PCMCIA scripts happy. */ 265 272 } 266 273 267 274 static int ipw_chars_in_buffer(struct tty_struct *linux_tty) ··· 393 386 return -EINVAL; 394 387 395 388 /* FIXME: Exactly how is the tty object locked here .. */ 396 - 397 - switch (cmd) { 398 - case TIOCGSERIAL: 399 - return ipwireless_get_serial_info(tty, (void __user *) arg); 400 - 401 - case TIOCSSERIAL: 402 - return 0; /* Keeps the PCMCIA scripts happy. */ 403 - } 404 - 405 389 if (tty->tty_type == TTYTYPE_MODEM) { 406 390 switch (cmd) { 407 391 case PPPIOCGCHAN: ··· 559 561 .chars_in_buffer = ipw_chars_in_buffer, 560 562 .tiocmget = ipw_tiocmget, 561 563 .tiocmset = ipw_tiocmset, 564 + .set_serial = ipwireless_set_serial_info, 565 + .get_serial = ipwireless_get_serial_info, 562 566 }; 563 567 564 568 int ipwireless_tty_init(void)
+25 -47
drivers/tty/isicom.c
··· 1091 1091 } 1092 1092 1093 1093 static int isicom_set_serial_info(struct tty_struct *tty, 1094 - struct serial_struct __user *info) 1094 + struct serial_struct *ss) 1095 1095 { 1096 1096 struct isi_port *port = tty->driver_data; 1097 - struct serial_struct newinfo; 1098 1097 int reconfig_port; 1099 1098 1100 - if (copy_from_user(&newinfo, info, sizeof(newinfo))) 1101 - return -EFAULT; 1099 + if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) 1100 + return -ENODEV; 1102 1101 1103 1102 mutex_lock(&port->port.mutex); 1104 1103 reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) != 1105 - (newinfo.flags & ASYNC_SPD_MASK)); 1104 + (ss->flags & ASYNC_SPD_MASK)); 1106 1105 1107 1106 if (!capable(CAP_SYS_ADMIN)) { 1108 - if ((newinfo.close_delay != port->port.close_delay) || 1109 - (newinfo.closing_wait != port->port.closing_wait) || 1110 - ((newinfo.flags & ~ASYNC_USR_MASK) != 1107 + if ((ss->close_delay != port->port.close_delay) || 1108 + (ss->closing_wait != port->port.closing_wait) || 1109 + ((ss->flags & ~ASYNC_USR_MASK) != 1111 1110 (port->port.flags & ~ASYNC_USR_MASK))) { 1112 1111 mutex_unlock(&port->port.mutex); 1113 1112 return -EPERM; 1114 1113 } 1115 1114 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | 1116 - (newinfo.flags & ASYNC_USR_MASK)); 1115 + (ss->flags & ASYNC_USR_MASK)); 1117 1116 } else { 1118 - port->port.close_delay = newinfo.close_delay; 1119 - port->port.closing_wait = newinfo.closing_wait; 1117 + port->port.close_delay = ss->close_delay; 1118 + port->port.closing_wait = ss->closing_wait; 1120 1119 port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) | 1121 - (newinfo.flags & ASYNC_FLAGS)); 1120 + (ss->flags & ASYNC_FLAGS)); 1122 1121 } 1123 1122 if (reconfig_port) { 1124 1123 unsigned long flags; ··· 1129 1130 return 0; 1130 1131 } 1131 1132 1132 - static int isicom_get_serial_info(struct isi_port *port, 1133 - struct serial_struct __user *info) 1134 - { 1135 - struct serial_struct out_info; 1136 - 1137 - mutex_lock(&port->port.mutex); 1138 - memset(&out_info, 0, sizeof(out_info)); 1139 - /* out_info.type = ? */ 1140 - out_info.line = port - isi_ports; 1141 - out_info.port = port->card->base; 1142 - out_info.irq = port->card->irq; 1143 - out_info.flags = port->port.flags; 1144 - /* out_info.baud_base = ? */ 1145 - out_info.close_delay = port->port.close_delay; 1146 - out_info.closing_wait = port->port.closing_wait; 1147 - mutex_unlock(&port->port.mutex); 1148 - if (copy_to_user(info, &out_info, sizeof(out_info))) 1149 - return -EFAULT; 1150 - return 0; 1151 - } 1152 - 1153 - static int isicom_ioctl(struct tty_struct *tty, 1154 - unsigned int cmd, unsigned long arg) 1133 + static int isicom_get_serial_info(struct tty_struct *tty, 1134 + struct serial_struct *ss) 1155 1135 { 1156 1136 struct isi_port *port = tty->driver_data; 1157 - void __user *argp = (void __user *)arg; 1158 1137 1159 1138 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) 1160 1139 return -ENODEV; 1161 1140 1162 - switch (cmd) { 1163 - case TIOCGSERIAL: 1164 - return isicom_get_serial_info(port, argp); 1165 - 1166 - case TIOCSSERIAL: 1167 - return isicom_set_serial_info(tty, argp); 1168 - 1169 - default: 1170 - return -ENOIOCTLCMD; 1171 - } 1141 + mutex_lock(&port->port.mutex); 1142 + /* ss->type = ? */ 1143 + ss->line = port - isi_ports; 1144 + ss->port = port->card->base; 1145 + ss->irq = port->card->irq; 1146 + ss->flags = port->port.flags; 1147 + /* ss->baud_base = ? */ 1148 + ss->close_delay = port->port.close_delay; 1149 + ss->closing_wait = port->port.closing_wait; 1150 + mutex_unlock(&port->port.mutex); 1172 1151 return 0; 1173 1152 } 1174 1153 ··· 1250 1273 .flush_chars = isicom_flush_chars, 1251 1274 .write_room = isicom_write_room, 1252 1275 .chars_in_buffer = isicom_chars_in_buffer, 1253 - .ioctl = isicom_ioctl, 1254 1276 .set_termios = isicom_set_termios, 1255 1277 .throttle = isicom_throttle, 1256 1278 .unthrottle = isicom_unthrottle, ··· 1260 1284 .tiocmget = isicom_tiocmget, 1261 1285 .tiocmset = isicom_tiocmset, 1262 1286 .break_ctl = isicom_send_break, 1287 + .get_serial = isicom_get_serial_info, 1288 + .set_serial = isicom_set_serial_info, 1263 1289 }; 1264 1290 1265 1291 static const struct tty_port_operations isicom_port_ops = {
+40 -39
drivers/tty/moxa.c
··· 221 221 static int MoxaPortTxFree(struct moxa_port *); 222 222 static void MoxaPortTxDisable(struct moxa_port *); 223 223 static void MoxaPortTxEnable(struct moxa_port *); 224 - static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *); 225 - static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *); 224 + static int moxa_get_serial_info(struct tty_struct *, struct serial_struct *); 225 + static int moxa_set_serial_info(struct tty_struct *, struct serial_struct *); 226 226 static void MoxaSetFifo(struct moxa_port *port, int enable); 227 227 228 228 /* ··· 375 375 } 376 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 378 default: 389 379 ret = -ENOIOCTLCMD; 390 380 } ··· 405 415 .break_ctl = moxa_break_ctl, 406 416 .tiocmget = moxa_tiocmget, 407 417 .tiocmset = moxa_tiocmset, 418 + .set_serial = moxa_set_serial_info, 419 + .get_serial = moxa_get_serial_info, 408 420 }; 409 421 410 422 static const struct tty_port_operations moxa_port_ops = { ··· 2026 2034 moxafunc(port->tableAddr, FC_SetXonState, Magic_code); 2027 2035 } 2028 2036 2029 - static int moxa_get_serial_info(struct moxa_port *info, 2030 - struct serial_struct __user *retinfo) 2037 + static int moxa_get_serial_info(struct tty_struct *tty, 2038 + struct serial_struct *ss) 2031 2039 { 2032 - struct serial_struct tmp = { 2033 - .type = info->type, 2034 - .line = info->port.tty->index, 2035 - .flags = info->port.flags, 2036 - .baud_base = 921600, 2037 - .close_delay = info->port.close_delay 2038 - }; 2039 - return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 2040 + struct moxa_port *info = tty->driver_data; 2041 + 2042 + if (tty->index == MAX_PORTS) 2043 + return -EINVAL; 2044 + if (!info) 2045 + return -ENODEV; 2046 + mutex_lock(&info->port.mutex); 2047 + ss->type = info->type, 2048 + ss->line = info->port.tty->index, 2049 + ss->flags = info->port.flags, 2050 + ss->baud_base = 921600, 2051 + ss->close_delay = info->port.close_delay; 2052 + mutex_unlock(&info->port.mutex); 2053 + return 0; 2040 2054 } 2041 2055 2042 2056 2043 - static int moxa_set_serial_info(struct moxa_port *info, 2044 - struct serial_struct __user *new_info) 2057 + static int moxa_set_serial_info(struct tty_struct *tty, 2058 + struct serial_struct *ss) 2045 2059 { 2046 - struct serial_struct new_serial; 2060 + struct moxa_port *info = tty->driver_data; 2047 2061 2048 - if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2049 - return -EFAULT; 2062 + if (tty->index == MAX_PORTS) 2063 + return -EINVAL; 2064 + if (!info) 2065 + return -ENODEV; 2050 2066 2051 - if (new_serial.irq != 0 || new_serial.port != 0 || 2052 - new_serial.custom_divisor != 0 || 2053 - new_serial.baud_base != 921600) 2067 + if (ss->irq != 0 || ss->port != 0 || 2068 + ss->custom_divisor != 0 || 2069 + ss->baud_base != 921600) 2054 2070 return -EPERM; 2055 2071 2072 + mutex_lock(&info->port.mutex); 2056 2073 if (!capable(CAP_SYS_ADMIN)) { 2057 - if (((new_serial.flags & ~ASYNC_USR_MASK) != 2058 - (info->port.flags & ~ASYNC_USR_MASK))) 2074 + if (((ss->flags & ~ASYNC_USR_MASK) != 2075 + (info->port.flags & ~ASYNC_USR_MASK))) { 2076 + mutex_unlock(&info->port.mutex); 2059 2077 return -EPERM; 2060 - } else 2061 - info->port.close_delay = new_serial.close_delay * HZ / 100; 2078 + } 2079 + } 2080 + info->port.close_delay = ss->close_delay * HZ / 100; 2062 2081 2063 - new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS); 2064 - new_serial.flags |= (info->port.flags & ASYNC_FLAGS); 2082 + MoxaSetFifo(info, ss->type == PORT_16550A); 2065 2083 2066 - MoxaSetFifo(info, new_serial.type == PORT_16550A); 2067 - 2068 - info->type = new_serial.type; 2084 + info->type = ss->type; 2085 + mutex_unlock(&info->port.mutex); 2069 2086 return 0; 2070 2087 } 2071 2088
+52 -47
drivers/tty/mxser.c
··· 1207 1207 * ------------------------------------------------------------ 1208 1208 */ 1209 1209 static int mxser_get_serial_info(struct tty_struct *tty, 1210 - struct serial_struct __user *retinfo) 1210 + struct serial_struct *ss) 1211 1211 { 1212 1212 struct mxser_port *info = tty->driver_data; 1213 - struct serial_struct tmp = { 1214 - .type = info->type, 1215 - .line = tty->index, 1216 - .port = info->ioaddr, 1217 - .irq = info->board->irq, 1218 - .flags = info->port.flags, 1219 - .baud_base = info->baud_base, 1220 - .close_delay = info->port.close_delay, 1221 - .closing_wait = info->port.closing_wait, 1222 - .custom_divisor = info->custom_divisor, 1223 - }; 1224 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1225 - return -EFAULT; 1213 + struct tty_port *port = &info->port; 1214 + 1215 + if (tty->index == MXSER_PORTS) 1216 + return -ENOTTY; 1217 + 1218 + mutex_lock(&port->mutex); 1219 + ss->type = info->type, 1220 + ss->line = tty->index, 1221 + ss->port = info->ioaddr, 1222 + ss->irq = info->board->irq, 1223 + ss->flags = info->port.flags, 1224 + ss->baud_base = info->baud_base, 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 1229 return 0; 1227 1230 } 1228 1231 1229 1232 static int mxser_set_serial_info(struct tty_struct *tty, 1230 - struct serial_struct __user *new_info) 1233 + struct serial_struct *ss) 1231 1234 { 1232 1235 struct mxser_port *info = tty->driver_data; 1233 1236 struct tty_port *port = &info->port; 1234 - struct serial_struct new_serial; 1235 1237 speed_t baud; 1236 1238 unsigned long sl_flags; 1237 1239 unsigned int flags; 1238 1240 int retval = 0; 1239 1241 1240 - if (!new_info || !info->ioaddr) 1241 - return -ENODEV; 1242 - if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 1243 - return -EFAULT; 1242 + if (tty->index == MXSER_PORTS) 1243 + return -ENOTTY; 1244 + if (tty_io_error(tty)) 1245 + return -EIO; 1244 1246 1245 - if (new_serial.irq != info->board->irq || 1246 - new_serial.port != info->ioaddr) 1247 + mutex_lock(&port->mutex); 1248 + if (!info->ioaddr) { 1249 + mutex_unlock(&port->mutex); 1250 + return -ENODEV; 1251 + } 1252 + 1253 + if (ss->irq != info->board->irq || 1254 + ss->port != info->ioaddr) { 1255 + mutex_unlock(&port->mutex); 1247 1256 return -EINVAL; 1257 + } 1248 1258 1249 1259 flags = port->flags & ASYNC_SPD_MASK; 1250 1260 1251 1261 if (!capable(CAP_SYS_ADMIN)) { 1252 - if ((new_serial.baud_base != info->baud_base) || 1253 - (new_serial.close_delay != info->port.close_delay) || 1254 - ((new_serial.flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) 1262 + if ((ss->baud_base != info->baud_base) || 1263 + (ss->close_delay != info->port.close_delay) || 1264 + ((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) { 1265 + mutex_unlock(&port->mutex); 1255 1266 return -EPERM; 1267 + } 1256 1268 info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) | 1257 - (new_serial.flags & ASYNC_USR_MASK)); 1269 + (ss->flags & ASYNC_USR_MASK)); 1258 1270 } else { 1259 1271 /* 1260 1272 * OK, past this point, all the error checking has been done. 1261 1273 * At this point, we start making changes..... 1262 1274 */ 1263 1275 port->flags = ((port->flags & ~ASYNC_FLAGS) | 1264 - (new_serial.flags & ASYNC_FLAGS)); 1265 - port->close_delay = new_serial.close_delay * HZ / 100; 1266 - port->closing_wait = new_serial.closing_wait * HZ / 100; 1276 + (ss->flags & ASYNC_FLAGS)); 1277 + port->close_delay = ss->close_delay * HZ / 100; 1278 + port->closing_wait = ss->closing_wait * HZ / 100; 1267 1279 port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1268 1280 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && 1269 - (new_serial.baud_base != info->baud_base || 1270 - new_serial.custom_divisor != 1281 + (ss->baud_base != info->baud_base || 1282 + ss->custom_divisor != 1271 1283 info->custom_divisor)) { 1272 - if (new_serial.custom_divisor == 0) 1284 + if (ss->custom_divisor == 0) { 1285 + mutex_unlock(&port->mutex); 1273 1286 return -EINVAL; 1274 - baud = new_serial.baud_base / new_serial.custom_divisor; 1287 + } 1288 + baud = ss->baud_base / ss->custom_divisor; 1275 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 1295 process_txrx_fifo(info); 1282 1296 ··· 1305 1291 if (retval == 0) 1306 1292 tty_port_set_initialized(port, 1); 1307 1293 } 1294 + mutex_unlock(&port->mutex); 1308 1295 return retval; 1309 1296 } 1310 1297 ··· 1675 1660 unsigned int cmd, unsigned long arg) 1676 1661 { 1677 1662 struct mxser_port *info = tty->driver_data; 1678 - struct tty_port *port = &info->port; 1679 1663 struct async_icount cnow; 1680 1664 unsigned long flags; 1681 1665 void __user *argp = (void __user *)arg; 1682 - int retval; 1683 1666 1684 1667 if (tty->index == MXSER_PORTS) 1685 1668 return mxser_ioctl_special(cmd, argp); ··· 1721 1708 return 0; 1722 1709 } 1723 1710 1724 - if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && tty_io_error(tty)) 1711 + if (cmd != TIOCMIWAIT && tty_io_error(tty)) 1725 1712 return -EIO; 1726 1713 1727 1714 switch (cmd) { 1728 - case TIOCGSERIAL: 1729 - mutex_lock(&port->mutex); 1730 - retval = mxser_get_serial_info(tty, argp); 1731 - mutex_unlock(&port->mutex); 1732 - return retval; 1733 - case TIOCSSERIAL: 1734 - mutex_lock(&port->mutex); 1735 - retval = mxser_set_serial_info(tty, argp); 1736 - mutex_unlock(&port->mutex); 1737 - return retval; 1738 1715 case TIOCSERGETLSR: /* Get line status register */ 1739 1716 return mxser_get_lsr_info(info, argp); 1740 1717 /* ··· 2328 2325 .wait_until_sent = mxser_wait_until_sent, 2329 2326 .tiocmget = mxser_tiocmget, 2330 2327 .tiocmset = mxser_tiocmset, 2328 + .set_serial = mxser_set_serial_info, 2329 + .get_serial = mxser_get_serial_info, 2331 2330 .get_icount = mxser_get_icount, 2332 2331 }; 2333 2332
-11
drivers/tty/n_gsm.c
··· 2614 2614 } 2615 2615 } 2616 2616 2617 - #ifdef CONFIG_COMPAT 2618 - static 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 2618 * Network interface 2627 2619 * ··· 2825 2833 .flush_buffer = gsmld_flush_buffer, 2826 2834 .read = gsmld_read, 2827 2835 .write = gsmld_write, 2828 - #ifdef CONFIG_COMPAT 2829 - .compat_ioctl = gsmld_compat_ioctl, 2830 - #endif 2831 2836 .ioctl = gsmld_ioctl, 2832 2837 .poll = gsmld_poll, 2833 2838 .receive_buf = gsmld_receive_buf,
+22
drivers/tty/n_r3964.c
··· 134 134 const unsigned char *buf, size_t nr); 135 135 static int r3964_ioctl(struct tty_struct *tty, struct file *file, 136 136 unsigned int cmd, unsigned long arg); 137 + #ifdef CONFIG_COMPAT 138 + static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file, 139 + unsigned int cmd, unsigned long arg); 140 + #endif 137 141 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old); 138 142 static __poll_t r3964_poll(struct tty_struct *tty, struct file *file, 139 143 struct poll_table_struct *wait); ··· 153 149 .read = r3964_read, 154 150 .write = r3964_write, 155 151 .ioctl = r3964_ioctl, 152 + #ifdef CONFIG_COMPAT 153 + .compat_ioctl = r3964_compat_ioctl, 154 + #endif 156 155 .set_termios = r3964_set_termios, 157 156 .poll = r3964_poll, 158 157 .receive_buf = r3964_receive_buf, ··· 1216 1209 return -ENOIOCTLCMD; 1217 1210 } 1218 1211 } 1212 + 1213 + #ifdef CONFIG_COMPAT 1214 + static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file, 1215 + unsigned int cmd, unsigned long arg) 1216 + { 1217 + switch (cmd) { 1218 + case R3964_ENABLE_SIGNALS: 1219 + case R3964_SETPRIORITY: 1220 + case R3964_USE_BCC: 1221 + return r3964_ioctl(tty, file, cmd, arg); 1222 + default: 1223 + return -ENOIOCTLCMD; 1224 + } 1225 + } 1226 + #endif 1219 1227 1220 1228 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old) 1221 1229 {
+12 -2
drivers/tty/pty.c
··· 28 28 #include <linux/mount.h> 29 29 #include <linux/file.h> 30 30 #include <linux/ioctl.h> 31 + #include <linux/compat.h> 31 32 32 33 #undef TTY_DEBUG_HANGUP 33 34 #ifdef TTY_DEBUG_HANGUP ··· 489 488 return -ENOIOCTLCMD; 490 489 } 491 490 491 + #ifdef CONFIG_COMPAT 492 492 static long pty_bsd_compat_ioctl(struct tty_struct *tty, 493 493 unsigned int cmd, unsigned long arg) 494 494 { ··· 497 495 * PTY ioctls don't require any special translation between 32-bit and 498 496 * 64-bit userspace, they are already compatible. 499 497 */ 500 - return pty_bsd_ioctl(tty, cmd, arg); 498 + return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg)); 501 499 } 500 + #else 501 + #define pty_bsd_compat_ioctl NULL 502 + #endif 502 503 503 504 static int legacy_count = CONFIG_LEGACY_PTY_COUNT; 504 505 /* ··· 681 676 return -ENOIOCTLCMD; 682 677 } 683 678 679 + #ifdef CONFIG_COMPAT 684 680 static long pty_unix98_compat_ioctl(struct tty_struct *tty, 685 681 unsigned int cmd, unsigned long arg) 686 682 { ··· 689 683 * PTY ioctls don't require any special translation between 32-bit and 690 684 * 64-bit userspace, they are already compatible. 691 685 */ 692 - return pty_unix98_ioctl(tty, cmd, arg); 686 + return pty_unix98_ioctl(tty, cmd, 687 + cmd == TIOCSIG ? arg : (unsigned long)compat_ptr(arg)); 693 688 } 689 + #else 690 + #define pty_unix98_compat_ioctl NULL 691 + #endif 694 692 695 693 /** 696 694 * ptm_unix98_lookup - find a pty master
+12 -31
drivers/tty/serial/serial_core.c
··· 778 778 return ret; 779 779 } 780 780 781 - static int uart_get_info_user(struct tty_port *port, 782 - struct serial_struct __user *retinfo) 781 + static int uart_get_info_user(struct tty_struct *tty, 782 + struct serial_struct *ss) 783 783 { 784 - struct serial_struct tmp; 784 + struct uart_state *state = tty->driver_data; 785 + struct tty_port *port = &state->port; 785 786 786 - if (uart_get_info(port, &tmp) < 0) 787 - return -EIO; 788 - 789 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 790 - return -EFAULT; 791 - return 0; 787 + return uart_get_info(port, ss) < 0 ? -EIO : 0; 792 788 } 793 789 794 790 static int uart_set_info(struct tty_struct *tty, struct tty_port *port, ··· 986 990 return retval; 987 991 } 988 992 989 - static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state, 990 - struct serial_struct __user *newinfo) 993 + static int uart_set_info_user(struct tty_struct *tty, struct serial_struct *ss) 991 994 { 992 - struct serial_struct new_serial; 995 + struct uart_state *state = tty->driver_data; 993 996 struct tty_port *port = &state->port; 994 997 int retval; 995 998 996 - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 997 - return -EFAULT; 998 - 999 + down_write(&tty->termios_rwsem); 999 1000 /* 1000 1001 * This semaphore protects port->count. It is also 1001 1002 * very useful to prevent opens. Also, take the ··· 1001 1008 * under us. 1002 1009 */ 1003 1010 mutex_lock(&port->mutex); 1004 - retval = uart_set_info(tty, port, state, &new_serial); 1011 + retval = uart_set_info(tty, port, state, ss); 1005 1012 mutex_unlock(&port->mutex); 1013 + up_write(&tty->termios_rwsem); 1006 1014 return retval; 1007 1015 } 1008 1016 ··· 1319 1325 * These ioctls don't rely on the hardware to be present. 1320 1326 */ 1321 1327 switch (cmd) { 1322 - case TIOCGSERIAL: 1323 - ret = uart_get_info_user(port, uarg); 1324 - break; 1325 - 1326 - case TIOCSSERIAL: 1327 - down_write(&tty->termios_rwsem); 1328 - ret = uart_set_info_user(tty, state, uarg); 1329 - up_write(&tty->termios_rwsem); 1330 - break; 1331 - 1332 1328 case TIOCSERCONFIG: 1333 1329 down_write(&tty->termios_rwsem); 1334 1330 ret = uart_do_autoconfig(tty, state); 1335 1331 up_write(&tty->termios_rwsem); 1336 - break; 1337 - 1338 - case TIOCSERGWILD: /* obsolete */ 1339 - case TIOCSERSWILD: /* obsolete */ 1340 - ret = 0; 1341 1332 break; 1342 1333 } 1343 1334 ··· 2392 2413 #endif 2393 2414 .tiocmget = uart_tiocmget, 2394 2415 .tiocmset = uart_tiocmset, 2416 + .set_serial = uart_set_info_user, 2417 + .get_serial = uart_get_info_user, 2395 2418 .get_icount = uart_get_icount, 2396 2419 #ifdef CONFIG_CONSOLE_POLL 2397 2420 .poll_init = uart_poll_init,
+1 -2
drivers/tty/synclink.c
··· 2959 2959 if (mgsl_paranoia_check(info, tty->name, "mgsl_ioctl")) 2960 2960 return -ENODEV; 2961 2961 2962 - if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 2963 - (cmd != TIOCMIWAIT)) { 2962 + if (cmd != TIOCMIWAIT) { 2964 2963 if (tty_io_error(tty)) 2965 2964 return -EIO; 2966 2965 }
+1 -2
drivers/tty/synclinkmp.c
··· 1259 1259 if (sanity_check(info, tty->name, "ioctl")) 1260 1260 return -ENODEV; 1261 1261 1262 - if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1263 - (cmd != TIOCMIWAIT)) { 1262 + if (cmd != TIOCMIWAIT) { 1264 1263 if (tty_io_error(tty)) 1265 1264 return -EIO; 1266 1265 }
+186 -43
drivers/tty/tty_io.c
··· 97 97 #include <linux/seq_file.h> 98 98 #include <linux/serial.h> 99 99 #include <linux/ratelimit.h> 100 + #include <linux/compat.h> 100 101 101 102 #include <linux/uaccess.h> 102 103 ··· 2294 2293 } 2295 2294 2296 2295 /** 2297 - * fionbio - non blocking ioctl 2298 - * @file: file to set blocking value 2299 - * @p: user parameter 2300 - * 2301 - * Historical tty interfaces had a blocking control ioctl before 2302 - * the generic functionality existed. This piece of history is preserved 2303 - * in the expected tty API of posix OS's. 2304 - * 2305 - * Locking: none, the open file handle ensures it won't go away. 2306 - */ 2307 - 2308 - static int fionbio(struct file *file, int __user *p) 2309 - { 2310 - int nonblock; 2311 - 2312 - if (get_user(nonblock, p)) 2313 - return -EFAULT; 2314 - 2315 - spin_lock(&file->f_lock); 2316 - if (nonblock) 2317 - file->f_flags |= O_NONBLOCK; 2318 - else 2319 - file->f_flags &= ~O_NONBLOCK; 2320 - spin_unlock(&file->f_lock); 2321 - return 0; 2322 - } 2323 - 2324 - /** 2325 2296 * tiocsetd - set line discipline 2326 2297 * @tty: tty device 2327 2298 * @p: pointer to user data ··· 2461 2488 return 0; 2462 2489 } 2463 2490 2464 - static void tty_warn_deprecated_flags(struct serial_struct __user *ss) 2491 + static int tty_tiocsserial(struct tty_struct *tty, struct serial_struct __user *ss) 2465 2492 { 2466 2493 static DEFINE_RATELIMIT_STATE(depr_flags, 2467 2494 DEFAULT_RATELIMIT_INTERVAL, 2468 2495 DEFAULT_RATELIMIT_BURST); 2469 2496 char comm[TASK_COMM_LEN]; 2497 + struct serial_struct v; 2470 2498 int flags; 2471 2499 2472 - if (get_user(flags, &ss->flags)) 2473 - return; 2500 + if (copy_from_user(&v, ss, sizeof(struct serial_struct))) 2501 + return -EFAULT; 2474 2502 2475 - flags &= ASYNC_DEPRECATED; 2503 + flags = v.flags & ASYNC_DEPRECATED; 2476 2504 2477 2505 if (flags && __ratelimit(&depr_flags)) 2478 2506 pr_warn("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n", 2479 2507 __func__, get_task_comm(comm, current), flags); 2508 + if (!tty->ops->set_serial) 2509 + return -ENOTTY; 2510 + return tty->ops->set_serial(tty, &v); 2511 + } 2512 + 2513 + static int tty_tiocgserial(struct tty_struct *tty, struct serial_struct __user *ss) 2514 + { 2515 + struct serial_struct v; 2516 + int err; 2517 + 2518 + memset(&v, 0, sizeof(struct serial_struct)); 2519 + if (!tty->ops->get_serial) 2520 + return -ENOTTY; 2521 + err = tty->ops->get_serial(tty, &v); 2522 + if (!err && copy_to_user(ss, &v, sizeof(struct serial_struct))) 2523 + err = -EFAULT; 2524 + return err; 2480 2525 } 2481 2526 2482 2527 /* ··· 2557 2566 return tiocswinsz(real_tty, p); 2558 2567 case TIOCCONS: 2559 2568 return real_tty != tty ? -EINVAL : tioccons(file); 2560 - case FIONBIO: 2561 - return fionbio(file, p); 2562 2569 case TIOCEXCL: 2563 2570 set_bit(TTY_EXCLUSIVE, &tty->flags); 2564 2571 return 0; ··· 2611 2622 case TIOCMBIS: 2612 2623 return tty_tiocmset(tty, cmd, p); 2613 2624 case TIOCGICOUNT: 2614 - retval = tty_tiocgicount(tty, p); 2615 - /* For the moment allow fall through to the old method */ 2616 - if (retval != -EINVAL) 2617 - return retval; 2618 - break; 2625 + return tty_tiocgicount(tty, p); 2619 2626 case TCFLSH: 2620 2627 switch (arg) { 2621 2628 case TCIFLUSH: ··· 2622 2637 } 2623 2638 break; 2624 2639 case TIOCSSERIAL: 2625 - tty_warn_deprecated_flags(p); 2626 - break; 2640 + return tty_tiocsserial(tty, p); 2641 + case TIOCGSERIAL: 2642 + return tty_tiocgserial(tty, p); 2627 2643 case TIOCGPTPEER: 2628 2644 /* Special because the struct file is needed */ 2629 2645 return ptm_open_peer(file, tty, (int)arg); ··· 2652 2666 } 2653 2667 2654 2668 #ifdef CONFIG_COMPAT 2669 + 2670 + struct serial_struct32 { 2671 + compat_int_t type; 2672 + compat_int_t line; 2673 + compat_uint_t port; 2674 + compat_int_t irq; 2675 + compat_int_t flags; 2676 + compat_int_t xmit_fifo_size; 2677 + compat_int_t custom_divisor; 2678 + compat_int_t baud_base; 2679 + unsigned short close_delay; 2680 + char io_type; 2681 + char reserved_char[1]; 2682 + compat_int_t hub6; 2683 + unsigned short closing_wait; /* time to wait before closing */ 2684 + unsigned short closing_wait2; /* no longer used... */ 2685 + compat_uint_t iomem_base; 2686 + unsigned short iomem_reg_shift; 2687 + unsigned int port_high; 2688 + /* compat_ulong_t iomap_base FIXME */ 2689 + compat_int_t reserved[1]; 2690 + }; 2691 + 2692 + static int compat_tty_tiocsserial(struct tty_struct *tty, 2693 + struct serial_struct32 __user *ss) 2694 + { 2695 + static DEFINE_RATELIMIT_STATE(depr_flags, 2696 + DEFAULT_RATELIMIT_INTERVAL, 2697 + DEFAULT_RATELIMIT_BURST); 2698 + char comm[TASK_COMM_LEN]; 2699 + struct serial_struct32 v32; 2700 + struct serial_struct v; 2701 + int flags; 2702 + 2703 + if (copy_from_user(&v32, ss, sizeof(struct serial_struct32))) 2704 + return -EFAULT; 2705 + 2706 + memcpy(&v, &v32, offsetof(struct serial_struct32, iomem_base)); 2707 + v.iomem_base = compat_ptr(v32.iomem_base); 2708 + v.iomem_reg_shift = v32.iomem_reg_shift; 2709 + v.port_high = v32.port_high; 2710 + v.iomap_base = 0; 2711 + 2712 + flags = v.flags & ASYNC_DEPRECATED; 2713 + 2714 + if (flags && __ratelimit(&depr_flags)) 2715 + pr_warn("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n", 2716 + __func__, get_task_comm(comm, current), flags); 2717 + if (!tty->ops->set_serial) 2718 + return -ENOTTY; 2719 + return tty->ops->set_serial(tty, &v); 2720 + } 2721 + 2722 + static int compat_tty_tiocgserial(struct tty_struct *tty, 2723 + struct serial_struct32 __user *ss) 2724 + { 2725 + struct serial_struct32 v32; 2726 + struct serial_struct v; 2727 + int err; 2728 + memset(&v, 0, sizeof(struct serial_struct)); 2729 + 2730 + if (!tty->ops->set_serial) 2731 + return -ENOTTY; 2732 + err = tty->ops->get_serial(tty, &v); 2733 + if (!err) { 2734 + memcpy(&v32, &v, offsetof(struct serial_struct32, iomem_base)); 2735 + v32.iomem_base = (unsigned long)v.iomem_base >> 32 ? 2736 + 0xfffffff : ptr_to_compat(v.iomem_base); 2737 + v32.iomem_reg_shift = v.iomem_reg_shift; 2738 + v32.port_high = v.port_high; 2739 + if (copy_to_user(ss, &v32, sizeof(struct serial_struct32))) 2740 + err = -EFAULT; 2741 + } 2742 + return err; 2743 + } 2655 2744 static long tty_compat_ioctl(struct file *file, unsigned int cmd, 2656 2745 unsigned long arg) 2657 2746 { ··· 2734 2673 struct tty_ldisc *ld; 2735 2674 int retval = -ENOIOCTLCMD; 2736 2675 2676 + switch (cmd) { 2677 + case TIOCSTI: 2678 + case TIOCGWINSZ: 2679 + case TIOCSWINSZ: 2680 + case TIOCGEXCL: 2681 + case TIOCGETD: 2682 + case TIOCSETD: 2683 + case TIOCGDEV: 2684 + case TIOCMGET: 2685 + case TIOCMSET: 2686 + case TIOCMBIC: 2687 + case TIOCMBIS: 2688 + case TIOCGICOUNT: 2689 + case TIOCGPGRP: 2690 + case TIOCSPGRP: 2691 + case TIOCGSID: 2692 + case TIOCSERGETLSR: 2693 + case TIOCGRS485: 2694 + case TIOCSRS485: 2695 + #ifdef TIOCGETP 2696 + case TIOCGETP: 2697 + case TIOCSETP: 2698 + case TIOCSETN: 2699 + #endif 2700 + #ifdef TIOCGETC 2701 + case TIOCGETC: 2702 + case TIOCSETC: 2703 + #endif 2704 + #ifdef TIOCGLTC 2705 + case TIOCGLTC: 2706 + case TIOCSLTC: 2707 + #endif 2708 + case TCSETSF: 2709 + case TCSETSW: 2710 + case TCSETS: 2711 + case TCGETS: 2712 + #ifdef TCGETS2 2713 + case TCGETS2: 2714 + case TCSETSF2: 2715 + case TCSETSW2: 2716 + case TCSETS2: 2717 + #endif 2718 + case TCGETA: 2719 + case TCSETAF: 2720 + case TCSETAW: 2721 + case TCSETA: 2722 + case TIOCGLCKTRMIOS: 2723 + case TIOCSLCKTRMIOS: 2724 + #ifdef TCGETX 2725 + case TCGETX: 2726 + case TCSETX: 2727 + case TCSETXW: 2728 + case TCSETXF: 2729 + #endif 2730 + case TIOCGSOFTCAR: 2731 + case TIOCSSOFTCAR: 2732 + return tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); 2733 + case TIOCCONS: 2734 + case TIOCEXCL: 2735 + case TIOCNXCL: 2736 + case TIOCVHANGUP: 2737 + case TIOCSBRK: 2738 + case TIOCCBRK: 2739 + case TCSBRK: 2740 + case TCSBRKP: 2741 + case TCFLSH: 2742 + case TIOCGPTPEER: 2743 + case TIOCNOTTY: 2744 + case TIOCSCTTY: 2745 + case TCXONC: 2746 + case TIOCMIWAIT: 2747 + case TIOCSERCONFIG: 2748 + return tty_ioctl(file, cmd, arg); 2749 + } 2750 + 2737 2751 if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) 2738 2752 return -EINVAL; 2739 2753 2754 + switch (cmd) { 2755 + case TIOCSSERIAL: 2756 + return compat_tty_tiocsserial(tty, compat_ptr(arg)); 2757 + case TIOCGSERIAL: 2758 + return compat_tty_tiocgserial(tty, compat_ptr(arg)); 2759 + } 2740 2760 if (tty->ops->compat_ioctl) { 2741 2761 retval = tty->ops->compat_ioctl(tty, cmd, arg); 2742 2762 if (retval != -ENOIOCTLCMD) ··· 2829 2687 return hung_up_tty_compat_ioctl(file, cmd, arg); 2830 2688 if (ld->ops->compat_ioctl) 2831 2689 retval = ld->ops->compat_ioctl(tty, file, cmd, arg); 2832 - else 2833 - retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg); 2690 + if (retval == -ENOIOCTLCMD && ld->ops->ioctl) 2691 + retval = ld->ops->ioctl(tty, file, 2692 + (unsigned long)compat_ptr(cmd), arg); 2834 2693 tty_ldisc_deref(ld); 2835 2694 2836 2695 return retval;
-16
drivers/tty/tty_ioctl.c
··· 941 941 } 942 942 } 943 943 EXPORT_SYMBOL(n_tty_ioctl_helper); 944 - 945 - #ifdef CONFIG_COMPAT 946 - long 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 - } 957 - EXPORT_SYMBOL(n_tty_compat_ioctl_helper); 958 - #endif 959 -
+9 -22
drivers/tty/vt/vt_ioctl.c
··· 1175 1175 { 1176 1176 struct vc_data *vc = tty->driver_data; 1177 1177 struct console_font_op op; /* used in multiple places here */ 1178 - unsigned int console; 1179 - void __user *up = (void __user *)arg; 1178 + unsigned int console = vc->vc_num; 1179 + void __user *up = compat_ptr(arg); 1180 1180 int perm; 1181 - int ret = 0; 1182 1181 1183 - console = vc->vc_num; 1184 1182 1185 - if (!vc_cons_allocated(console)) { /* impossible? */ 1186 - ret = -ENOIOCTLCMD; 1187 - goto out; 1188 - } 1183 + if (!vc_cons_allocated(console)) /* impossible? */ 1184 + return -ENOIOCTLCMD; 1189 1185 1190 1186 /* 1191 1187 * To have permissions to do most of the vt ioctls, we either have ··· 1197 1201 */ 1198 1202 case PIO_FONTX: 1199 1203 case GIO_FONTX: 1200 - ret = compat_fontx_ioctl(cmd, up, perm, &op); 1201 - break; 1204 + return compat_fontx_ioctl(cmd, up, perm, &op); 1202 1205 1203 1206 case KDFONTOP: 1204 - ret = compat_kdfontop_ioctl(up, perm, &op, vc); 1205 - break; 1207 + return compat_kdfontop_ioctl(up, perm, &op, vc); 1206 1208 1207 1209 case PIO_UNIMAP: 1208 1210 case GIO_UNIMAP: 1209 - ret = compat_unimap_ioctl(cmd, up, perm, vc); 1210 - break; 1211 + return compat_unimap_ioctl(cmd, up, perm, vc); 1211 1212 1212 1213 /* 1213 1214 * all these treat 'arg' as an integer ··· 1229 1236 case VT_DISALLOCATE: 1230 1237 case VT_RESIZE: 1231 1238 case VT_RESIZEX: 1232 - goto fallback; 1239 + return vt_ioctl(tty, cmd, arg); 1233 1240 1234 1241 /* 1235 1242 * the rest has a compatible data structure behind arg, 1236 1243 * but we have to convert it to a proper 64 bit pointer. 1237 1244 */ 1238 1245 default: 1239 - arg = (unsigned long)compat_ptr(arg); 1240 - goto fallback; 1246 + return vt_ioctl(tty, cmd, (unsigned long)up); 1241 1247 } 1242 - out: 1243 - return ret; 1244 - 1245 - fallback: 1246 - return vt_ioctl(tty, cmd, arg); 1247 1248 } 1248 1249 1249 1250
+14 -27
drivers/usb/class/cdc-acm.c
··· 884 884 return acm_set_control(acm, acm->ctrlout = newctrl); 885 885 } 886 886 887 - static int get_serial_info(struct acm *acm, struct serial_struct __user *info) 887 + static 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)); 892 - tmp.xmit_fifo_size = acm->writesize; 893 - tmp.baud_base = le32_to_cpu(acm->line.dwDTERate); 894 - tmp.close_delay = acm->port.close_delay / 10; 895 - tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? 891 + ss->xmit_fifo_size = acm->writesize; 892 + ss->baud_base = le32_to_cpu(acm->line.dwDTERate); 893 + ss->close_delay = acm->port.close_delay / 10; 894 + ss->closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? 896 895 ASYNC_CLOSING_WAIT_NONE : 897 896 acm->port.closing_wait / 10; 898 - 899 - if (copy_to_user(info, &tmp, sizeof(tmp))) 900 - return -EFAULT; 901 - else 902 - return 0; 897 + return 0; 903 898 } 904 899 905 - static int set_serial_info(struct acm *acm, 906 - struct serial_struct __user *newinfo) 900 + static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss) 907 901 { 908 - struct serial_struct new_serial; 902 + struct acm *acm = tty->driver_data; 909 903 unsigned int closing_wait, close_delay; 910 904 int retval = 0; 911 905 912 - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 913 - return -EFAULT; 914 - 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; 906 + close_delay = ss->close_delay * 10; 907 + closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ? 908 + ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10; 918 909 919 910 mutex_lock(&acm->port.mutex); 920 911 ··· 990 999 int rv = -ENOIOCTLCMD; 991 1000 992 1001 switch (cmd) { 993 - case TIOCGSERIAL: /* gets serial port data */ 994 - rv = get_serial_info(acm, (struct serial_struct __user *) arg); 995 - break; 996 - case TIOCSSERIAL: 997 - rv = set_serial_info(acm, (struct serial_struct __user *) arg); 998 - break; 999 1002 case TIOCMIWAIT: 1000 1003 rv = usb_autopm_get_interface(acm->control); 1001 1004 if (rv < 0) { ··· 1916 1931 .set_termios = acm_tty_set_termios, 1917 1932 .tiocmget = acm_tty_tiocmget, 1918 1933 .tiocmset = acm_tty_tiocmset, 1934 + .get_serial = get_serial_info, 1935 + .set_serial = set_serial_info, 1919 1936 .get_icount = acm_tty_get_icount, 1920 1937 }; 1921 1938
+8 -30
drivers/usb/serial/ark3116.c
··· 397 397 return result; 398 398 } 399 399 400 - static int ark3116_get_serial_info(struct usb_serial_port *port, 401 - struct serial_struct __user *retinfo) 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 - 418 - static int ark3116_ioctl(struct tty_struct *tty, 419 - unsigned int cmd, unsigned long arg) 400 + static int ark3116_get_serial_info(struct tty_struct *tty, 401 + struct serial_struct *ss) 420 402 { 421 403 struct usb_serial_port *port = tty->driver_data; 422 - void __user *user_arg = (void __user *)arg; 423 404 424 - switch (cmd) { 425 - case TIOCGSERIAL: 426 - return ark3116_get_serial_info(port, user_arg); 427 - default: 428 - break; 429 - } 430 - 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 434 412 static int ark3116_tiocmget(struct tty_struct *tty) ··· 646 668 .port_remove = ark3116_port_remove, 647 669 .set_termios = ark3116_set_termios, 648 670 .init_termios = ark3116_init_termios, 649 - .ioctl = ark3116_ioctl, 671 + .get_serial = ark3116_get_serial_info, 650 672 .tiocmget = ark3116_tiocmget, 651 673 .tiocmset = ark3116_tiocmset, 652 674 .tiocmiwait = usb_serial_generic_tiocmiwait,
+8 -28
drivers/usb/serial/f81232.c
··· 583 583 return 0; 584 584 } 585 585 586 - static int f81232_get_serial_info(struct usb_serial_port *port, 587 - unsigned long arg) 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 - 604 - static int f81232_ioctl(struct tty_struct *tty, 605 - unsigned int cmd, unsigned long arg) 586 + static int f81232_get_serial_info(struct tty_struct *tty, 587 + struct serial_struct *ss) 606 588 { 607 589 struct usb_serial_port *port = tty->driver_data; 608 590 609 - switch (cmd) { 610 - case TIOCGSERIAL: 611 - return f81232_get_serial_info(port, arg); 612 - default: 613 - break; 614 - } 615 - return -ENOIOCTLCMD; 591 + ss->type = PORT_16550A; 592 + ss->line = port->minor; 593 + ss->port = port->port_number; 594 + ss->baud_base = F81232_MAX_BAUDRATE; 595 + return 0; 616 596 } 617 597 618 598 static void f81232_interrupt_work(struct work_struct *work) ··· 645 665 .close = f81232_close, 646 666 .dtr_rts = f81232_dtr_rts, 647 667 .carrier_raised = f81232_carrier_raised, 648 - .ioctl = f81232_ioctl, 668 + .get_serial = f81232_get_serial_info, 649 669 .break_ctl = f81232_break_ctl, 650 670 .set_termios = f81232_set_termios, 651 671 .tiocmget = f81232_tiocmget,
+8 -30
drivers/usb/serial/f81534.c
··· 1139 1139 mutex_unlock(&serial_priv->urb_mutex); 1140 1140 } 1141 1141 1142 - static int f81534_get_serial_info(struct usb_serial_port *port, 1143 - struct serial_struct __user *retinfo) 1142 + static int f81534_get_serial_info(struct tty_struct *tty, 1143 + struct serial_struct *ss) 1144 1144 { 1145 + struct usb_serial_port *port = tty->driver_data; 1145 1146 struct f81534_port_private *port_priv; 1146 - struct serial_struct tmp; 1147 1147 1148 1148 port_priv = usb_get_serial_port_data(port); 1149 1149 1150 - memset(&tmp, 0, sizeof(tmp)); 1151 - 1152 - tmp.type = PORT_16550A; 1153 - tmp.port = port->port_number; 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 - 1150 + ss->type = PORT_16550A; 1151 + ss->port = port->port_number; 1152 + ss->line = port->minor; 1153 + ss->baud_base = port_priv->baud_base; 1160 1154 return 0; 1161 - } 1162 - 1163 - static 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 1155 } 1178 1156 1179 1157 static void f81534_process_per_serial_block(struct usb_serial_port *port, ··· 1559 1581 .break_ctl = f81534_break_ctl, 1560 1582 .dtr_rts = f81534_dtr_rts, 1561 1583 .process_read_urb = f81534_process_read_urb, 1562 - .ioctl = f81534_ioctl, 1584 + .get_serial = f81534_get_serial_info, 1563 1585 .tiocmget = f81534_tiocmget, 1564 1586 .tiocmset = f81534_tiocmset, 1565 1587 .write_bulk_callback = f81534_write_usb_callback,
+21 -27
drivers/usb/serial/ftdi_sio.c
··· 1055 1055 unsigned int set, unsigned int clear); 1056 1056 static int ftdi_ioctl(struct tty_struct *tty, 1057 1057 unsigned int cmd, unsigned long arg); 1058 + static int get_serial_info(struct tty_struct *tty, 1059 + struct serial_struct *ss); 1060 + static int set_serial_info(struct tty_struct *tty, 1061 + struct serial_struct *ss); 1058 1062 static void ftdi_break_ctl(struct tty_struct *tty, int break_state); 1059 1063 static bool ftdi_tx_empty(struct usb_serial_port *port); 1060 1064 static int ftdi_get_modem_status(struct usb_serial_port *port, ··· 1095 1091 .tiocmiwait = usb_serial_generic_tiocmiwait, 1096 1092 .get_icount = usb_serial_generic_get_icount, 1097 1093 .ioctl = ftdi_ioctl, 1094 + .get_serial = get_serial_info, 1095 + .set_serial = set_serial_info, 1098 1096 .set_termios = ftdi_set_termios, 1099 1097 .break_ctl = ftdi_break_ctl, 1100 1098 .tx_empty = ftdi_tx_empty, ··· 1449 1443 return 0; 1450 1444 } 1451 1445 1452 - static int get_serial_info(struct usb_serial_port *port, 1453 - struct serial_struct __user *retinfo) 1446 + static int get_serial_info(struct tty_struct *tty, 1447 + struct serial_struct *ss) 1454 1448 { 1449 + struct usb_serial_port *port = tty->driver_data; 1455 1450 struct ftdi_private *priv = usb_get_serial_port_data(port); 1456 - struct serial_struct tmp; 1457 1451 1458 - memset(&tmp, 0, sizeof(tmp)); 1459 - tmp.flags = priv->flags; 1460 - tmp.baud_base = priv->baud_base; 1461 - tmp.custom_divisor = priv->custom_divisor; 1462 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1463 - return -EFAULT; 1452 + ss->flags = priv->flags; 1453 + ss->baud_base = priv->baud_base; 1454 + ss->custom_divisor = priv->custom_divisor; 1464 1455 return 0; 1465 1456 } 1466 1457 1467 1458 static int set_serial_info(struct tty_struct *tty, 1468 - struct usb_serial_port *port, struct serial_struct __user *newinfo) 1459 + struct serial_struct *ss) 1469 1460 { 1461 + struct usb_serial_port *port = tty->driver_data; 1470 1462 struct ftdi_private *priv = usb_get_serial_port_data(port); 1471 - struct serial_struct new_serial; 1472 1463 struct ftdi_private old_priv; 1473 - 1474 - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 1475 - return -EFAULT; 1476 1464 1477 1465 mutex_lock(&priv->cfg_lock); 1478 1466 old_priv = *priv; ··· 1474 1474 /* Do error checking and permission checking */ 1475 1475 1476 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 1478 mutex_unlock(&priv->cfg_lock); 1479 1479 return -EPERM; 1480 1480 } 1481 1481 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1482 - (new_serial.flags & ASYNC_USR_MASK)); 1483 - priv->custom_divisor = new_serial.custom_divisor; 1482 + (ss->flags & ASYNC_USR_MASK)); 1483 + priv->custom_divisor = ss->custom_divisor; 1484 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 1488 mutex_unlock(&priv->cfg_lock); 1489 1489 return -EINVAL; 1490 1490 } ··· 1492 1492 /* Make the changes - these are privileged changes! */ 1493 1493 1494 1494 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 1495 - (new_serial.flags & ASYNC_FLAGS)); 1496 - priv->custom_divisor = new_serial.custom_divisor; 1495 + (ss->flags & ASYNC_FLAGS)); 1496 + priv->custom_divisor = ss->custom_divisor; 1497 1497 1498 1498 check_and_exit: 1499 1499 write_latency_timer(port); ··· 1507 1507 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n"); 1508 1508 1509 1509 change_speed(tty, port); 1510 - mutex_unlock(&priv->cfg_lock); 1511 1510 } 1512 - else 1513 - mutex_unlock(&priv->cfg_lock); 1511 + mutex_unlock(&priv->cfg_lock); 1514 1512 return 0; 1515 1513 } 1516 1514 ··· 2450 2452 void __user *argp = (void __user *)arg; 2451 2453 2452 2454 switch (cmd) { 2453 - case TIOCGSERIAL: 2454 - return get_serial_info(port, argp); 2455 - case TIOCSSERIAL: 2456 - return set_serial_info(tty, port, argp); 2457 2455 case TIOCSERGETLSR: 2458 2456 return get_lsr_info(port, argp); 2459 2457 default:
+16 -21
drivers/usb/serial/io_edgeport.c
··· 1637 1637 return result; 1638 1638 } 1639 1639 1640 - static int get_serial_info(struct edgeport_port *edge_port, 1641 - struct serial_struct __user *retinfo) 1640 + static int get_serial_info(struct tty_struct *tty, 1641 + struct serial_struct *ss) 1642 1642 { 1643 - struct serial_struct tmp; 1643 + struct usb_serial_port *port = tty->driver_data; 1644 + struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1644 1645 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 - 1656 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1657 - return -EFAULT; 1646 + ss->type = PORT_16550A; 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 1654 return 0; 1659 1655 } 1660 1656 ··· 1663 1667 unsigned int cmd, unsigned long arg) 1664 1668 { 1665 1669 struct usb_serial_port *port = tty->driver_data; 1666 - DEFINE_WAIT(wait); 1667 1670 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1668 1671 1669 1672 switch (cmd) { 1670 1673 case TIOCSERGETLSR: 1671 1674 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); 1672 1675 return get_lsr_info(edge_port, (unsigned int __user *) arg); 1673 - 1674 - case TIOCGSERIAL: 1675 - dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); 1676 - return get_serial_info(edge_port, (struct serial_struct __user *) arg); 1677 1676 } 1678 1677 return -ENOIOCTLCMD; 1679 1678 } ··· 3117 3126 .set_termios = edge_set_termios, 3118 3127 .tiocmget = edge_tiocmget, 3119 3128 .tiocmset = edge_tiocmset, 3129 + .get_serial = get_serial_info, 3120 3130 .tiocmiwait = usb_serial_generic_tiocmiwait, 3121 3131 .get_icount = usb_serial_generic_get_icount, 3122 3132 .write = edge_write, ··· 3153 3161 .set_termios = edge_set_termios, 3154 3162 .tiocmget = edge_tiocmget, 3155 3163 .tiocmset = edge_tiocmset, 3164 + .get_serial = get_serial_info, 3156 3165 .tiocmiwait = usb_serial_generic_tiocmiwait, 3157 3166 .get_icount = usb_serial_generic_get_icount, 3158 3167 .write = edge_write, ··· 3189 3196 .set_termios = edge_set_termios, 3190 3197 .tiocmget = edge_tiocmget, 3191 3198 .tiocmset = edge_tiocmset, 3199 + .get_serial = get_serial_info, 3192 3200 .tiocmiwait = usb_serial_generic_tiocmiwait, 3193 3201 .get_icount = usb_serial_generic_get_icount, 3194 3202 .write = edge_write, ··· 3225 3231 .set_termios = edge_set_termios, 3226 3232 .tiocmget = edge_tiocmget, 3227 3233 .tiocmset = edge_tiocmset, 3234 + .get_serial = get_serial_info, 3228 3235 .tiocmiwait = usb_serial_generic_tiocmiwait, 3229 3236 .get_icount = usb_serial_generic_get_icount, 3230 3237 .write = edge_write,
+14 -33
drivers/usb/serial/io_ti.c
··· 2437 2437 return result; 2438 2438 } 2439 2439 2440 - static int get_serial_info(struct edgeport_port *edge_port, 2441 - struct serial_struct __user *retinfo) 2440 + static int get_serial_info(struct tty_struct *tty, 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 2445 unsigned cwait; 2445 2446 2446 2447 cwait = edge_port->port->port.closing_wait; 2447 2448 if (cwait != ASYNC_CLOSING_WAIT_NONE) 2448 2449 cwait = jiffies_to_msecs(cwait) / 10; 2449 2450 2450 - memset(&tmp, 0, sizeof(tmp)); 2451 - 2452 - tmp.type = PORT_16550A; 2453 - tmp.line = edge_port->port->minor; 2454 - tmp.port = edge_port->port->port_number; 2455 - tmp.irq = 0; 2456 - tmp.xmit_fifo_size = edge_port->port->bulk_out_size; 2457 - tmp.baud_base = 9600; 2458 - tmp.close_delay = 5*HZ; 2459 - tmp.closing_wait = cwait; 2460 - 2461 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 2462 - return -EFAULT; 2451 + ss->type = PORT_16550A; 2452 + ss->line = edge_port->port->minor; 2453 + ss->port = edge_port->port->port_number; 2454 + ss->irq = 0; 2455 + ss->xmit_fifo_size = edge_port->port->bulk_out_size; 2456 + ss->baud_base = 9600; 2457 + ss->close_delay = 5*HZ; 2458 + ss->closing_wait = cwait; 2463 2459 return 0; 2464 - } 2465 - 2466 - static 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 2460 } 2480 2461 2481 2462 static void edge_break(struct tty_struct *tty, int break_state) ··· 2719 2738 .release = edge_release, 2720 2739 .port_probe = edge_port_probe, 2721 2740 .port_remove = edge_port_remove, 2722 - .ioctl = edge_ioctl, 2741 + .get_serial = get_serial_info, 2723 2742 .set_termios = edge_set_termios, 2724 2743 .tiocmget = edge_tiocmget, 2725 2744 .tiocmset = edge_tiocmset, ··· 2758 2777 .release = edge_release, 2759 2778 .port_probe = edge_port_probe, 2760 2779 .port_remove = edge_port_remove, 2761 - .ioctl = edge_ioctl, 2780 + .get_serial = get_serial_info, 2762 2781 .set_termios = edge_set_termios, 2763 2782 .tiocmget = edge_tiocmget, 2764 2783 .tiocmset = edge_tiocmset,
+13 -73
drivers/usb/serial/mos7720.c
··· 1786 1786 return 0; 1787 1787 } 1788 1788 1789 - static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, 1790 - unsigned int __user *value) 1789 + static int get_serial_info(struct tty_struct *tty, 1790 + struct serial_struct *ss) 1791 1791 { 1792 - unsigned int mcr; 1793 - unsigned int arg; 1792 + struct usb_serial_port *port = tty->driver_data; 1793 + struct moschip_port *mos7720_port = usb_get_serial_port_data(port); 1794 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 - 1834 - static 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 - 1850 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1851 - return -EFAULT; 1795 + ss->type = PORT_16550A; 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 1803 return 0; 1853 1804 } 1854 1805 ··· 1818 1867 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); 1819 1868 return get_lsr_info(tty, mos7720_port, 1820 1869 (unsigned int __user *)arg); 1821 - 1822 - /* FIXME: These should be using the mode methods */ 1823 - case TIOCMBIS: 1824 - case TIOCMBIC: 1825 - dev_dbg(&port->dev, "%s TIOCMSET/TIOCMBIC/TIOCMSET\n", __func__); 1826 - return set_modem_info(mos7720_port, cmd, 1827 - (unsigned int __user *)arg); 1828 - 1829 - case TIOCGSERIAL: 1830 - dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); 1831 - return get_serial_info(mos7720_port, 1832 - (struct serial_struct __user *)arg); 1833 1870 } 1834 1871 1835 1872 return -ENOIOCTLCMD; ··· 1954 2015 .ioctl = mos7720_ioctl, 1955 2016 .tiocmget = mos7720_tiocmget, 1956 2017 .tiocmset = mos7720_tiocmset, 2018 + .get_serial = get_serial_info, 1957 2019 .set_termios = mos7720_set_termios, 1958 2020 .write = mos7720_write, 1959 2021 .write_room = mos7720_write_room,
+13 -26
drivers/usb/serial/mos7840.c
··· 1931 1931 * function to get information about serial port 1932 1932 *****************************************************************************/ 1933 1933 1934 - static int mos7840_get_serial_info(struct moschip_port *mos7840_port, 1935 - struct serial_struct __user *retinfo) 1934 + static int mos7840_get_serial_info(struct tty_struct *tty, 1935 + struct serial_struct *ss) 1936 1936 { 1937 - struct serial_struct tmp; 1937 + struct usb_serial_port *port = tty->driver_data; 1938 + struct moschip_port *mos7840_port = mos7840_get_port_private(port); 1938 1939 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 - 1953 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1954 - return -EFAULT; 1940 + ss->type = PORT_16550A; 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 1948 return 0; 1956 1949 } 1957 1950 ··· 1975 1982 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); 1976 1983 return mos7840_get_lsr_info(tty, argp); 1977 1984 1978 - case TIOCGSERIAL: 1979 - dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); 1980 - return mos7840_get_serial_info(mos7840_port, argp); 1981 - 1982 - case TIOCSSERIAL: 1983 - dev_dbg(&port->dev, "%s TIOCSSERIAL\n", __func__); 1984 - break; 1985 1985 default: 1986 1986 break; 1987 1987 } ··· 2362 2376 .calc_num_ports = mos7840_calc_num_ports, 2363 2377 .probe = mos7840_probe, 2364 2378 .ioctl = mos7840_ioctl, 2379 + .get_serial = mos7840_get_serial_info, 2365 2380 .set_termios = mos7840_set_termios, 2366 2381 .break_ctl = mos7840_break, 2367 2382 .tiocmget = mos7840_tiocmget,
+13 -32
drivers/usb/serial/opticon.c
··· 328 328 return 0; 329 329 } 330 330 331 - static int get_serial_info(struct usb_serial_port *port, 332 - struct serial_struct __user *serial) 333 - { 334 - struct serial_struct tmp; 335 - 336 - memset(&tmp, 0x00, sizeof(tmp)); 337 - 338 - /* fake emulate a 16550 uart to make userspace code happy */ 339 - tmp.type = PORT_16550A; 340 - tmp.line = port->minor; 341 - tmp.port = 0; 342 - tmp.irq = 0; 343 - tmp.xmit_fifo_size = 1024; 344 - tmp.baud_base = 9600; 345 - tmp.close_delay = 5*HZ; 346 - tmp.closing_wait = 30*HZ; 347 - 348 - if (copy_to_user(serial, &tmp, sizeof(*serial))) 349 - return -EFAULT; 350 - return 0; 351 - } 352 - 353 - static int opticon_ioctl(struct tty_struct *tty, 354 - unsigned int cmd, unsigned long arg) 331 + static int get_serial_info(struct tty_struct *tty, 332 + struct serial_struct *ss) 355 333 { 356 334 struct usb_serial_port *port = tty->driver_data; 357 335 358 - switch (cmd) { 359 - case TIOCGSERIAL: 360 - return get_serial_info(port, 361 - (struct serial_struct __user *)arg); 362 - } 363 - 364 - return -ENOIOCTLCMD; 336 + /* fake emulate a 16550 uart to make userspace code happy */ 337 + ss->type = PORT_16550A; 338 + ss->line = port->minor; 339 + ss->port = 0; 340 + ss->irq = 0; 341 + ss->xmit_fifo_size = 1024; 342 + ss->baud_base = 9600; 343 + ss->close_delay = 5*HZ; 344 + ss->closing_wait = 30*HZ; 345 + return 0; 365 346 } 366 347 367 348 static int opticon_port_probe(struct usb_serial_port *port) ··· 385 404 .write_room = opticon_write_room, 386 405 .throttle = usb_serial_generic_throttle, 387 406 .unthrottle = usb_serial_generic_unthrottle, 388 - .ioctl = opticon_ioctl, 407 + .get_serial = get_serial_info, 389 408 .tiocmget = opticon_tiocmget, 390 409 .tiocmset = opticon_tiocmset, 391 410 .process_read_urb = opticon_process_read_urb,
+2 -1
drivers/usb/serial/option.c
··· 1966 1966 .chars_in_buffer = usb_wwan_chars_in_buffer, 1967 1967 .tiocmget = usb_wwan_tiocmget, 1968 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 1971 .attach = option_attach, 1971 1972 .release = option_release, 1972 1973 .port_probe = usb_wwan_port_probe,
+8 -21
drivers/usb/serial/pl2303.c
··· 808 808 return 0; 809 809 } 810 810 811 - static int pl2303_ioctl(struct tty_struct *tty, 812 - unsigned int cmd, unsigned long arg) 811 + static int pl2303_get_serial(struct tty_struct *tty, 812 + struct serial_struct *ss) 813 813 { 814 - struct serial_struct ser; 815 814 struct usb_serial_port *port = tty->driver_data; 816 815 817 - switch (cmd) { 818 - case TIOCGSERIAL: 819 - memset(&ser, 0, sizeof ser); 820 - ser.type = PORT_16654; 821 - ser.line = port->minor; 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; 816 + ss->type = PORT_16654; 817 + ss->line = port->minor; 818 + ss->port = port->port_number; 819 + ss->baud_base = 460800; 820 + return 0; 834 821 } 835 822 836 823 static void pl2303_set_break(struct usb_serial_port *port, bool enable) ··· 1003 1016 .close = pl2303_close, 1004 1017 .dtr_rts = pl2303_dtr_rts, 1005 1018 .carrier_raised = pl2303_carrier_raised, 1006 - .ioctl = pl2303_ioctl, 1019 + .get_serial = pl2303_get_serial, 1007 1020 .break_ctl = pl2303_break_ctl, 1008 1021 .set_termios = pl2303_set_termios, 1009 1022 .tiocmget = pl2303_tiocmget,
+11 -31
drivers/usb/serial/quatech2.c
··· 453 453 usb_kill_urb(serial_priv->read_urb); 454 454 } 455 455 456 - static int get_serial_info(struct usb_serial_port *port, 457 - struct serial_struct __user *retinfo) 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 - 475 - static int qt2_ioctl(struct tty_struct *tty, 476 - unsigned int cmd, unsigned long arg) 456 + static int get_serial_info(struct tty_struct *tty, 457 + struct serial_struct *ss) 477 458 { 478 459 struct usb_serial_port *port = tty->driver_data; 479 460 480 - switch (cmd) { 481 - case TIOCGSERIAL: 482 - return get_serial_info(port, 483 - (struct serial_struct __user *)arg); 484 - default: 485 - break; 486 - } 487 - 488 - return -ENOIOCTLCMD; 461 + ss->line = port->minor; 462 + ss->port = 0; 463 + ss->irq = 0; 464 + ss->xmit_fifo_size = port->bulk_out_size; 465 + ss->baud_base = 9600; 466 + ss->close_delay = 5*HZ; 467 + ss->closing_wait = 30*HZ; 468 + return 0; 489 469 } 490 470 491 471 static void qt2_process_status(struct usb_serial_port *port, unsigned char *ch) ··· 993 1013 .tiocmset = qt2_tiocmset, 994 1014 .tiocmiwait = usb_serial_generic_tiocmiwait, 995 1015 .get_icount = usb_serial_generic_get_icount, 996 - .ioctl = qt2_ioctl, 1016 + .get_serial = get_serial_info, 997 1017 .set_termios = qt2_set_termios, 998 1018 }; 999 1019
+11 -31
drivers/usb/serial/ssu100.c
··· 331 331 return usb_serial_generic_open(tty, port); 332 332 } 333 333 334 - static int get_serial_info(struct usb_serial_port *port, 335 - struct serial_struct __user *retinfo) 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 - 353 - static int ssu100_ioctl(struct tty_struct *tty, 354 - unsigned int cmd, unsigned long arg) 334 + static int get_serial_info(struct tty_struct *tty, 335 + struct serial_struct *ss) 355 336 { 356 337 struct usb_serial_port *port = tty->driver_data; 357 338 358 - switch (cmd) { 359 - case TIOCGSERIAL: 360 - return get_serial_info(port, 361 - (struct serial_struct __user *) arg); 362 - default: 363 - break; 364 - } 365 - 366 - return -ENOIOCTLCMD; 339 + ss->line = port->minor; 340 + ss->port = 0; 341 + ss->irq = 0; 342 + ss->xmit_fifo_size = port->bulk_out_size; 343 + ss->baud_base = 9600; 344 + ss->close_delay = 5*HZ; 345 + ss->closing_wait = 30*HZ; 346 + return 0; 367 347 } 368 348 369 349 static int ssu100_attach(struct usb_serial *serial) ··· 546 566 .tiocmset = ssu100_tiocmset, 547 567 .tiocmiwait = usb_serial_generic_tiocmiwait, 548 568 .get_icount = usb_serial_generic_get_icount, 549 - .ioctl = ssu100_ioctl, 569 + .get_serial = get_serial_info, 550 570 .set_termios = ssu100_set_termios, 551 571 }; 552 572
+24 -50
drivers/usb/serial/ti_usb_3410_5052.c
··· 313 313 static bool ti_tx_empty(struct usb_serial_port *port); 314 314 static void ti_throttle(struct tty_struct *tty); 315 315 static void ti_unthrottle(struct tty_struct *tty); 316 - static int ti_ioctl(struct tty_struct *tty, 317 - unsigned int cmd, unsigned long arg); 318 316 static void ti_set_termios(struct tty_struct *tty, 319 317 struct usb_serial_port *port, struct ktermios *old_termios); 320 318 static int ti_tiocmget(struct tty_struct *tty); ··· 328 330 static void ti_send(struct ti_port *tport); 329 331 static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); 330 332 static int ti_get_lsr(struct ti_port *tport, u8 *lsr); 331 - static int ti_get_serial_info(struct ti_port *tport, 332 - struct serial_struct __user *ret_arg); 333 - static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, 334 - struct serial_struct __user *new_arg); 333 + static int ti_get_serial_info(struct tty_struct *tty, 334 + struct serial_struct *ss); 335 + static int ti_set_serial_info(struct tty_struct *tty, 336 + struct serial_struct *ss); 335 337 static void ti_handle_new_msr(struct ti_port *tport, u8 msr); 336 338 337 339 static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty); ··· 434 436 .tx_empty = ti_tx_empty, 435 437 .throttle = ti_throttle, 436 438 .unthrottle = ti_unthrottle, 437 - .ioctl = ti_ioctl, 439 + .get_serial = ti_get_serial_info, 440 + .set_serial = ti_set_serial_info, 438 441 .set_termios = ti_set_termios, 439 442 .tiocmget = ti_tiocmget, 440 443 .tiocmset = ti_tiocmset, ··· 468 469 .tx_empty = ti_tx_empty, 469 470 .throttle = ti_throttle, 470 471 .unthrottle = ti_unthrottle, 471 - .ioctl = ti_ioctl, 472 + .get_serial = ti_get_serial_info, 473 + .set_serial = ti_set_serial_info, 472 474 .set_termios = ti_set_termios, 473 475 .tiocmget = ti_tiocmget, 474 476 .tiocmset = ti_tiocmset, ··· 901 901 __func__, status); 902 902 } 903 903 } 904 - 905 - static 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 904 923 905 static void ti_set_termios(struct tty_struct *tty, 924 906 struct usb_serial_port *port, struct ktermios *old_termios) ··· 1399 1417 } 1400 1418 1401 1419 1402 - static int ti_get_serial_info(struct ti_port *tport, 1403 - struct serial_struct __user *ret_arg) 1420 + static int ti_get_serial_info(struct tty_struct *tty, 1421 + struct serial_struct *ss) 1404 1422 { 1405 - struct usb_serial_port *port = tport->tp_port; 1406 - struct serial_struct ret_serial; 1423 + struct usb_serial_port *port = tty->driver_data; 1424 + struct ti_port *tport = usb_get_serial_port_data(port); 1407 1425 unsigned cwait; 1408 1426 1409 1427 cwait = port->port.closing_wait; 1410 1428 if (cwait != ASYNC_CLOSING_WAIT_NONE) 1411 1429 cwait = jiffies_to_msecs(cwait) / 10; 1412 1430 1413 - memset(&ret_serial, 0, sizeof(ret_serial)); 1414 - 1415 - ret_serial.type = PORT_16550A; 1416 - ret_serial.line = port->minor; 1417 - ret_serial.port = port->port_number; 1418 - ret_serial.xmit_fifo_size = kfifo_size(&port->write_fifo); 1419 - ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; 1420 - ret_serial.closing_wait = cwait; 1421 - 1422 - if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg))) 1423 - return -EFAULT; 1424 - 1431 + ss->type = PORT_16550A; 1432 + ss->line = port->minor; 1433 + ss->port = port->port_number; 1434 + ss->xmit_fifo_size = kfifo_size(&port->write_fifo); 1435 + ss->baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; 1436 + ss->closing_wait = cwait; 1425 1437 return 0; 1426 1438 } 1427 1439 1428 1440 1429 - static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, 1430 - struct serial_struct __user *new_arg) 1441 + static int ti_set_serial_info(struct tty_struct *tty, 1442 + struct serial_struct *ss) 1431 1443 { 1432 - struct serial_struct new_serial; 1444 + struct usb_serial_port *port = tty->driver_data; 1445 + struct ti_port *tport = usb_get_serial_port_data(port); 1433 1446 unsigned cwait; 1434 1447 1435 - if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) 1436 - return -EFAULT; 1437 - 1438 - cwait = new_serial.closing_wait; 1448 + cwait = ss->closing_wait; 1439 1449 if (cwait != ASYNC_CLOSING_WAIT_NONE) 1440 - cwait = msecs_to_jiffies(10 * new_serial.closing_wait); 1450 + cwait = msecs_to_jiffies(10 * ss->closing_wait); 1441 1451 1442 1452 tport->tp_port->port.closing_wait = cwait; 1443 1453
+20
drivers/usb/serial/usb-serial.c
··· 396 396 port->serial->type->unthrottle(tty); 397 397 } 398 398 399 + static 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 + 408 + static 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 + 399 417 static int serial_ioctl(struct tty_struct *tty, 400 418 unsigned int cmd, unsigned long arg) 401 419 { ··· 1195 1177 .tiocmget = serial_tiocmget, 1196 1178 .tiocmset = serial_tiocmset, 1197 1179 .get_icount = serial_get_icount, 1180 + .set_serial = serial_set_serial, 1181 + .get_serial = serial_get_serial, 1198 1182 .cleanup = serial_cleanup, 1199 1183 .install = serial_install, 1200 1184 .proc_show = serial_proc_show,
+4 -2
drivers/usb/serial/usb-wwan.h
··· 15 15 extern int usb_wwan_tiocmget(struct tty_struct *tty); 16 16 extern int usb_wwan_tiocmset(struct tty_struct *tty, 17 17 unsigned int set, unsigned int clear); 18 - extern int usb_wwan_ioctl(struct tty_struct *tty, 19 - unsigned int cmd, unsigned long arg); 18 + extern int usb_wwan_get_serial_info(struct tty_struct *tty, 19 + struct serial_struct *ss); 20 + extern int usb_wwan_set_serial_info(struct tty_struct *tty, 21 + struct serial_struct *ss); 20 22 extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, 21 23 const unsigned char *buf, int count); 22 24 extern int usb_wwan_chars_in_buffer(struct tty_struct *tty);
+16 -45
drivers/usb/serial/usb_wwan.c
··· 132 132 } 133 133 EXPORT_SYMBOL(usb_wwan_tiocmset); 134 134 135 - static int get_serial_info(struct usb_serial_port *port, 136 - struct serial_struct __user *retinfo) 135 + int usb_wwan_get_serial_info(struct tty_struct *tty, 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)); 141 - tmp.line = port->minor; 142 - tmp.port = port->port_number; 143 - tmp.baud_base = tty_get_baud_rate(port->port.tty); 144 - tmp.close_delay = port->port.close_delay / 10; 145 - tmp.closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? 140 + ss->line = port->minor; 141 + ss->port = port->port_number; 142 + ss->baud_base = tty_get_baud_rate(port->port.tty); 143 + ss->close_delay = port->port.close_delay / 10; 144 + ss->closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? 146 145 ASYNC_CLOSING_WAIT_NONE : 147 146 port->port.closing_wait / 10; 148 - 149 - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 150 - return -EFAULT; 151 147 return 0; 152 148 } 149 + EXPORT_SYMBOL(usb_wwan_get_serial_info); 153 150 154 - static int set_serial_info(struct usb_serial_port *port, 155 - struct serial_struct __user *newinfo) 151 + int usb_wwan_set_serial_info(struct tty_struct *tty, 152 + struct serial_struct *ss) 156 153 { 157 - struct serial_struct new_serial; 154 + struct usb_serial_port *port = tty->driver_data; 158 155 unsigned int closing_wait, close_delay; 159 156 int retval = 0; 160 157 161 - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 162 - return -EFAULT; 163 - 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; 158 + close_delay = ss->close_delay * 10; 159 + closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ? 160 + ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10; 167 161 168 162 mutex_lock(&port->port.mutex); 169 163 ··· 175 181 mutex_unlock(&port->port.mutex); 176 182 return retval; 177 183 } 178 - 179 - int usb_wwan_ioctl(struct tty_struct *tty, 180 - unsigned int cmd, unsigned long arg) 181 - { 182 - struct usb_serial_port *port = tty->driver_data; 183 - 184 - dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd); 185 - 186 - switch (cmd) { 187 - case TIOCGSERIAL: 188 - return get_serial_info(port, 189 - (struct serial_struct __user *) arg); 190 - case TIOCSSERIAL: 191 - return set_serial_info(port, 192 - (struct serial_struct __user *) arg); 193 - default: 194 - break; 195 - } 196 - 197 - dev_dbg(&port->dev, "%s arg not supported\n", __func__); 198 - 199 - return -ENOIOCTLCMD; 200 - } 201 - EXPORT_SYMBOL(usb_wwan_ioctl); 184 + EXPORT_SYMBOL(usb_wwan_set_serial_info); 202 185 203 186 int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, 204 187 const unsigned char *buf, int count)
+14 -26
drivers/usb/serial/whiteheat.c
··· 83 83 static int whiteheat_open(struct tty_struct *tty, 84 84 struct usb_serial_port *port); 85 85 static void whiteheat_close(struct usb_serial_port *port); 86 - static int whiteheat_ioctl(struct tty_struct *tty, 87 - unsigned int cmd, unsigned long arg); 86 + static int whiteheat_get_serial(struct tty_struct *tty, 87 + struct serial_struct *ss); 88 88 static void whiteheat_set_termios(struct tty_struct *tty, 89 89 struct usb_serial_port *port, struct ktermios *old); 90 90 static int whiteheat_tiocmget(struct tty_struct *tty); ··· 120 120 .port_remove = whiteheat_port_remove, 121 121 .open = whiteheat_open, 122 122 .close = whiteheat_close, 123 - .ioctl = whiteheat_ioctl, 123 + .get_serial = whiteheat_get_serial, 124 124 .set_termios = whiteheat_set_termios, 125 125 .break_ctl = whiteheat_break_ctl, 126 126 .tiocmget = whiteheat_tiocmget, ··· 442 442 } 443 443 444 444 445 - static int whiteheat_ioctl(struct tty_struct *tty, 446 - unsigned int cmd, unsigned long arg) 445 + static int whiteheat_get_serial(struct tty_struct *tty, 446 + struct serial_struct *ss) 447 447 { 448 448 struct usb_serial_port *port = tty->driver_data; 449 - struct serial_struct serstruct; 450 - void __user *user_arg = (void __user *)arg; 451 449 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; 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; 463 458 464 - if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) 465 - return -EFAULT; 466 - break; 467 - default: 468 - break; 469 - } 470 - 471 - return -ENOIOCTLCMD; 459 + return 0; 472 460 } 473 461 474 462
-169
fs/compat_ioctl.c
··· 560 560 #define HIDPGETCONNLIST _IOR('H', 210, int) 561 561 #define HIDPGETCONNINFO _IOR('H', 211, int) 562 562 563 - 564 - struct 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 - 586 - static 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 563 #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) 627 564 #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) 628 565 #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) ··· 644 707 645 708 static unsigned int ioctl_pointer[] = { 646 709 /* compatible ioctls first */ 647 - COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */ 648 - COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */ 649 - 650 - /* Big T */ 651 - COMPATIBLE_IOCTL(TCGETA) 652 - COMPATIBLE_IOCTL(TCSETA) 653 - COMPATIBLE_IOCTL(TCSETAW) 654 - COMPATIBLE_IOCTL(TCSETAF) 655 - COMPATIBLE_IOCTL(TCSBRK) 656 - COMPATIBLE_IOCTL(TCXONC) 657 - COMPATIBLE_IOCTL(TCFLSH) 658 - COMPATIBLE_IOCTL(TCGETS) 659 - COMPATIBLE_IOCTL(TCSETS) 660 - COMPATIBLE_IOCTL(TCSETSW) 661 - COMPATIBLE_IOCTL(TCSETSF) 662 - COMPATIBLE_IOCTL(TIOCLINUX) 663 - COMPATIBLE_IOCTL(TIOCSBRK) 664 - COMPATIBLE_IOCTL(TIOCGDEV) 665 - COMPATIBLE_IOCTL(TIOCCBRK) 666 - COMPATIBLE_IOCTL(TIOCGSID) 667 - COMPATIBLE_IOCTL(TIOCGICOUNT) 668 - COMPATIBLE_IOCTL(TIOCGEXCL) 669 710 /* Little t */ 670 - COMPATIBLE_IOCTL(TIOCGETD) 671 - COMPATIBLE_IOCTL(TIOCSETD) 672 - COMPATIBLE_IOCTL(TIOCEXCL) 673 - COMPATIBLE_IOCTL(TIOCNXCL) 674 - COMPATIBLE_IOCTL(TIOCCONS) 675 - COMPATIBLE_IOCTL(TIOCGSOFTCAR) 676 - COMPATIBLE_IOCTL(TIOCSSOFTCAR) 677 - COMPATIBLE_IOCTL(TIOCSWINSZ) 678 - COMPATIBLE_IOCTL(TIOCGWINSZ) 679 - COMPATIBLE_IOCTL(TIOCMGET) 680 - COMPATIBLE_IOCTL(TIOCMBIC) 681 - COMPATIBLE_IOCTL(TIOCMBIS) 682 - COMPATIBLE_IOCTL(TIOCMSET) 683 - COMPATIBLE_IOCTL(TIOCNOTTY) 684 - COMPATIBLE_IOCTL(TIOCSTI) 685 711 COMPATIBLE_IOCTL(TIOCOUTQ) 686 - COMPATIBLE_IOCTL(TIOCSPGRP) 687 - COMPATIBLE_IOCTL(TIOCGPGRP) 688 - COMPATIBLE_IOCTL(TIOCSERGETLSR) 689 - #ifdef TIOCSRS485 690 - COMPATIBLE_IOCTL(TIOCSRS485) 691 - #endif 692 - #ifdef TIOCGRS485 693 - COMPATIBLE_IOCTL(TIOCGRS485) 694 - #endif 695 - #ifdef TCGETS2 696 - COMPATIBLE_IOCTL(TCGETS2) 697 - COMPATIBLE_IOCTL(TCSETS2) 698 - COMPATIBLE_IOCTL(TCSETSW2) 699 - COMPATIBLE_IOCTL(TCSETSF2) 700 - #endif 701 712 /* Little f */ 702 713 COMPATIBLE_IOCTL(FIOCLEX) 703 714 COMPATIBLE_IOCTL(FIONCLEX) ··· 660 775 COMPATIBLE_IOCTL(FIFREEZE) 661 776 COMPATIBLE_IOCTL(FITHAW) 662 777 COMPATIBLE_IOCTL(FITRIM) 663 - COMPATIBLE_IOCTL(KDGETKEYCODE) 664 - COMPATIBLE_IOCTL(KDSETKEYCODE) 665 - COMPATIBLE_IOCTL(KDGKBTYPE) 666 - COMPATIBLE_IOCTL(KDGETMODE) 667 - COMPATIBLE_IOCTL(KDGKBMODE) 668 - COMPATIBLE_IOCTL(KDGKBMETA) 669 - COMPATIBLE_IOCTL(KDGKBENT) 670 - COMPATIBLE_IOCTL(KDSKBENT) 671 - COMPATIBLE_IOCTL(KDGKBSENT) 672 - COMPATIBLE_IOCTL(KDSKBSENT) 673 - COMPATIBLE_IOCTL(KDGKBDIACR) 674 - COMPATIBLE_IOCTL(KDSKBDIACR) 675 - COMPATIBLE_IOCTL(KDGKBDIACRUC) 676 - COMPATIBLE_IOCTL(KDSKBDIACRUC) 677 - COMPATIBLE_IOCTL(KDKBDREP) 678 - COMPATIBLE_IOCTL(KDGKBLED) 679 - COMPATIBLE_IOCTL(KDGETLED) 680 778 #ifdef CONFIG_BLOCK 681 779 /* Big S */ 682 780 COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) ··· 1001 1133 COMPATIBLE_IOCTL(CAPI_CLR_FLAGS) 1002 1134 COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT) 1003 1135 COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT) 1004 - /* Siemens Gigaset */ 1005 - COMPATIBLE_IOCTL(GIGASET_REDIR) 1006 - COMPATIBLE_IOCTL(GIGASET_CONFIG) 1007 - COMPATIBLE_IOCTL(GIGASET_BRKCHARS) 1008 - COMPATIBLE_IOCTL(GIGASET_VERSION) 1009 1136 /* Misc. */ 1010 1137 COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */ 1011 1138 COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */ ··· 1086 1223 COMPATIBLE_IOCTL(JSIOCGBUTTONS) 1087 1224 COMPATIBLE_IOCTL(JSIOCGNAME(0)) 1088 1225 1089 - #ifdef TIOCGLTC 1090 - COMPATIBLE_IOCTL(TIOCGLTC) 1091 - COMPATIBLE_IOCTL(TIOCSLTC) 1092 - #endif 1093 - #ifdef TIOCSTART 1094 - /* 1095 - * For these two we have definitions in ioctls.h and/or termios.h on 1096 - * some architectures but no actual implemention. Some applications 1097 - * like bash call them if they are defined in the headers, so we provide 1098 - * entries here to avoid syslog message spew. 1099 - */ 1100 - COMPATIBLE_IOCTL(TIOCSTART) 1101 - COMPATIBLE_IOCTL(TIOCSTOP) 1102 - #endif 1103 - 1104 1226 /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, 1105 1227 but we don't want warnings on other file systems. So declare 1106 1228 them as compatible here. */ ··· 1141 1293 case MTIOCPOS32: 1142 1294 return mt_ioctl_trans(file, cmd, argp); 1143 1295 #endif 1144 - /* Serial */ 1145 - case TIOCGSERIAL: 1146 - case TIOCSSERIAL: 1147 - return serial_struct_ioctl(file, cmd, argp); 1148 1296 /* Not implemented in the native kernel */ 1149 1297 case RTC_IRQP_READ32: 1150 1298 case RTC_IRQP_SET32: ··· 1160 1316 * so we must not do a compat_ptr() translation. 1161 1317 */ 1162 1318 switch (cmd) { 1163 - /* Big T */ 1164 - case TCSBRKP: 1165 - case TIOCMIWAIT: 1166 - case TIOCSCTTY: 1167 1319 /* RAID */ 1168 1320 case HOT_REMOVE_DISK: 1169 1321 case HOT_ADD_DISK: 1170 1322 case SET_DISK_FAULTY: 1171 1323 case SET_BITMAP_FILE: 1172 - /* Big K */ 1173 - case KDSIGACCEPT: 1174 - case KIOCSOUND: 1175 - case KDMKTONE: 1176 - case KDSETMODE: 1177 - case KDSKBMODE: 1178 - case KDSKBMETA: 1179 - case KDSKBLED: 1180 - case KDSETLED: 1181 1324 return vfs_ioctl(file, cmd, arg); 1182 1325 } 1183 1326
-2
include/linux/tty.h
··· 746 746 /* tty_ioctl.c */ 747 747 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, 748 748 unsigned int cmd, unsigned long arg); 749 - extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file, 750 - unsigned int cmd, unsigned long arg); 751 749 752 750 /* vt.c */ 753 751
+3
include/linux/tty_driver.h
··· 249 249 struct tty_struct; 250 250 struct tty_driver; 251 251 struct serial_icounter_struct; 252 + struct serial_struct; 252 253 253 254 struct tty_operations { 254 255 struct tty_struct * (*lookup)(struct tty_driver *driver, ··· 288 287 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); 289 288 int (*get_icount)(struct tty_struct *tty, 290 289 struct serial_icounter_struct *icount); 290 + int (*get_serial)(struct tty_struct *tty, struct serial_struct *p); 291 + int (*set_serial)(struct tty_struct *tty, struct serial_struct *p); 291 292 void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); 292 293 #ifdef CONFIG_CONSOLE_POLL 293 294 int (*poll_init)(struct tty_driver *driver, int line, char *options);
+8 -2
include/linux/tty_ldisc.h
··· 54 54 * low-level driver can "grab" an ioctl request before the line 55 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 58 * unsigned int cmd, unsigned long arg); 59 59 * 60 60 * Process ioctl calls from 32-bit process on 64-bit system 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. 61 67 * 62 68 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 63 69 * ··· 190 184 const unsigned char *buf, size_t nr); 191 185 int (*ioctl)(struct tty_struct *tty, struct file *file, 192 186 unsigned int cmd, unsigned long arg); 193 - long (*compat_ioctl)(struct tty_struct *tty, struct file *file, 187 + int (*compat_ioctl)(struct tty_struct *tty, struct file *file, 194 188 unsigned int cmd, unsigned long arg); 195 189 void (*set_termios)(struct tty_struct *tty, struct ktermios *old); 196 190 __poll_t (*poll)(struct tty_struct *, struct file *,
+2
include/linux/usb/serial.h
··· 285 285 int (*write_room)(struct tty_struct *tty); 286 286 int (*ioctl)(struct tty_struct *tty, 287 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 290 void (*set_termios)(struct tty_struct *tty, 289 291 struct usb_serial_port *port, struct ktermios *old); 290 292 void (*break_ctl)(struct tty_struct *tty, int break_state);
-12
net/bluetooth/rfcomm/tty.c
··· 839 839 BT_DBG("TIOCMIWAIT"); 840 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 842 case TIOCSERGETLSR: 855 843 BT_ERR("TIOCSERGETLSR is not supported"); 856 844 return -ENOIOCTLCMD;
+1
net/nfc/nci/uart.c
··· 463 463 .receive_buf = nci_uart_tty_receive, 464 464 .write_wakeup = nci_uart_tty_wakeup, 465 465 .ioctl = nci_uart_tty_ioctl, 466 + .compat_ioctl = nci_uart_tty_ioctl, 466 467 }; 467 468 468 469 static int __init nci_uart_init(void)