diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-09-11 22:00:37 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-10-13 00:50:31 -0400 |
commit | b60f38c6640f3b0e15f37c63167df9560fe00e6a (patch) | |
tree | 8aa7ee05e72075be70b2e095d1c7990adb3add6f | |
parent | a7b06fcf2ecef39b37979ac8b8838a182ba569e2 (diff) |
isicom: switch to ->[sg]et_serial()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/tty/isicom.c | 72 |
1 files changed, 25 insertions, 47 deletions
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index 8d96e86966f1..e04a43e89f6b 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c | |||
@@ -1091,34 +1091,33 @@ static int isicom_tiocmset(struct tty_struct *tty, | |||
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | static int isicom_set_serial_info(struct tty_struct *tty, | 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 | struct isi_port *port = tty->driver_data; | 1096 | struct isi_port *port = tty->driver_data; |
1097 | struct serial_struct newinfo; | ||
1098 | int reconfig_port; | 1097 | int reconfig_port; |
1099 | 1098 | ||
1100 | if (copy_from_user(&newinfo, info, sizeof(newinfo))) | 1099 | if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) |
1101 | return -EFAULT; | 1100 | return -ENODEV; |
1102 | 1101 | ||
1103 | mutex_lock(&port->port.mutex); | 1102 | mutex_lock(&port->port.mutex); |
1104 | reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) != | 1103 | reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) != |
1105 | (newinfo.flags & ASYNC_SPD_MASK)); | 1104 | (ss->flags & ASYNC_SPD_MASK)); |
1106 | 1105 | ||
1107 | if (!capable(CAP_SYS_ADMIN)) { | 1106 | if (!capable(CAP_SYS_ADMIN)) { |
1108 | if ((newinfo.close_delay != port->port.close_delay) || | 1107 | if ((ss->close_delay != port->port.close_delay) || |
1109 | (newinfo.closing_wait != port->port.closing_wait) || | 1108 | (ss->closing_wait != port->port.closing_wait) || |
1110 | ((newinfo.flags & ~ASYNC_USR_MASK) != | 1109 | ((ss->flags & ~ASYNC_USR_MASK) != |
1111 | (port->port.flags & ~ASYNC_USR_MASK))) { | 1110 | (port->port.flags & ~ASYNC_USR_MASK))) { |
1112 | mutex_unlock(&port->port.mutex); | 1111 | mutex_unlock(&port->port.mutex); |
1113 | return -EPERM; | 1112 | return -EPERM; |
1114 | } | 1113 | } |
1115 | port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | | 1114 | port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | |
1116 | (newinfo.flags & ASYNC_USR_MASK)); | 1115 | (ss->flags & ASYNC_USR_MASK)); |
1117 | } else { | 1116 | } else { |
1118 | port->port.close_delay = newinfo.close_delay; | 1117 | port->port.close_delay = ss->close_delay; |
1119 | port->port.closing_wait = newinfo.closing_wait; | 1118 | port->port.closing_wait = ss->closing_wait; |
1120 | port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) | | 1119 | port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) | |
1121 | (newinfo.flags & ASYNC_FLAGS)); | 1120 | (ss->flags & ASYNC_FLAGS)); |
1122 | } | 1121 | } |
1123 | if (reconfig_port) { | 1122 | if (reconfig_port) { |
1124 | unsigned long flags; | 1123 | unsigned long flags; |
@@ -1130,46 +1129,24 @@ static int isicom_set_serial_info(struct tty_struct *tty, | |||
1130 | return 0; | 1129 | return 0; |
1131 | } | 1130 | } |
1132 | 1131 | ||
1133 | static int isicom_get_serial_info(struct isi_port *port, | 1132 | static int isicom_get_serial_info(struct tty_struct *tty, |
1134 | struct serial_struct __user *info) | 1133 | struct serial_struct *ss) |
1135 | { | ||
1136 | struct serial_struct out_info; | ||
1137 | |||
1138 | mutex_lock(&port->port.mutex); | ||
1139 | memset(&out_info, 0, sizeof(out_info)); | ||
1140 | /* out_info.type = ? */ | ||
1141 | out_info.line = port - isi_ports; | ||
1142 | out_info.port = port->card->base; | ||
1143 | out_info.irq = port->card->irq; | ||
1144 | out_info.flags = port->port.flags; | ||
1145 | /* out_info.baud_base = ? */ | ||
1146 | out_info.close_delay = port->port.close_delay; | ||
1147 | out_info.closing_wait = port->port.closing_wait; | ||
1148 | mutex_unlock(&port->port.mutex); | ||
1149 | if (copy_to_user(info, &out_info, sizeof(out_info))) | ||
1150 | return -EFAULT; | ||
1151 | return 0; | ||
1152 | } | ||
1153 | |||
1154 | static int isicom_ioctl(struct tty_struct *tty, | ||
1155 | unsigned int cmd, unsigned long arg) | ||
1156 | { | 1134 | { |
1157 | struct isi_port *port = tty->driver_data; | 1135 | struct isi_port *port = tty->driver_data; |
1158 | void __user *argp = (void __user *)arg; | ||
1159 | 1136 | ||
1160 | if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) | 1137 | if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) |
1161 | return -ENODEV; | 1138 | return -ENODEV; |
1162 | 1139 | ||
1163 | switch (cmd) { | 1140 | mutex_lock(&port->port.mutex); |
1164 | case TIOCGSERIAL: | 1141 | /* ss->type = ? */ |
1165 | return isicom_get_serial_info(port, argp); | 1142 | ss->line = port - isi_ports; |
1166 | 1143 | ss->port = port->card->base; | |
1167 | case TIOCSSERIAL: | 1144 | ss->irq = port->card->irq; |
1168 | return isicom_set_serial_info(tty, argp); | 1145 | ss->flags = port->port.flags; |
1169 | 1146 | /* ss->baud_base = ? */ | |
1170 | default: | 1147 | ss->close_delay = port->port.close_delay; |
1171 | return -ENOIOCTLCMD; | 1148 | ss->closing_wait = port->port.closing_wait; |
1172 | } | 1149 | mutex_unlock(&port->port.mutex); |
1173 | return 0; | 1150 | return 0; |
1174 | } | 1151 | } |
1175 | 1152 | ||
@@ -1273,7 +1250,6 @@ static const struct tty_operations isicom_ops = { | |||
1273 | .flush_chars = isicom_flush_chars, | 1250 | .flush_chars = isicom_flush_chars, |
1274 | .write_room = isicom_write_room, | 1251 | .write_room = isicom_write_room, |
1275 | .chars_in_buffer = isicom_chars_in_buffer, | 1252 | .chars_in_buffer = isicom_chars_in_buffer, |
1276 | .ioctl = isicom_ioctl, | ||
1277 | .set_termios = isicom_set_termios, | 1253 | .set_termios = isicom_set_termios, |
1278 | .throttle = isicom_throttle, | 1254 | .throttle = isicom_throttle, |
1279 | .unthrottle = isicom_unthrottle, | 1255 | .unthrottle = isicom_unthrottle, |
@@ -1284,6 +1260,8 @@ static const struct tty_operations isicom_ops = { | |||
1284 | .tiocmget = isicom_tiocmget, | 1260 | .tiocmget = isicom_tiocmget, |
1285 | .tiocmset = isicom_tiocmset, | 1261 | .tiocmset = isicom_tiocmset, |
1286 | .break_ctl = isicom_send_break, | 1262 | .break_ctl = isicom_send_break, |
1263 | .get_serial = isicom_get_serial_info, | ||
1264 | .set_serial = isicom_set_serial_info, | ||
1287 | }; | 1265 | }; |
1288 | 1266 | ||
1289 | static const struct tty_port_operations isicom_port_ops = { | 1267 | static const struct tty_port_operations isicom_port_ops = { |