summaryrefslogtreecommitdiffstats
path: root/drivers/tty/cyclades.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-09-11 21:59:48 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-10-13 00:50:30 -0400
commit6fbf9582548105e7548a2342f67b32977fe8a43a (patch)
treeafb3361275c1238281b094180f1f7faf9a52e204 /drivers/tty/cyclades.c
parentb129cbc99b2d09a4c4c5de60f91118ecb380e2fa (diff)
cyclades: switch to ->[sg]et_serial()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/tty/cyclades.c')
-rw-r--r--drivers/tty/cyclades.c77
1 files changed, 37 insertions, 40 deletions
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 6d3c58051ce3..4562c8060d09 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -2257,44 +2257,45 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
2257 } 2257 }
2258} /* set_line_char */ 2258} /* set_line_char */
2259 2259
2260static int cy_get_serial_info(struct cyclades_port *info, 2260static int cy_get_serial_info(struct tty_struct *tty,
2261 struct serial_struct __user *retinfo) 2261 struct serial_struct *ss)
2262{ 2262{
2263 struct cyclades_port *info = tty->driver_data;
2263 struct cyclades_card *cinfo = info->card; 2264 struct cyclades_card *cinfo = info->card;
2264 struct serial_struct tmp = { 2265
2265 .type = info->type, 2266 if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
2266 .line = info->line, 2267 return -ENODEV;
2267 .port = (info->card - cy_card) * 0x100 + info->line - 2268 ss->type = info->type;
2268 cinfo->first_line, 2269 ss->line = info->line;
2269 .irq = cinfo->irq, 2270 ss->port = (info->card - cy_card) * 0x100 + info->line -
2270 .flags = info->port.flags, 2271 cinfo->first_line;
2271 .close_delay = info->port.close_delay, 2272 ss->irq = cinfo->irq;
2272 .closing_wait = info->port.closing_wait, 2273 ss->flags = info->port.flags;
2273 .baud_base = info->baud, 2274 ss->close_delay = info->port.close_delay;
2274 .custom_divisor = info->custom_divisor, 2275 ss->closing_wait = info->port.closing_wait;
2275 }; 2276 ss->baud_base = info->baud;
2276 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 2277 ss->custom_divisor = info->custom_divisor;
2278 return 0;
2277} 2279}
2278 2280
2279static int 2281static int cy_set_serial_info(struct tty_struct *tty,
2280cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty, 2282 struct serial_struct *ss)
2281 struct serial_struct __user *new_info)
2282{ 2283{
2283 struct serial_struct new_serial; 2284 struct cyclades_port *info = tty->driver_data;
2284 int old_flags; 2285 int old_flags;
2285 int ret; 2286 int ret;
2286 2287
2287 if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2288 if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
2288 return -EFAULT; 2289 return -ENODEV;
2289 2290
2290 mutex_lock(&info->port.mutex); 2291 mutex_lock(&info->port.mutex);
2291 2292
2292 old_flags = info->port.flags; 2293 old_flags = info->port.flags;
2293 2294
2294 if (!capable(CAP_SYS_ADMIN)) { 2295 if (!capable(CAP_SYS_ADMIN)) {
2295 if (new_serial.close_delay != info->port.close_delay || 2296 if (ss->close_delay != info->port.close_delay ||
2296 new_serial.baud_base != info->baud || 2297 ss->baud_base != info->baud ||
2297 (new_serial.flags & ASYNC_FLAGS & 2298 (ss->flags & ASYNC_FLAGS &
2298 ~ASYNC_USR_MASK) != 2299 ~ASYNC_USR_MASK) !=
2299 (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) 2300 (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
2300 { 2301 {
@@ -2302,9 +2303,9 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
2302 return -EPERM; 2303 return -EPERM;
2303 } 2304 }
2304 info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) | 2305 info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
2305 (new_serial.flags & ASYNC_USR_MASK); 2306 (ss->flags & ASYNC_USR_MASK);
2306 info->baud = new_serial.baud_base; 2307 info->baud = ss->baud_base;
2307 info->custom_divisor = new_serial.custom_divisor; 2308 info->custom_divisor = ss->custom_divisor;
2308 goto check_and_exit; 2309 goto check_and_exit;
2309 } 2310 }
2310 2311
@@ -2313,18 +2314,18 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
2313 * At this point, we start making changes..... 2314 * At this point, we start making changes.....
2314 */ 2315 */
2315 2316
2316 info->baud = new_serial.baud_base; 2317 info->baud = ss->baud_base;
2317 info->custom_divisor = new_serial.custom_divisor; 2318 info->custom_divisor = ss->custom_divisor;
2318 info->port.flags = (info->port.flags & ~ASYNC_FLAGS) | 2319 info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
2319 (new_serial.flags & ASYNC_FLAGS); 2320 (ss->flags & ASYNC_FLAGS);
2320 info->port.close_delay = new_serial.close_delay * HZ / 100; 2321 info->port.close_delay = ss->close_delay * HZ / 100;
2321 info->port.closing_wait = new_serial.closing_wait * HZ / 100; 2322 info->port.closing_wait = ss->closing_wait * HZ / 100;
2322 2323
2323check_and_exit: 2324check_and_exit:
2324 if (tty_port_initialized(&info->port)) { 2325 if (tty_port_initialized(&info->port)) {
2325 if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) { 2326 if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) {
2326 /* warn about deprecation unless clearing */ 2327 /* warn about deprecation unless clearing */
2327 if (new_serial.flags & ASYNC_SPD_MASK) 2328 if (ss->flags & ASYNC_SPD_MASK)
2328 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); 2329 dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n");
2329 } 2330 }
2330 cy_set_line_char(info, tty); 2331 cy_set_line_char(info, tty);
@@ -2698,12 +2699,6 @@ cy_ioctl(struct tty_struct *tty,
2698 case CYGETWAIT: 2699 case CYGETWAIT:
2699 ret_val = info->port.closing_wait / (HZ / 100); 2700 ret_val = info->port.closing_wait / (HZ / 100);
2700 break; 2701 break;
2701 case TIOCGSERIAL:
2702 ret_val = cy_get_serial_info(info, argp);
2703 break;
2704 case TIOCSSERIAL:
2705 ret_val = cy_set_serial_info(info, tty, argp);
2706 break;
2707 case TIOCSERGETLSR: /* Get line status register */ 2702 case TIOCSERGETLSR: /* Get line status register */
2708 ret_val = get_lsr_info(info, argp); 2703 ret_val = get_lsr_info(info, argp);
2709 break; 2704 break;
@@ -4011,6 +4006,8 @@ static const struct tty_operations cy_ops = {
4011 .tiocmget = cy_tiocmget, 4006 .tiocmget = cy_tiocmget,
4012 .tiocmset = cy_tiocmset, 4007 .tiocmset = cy_tiocmset,
4013 .get_icount = cy_get_icount, 4008 .get_icount = cy_get_icount,
4009 .set_serial = cy_set_serial_info,
4010 .get_serial = cy_get_serial_info,
4014 .proc_show = cyclades_proc_show, 4011 .proc_show = cyclades_proc_show,
4015}; 4012};
4016 4013