cyclades: switch to ->[sg]et_serial()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2018-09-11 21:59:48 -04:00
parent b129cbc99b
commit 6fbf958254
1 changed files with 37 additions and 40 deletions

View File

@ -2257,44 +2257,45 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
} }
} /* set_line_char */ } /* set_line_char */
static int cy_get_serial_info(struct cyclades_port *info, static int cy_get_serial_info(struct tty_struct *tty,
struct serial_struct __user *retinfo) struct serial_struct *ss)
{ {
struct cyclades_port *info = tty->driver_data;
struct cyclades_card *cinfo = info->card; struct cyclades_card *cinfo = info->card;
struct serial_struct tmp = {
.type = info->type, if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
.line = info->line, return -ENODEV;
.port = (info->card - cy_card) * 0x100 + info->line - ss->type = info->type;
cinfo->first_line, ss->line = info->line;
.irq = cinfo->irq, ss->port = (info->card - cy_card) * 0x100 + info->line -
.flags = info->port.flags, cinfo->first_line;
.close_delay = info->port.close_delay, ss->irq = cinfo->irq;
.closing_wait = info->port.closing_wait, ss->flags = info->port.flags;
.baud_base = info->baud, ss->close_delay = info->port.close_delay;
.custom_divisor = info->custom_divisor, ss->closing_wait = info->port.closing_wait;
}; ss->baud_base = info->baud;
return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; ss->custom_divisor = info->custom_divisor;
return 0;
} }
static int static int cy_set_serial_info(struct tty_struct *tty,
cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty, struct serial_struct *ss)
struct serial_struct __user *new_info)
{ {
struct serial_struct new_serial; struct cyclades_port *info = tty->driver_data;
int old_flags; int old_flags;
int ret; int ret;
if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
return -EFAULT; return -ENODEV;
mutex_lock(&info->port.mutex); mutex_lock(&info->port.mutex);
old_flags = info->port.flags; old_flags = info->port.flags;
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
if (new_serial.close_delay != info->port.close_delay || if (ss->close_delay != info->port.close_delay ||
new_serial.baud_base != info->baud || ss->baud_base != info->baud ||
(new_serial.flags & ASYNC_FLAGS & (ss->flags & ASYNC_FLAGS &
~ASYNC_USR_MASK) != ~ASYNC_USR_MASK) !=
(info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
{ {
@ -2302,9 +2303,9 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
return -EPERM; return -EPERM;
} }
info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) | info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
(new_serial.flags & ASYNC_USR_MASK); (ss->flags & ASYNC_USR_MASK);
info->baud = new_serial.baud_base; info->baud = ss->baud_base;
info->custom_divisor = new_serial.custom_divisor; info->custom_divisor = ss->custom_divisor;
goto check_and_exit; goto check_and_exit;
} }
@ -2313,18 +2314,18 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
* At this point, we start making changes..... * At this point, we start making changes.....
*/ */
info->baud = new_serial.baud_base; info->baud = ss->baud_base;
info->custom_divisor = new_serial.custom_divisor; info->custom_divisor = ss->custom_divisor;
info->port.flags = (info->port.flags & ~ASYNC_FLAGS) | info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
(new_serial.flags & ASYNC_FLAGS); (ss->flags & ASYNC_FLAGS);
info->port.close_delay = new_serial.close_delay * HZ / 100; info->port.close_delay = ss->close_delay * HZ / 100;
info->port.closing_wait = new_serial.closing_wait * HZ / 100; info->port.closing_wait = ss->closing_wait * HZ / 100;
check_and_exit: check_and_exit:
if (tty_port_initialized(&info->port)) { if (tty_port_initialized(&info->port)) {
if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) { if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) {
/* warn about deprecation unless clearing */ /* warn about deprecation unless clearing */
if (new_serial.flags & ASYNC_SPD_MASK) if (ss->flags & ASYNC_SPD_MASK)
dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n");
} }
cy_set_line_char(info, tty); cy_set_line_char(info, tty);
@ -2698,12 +2699,6 @@ cy_ioctl(struct tty_struct *tty,
case CYGETWAIT: case CYGETWAIT:
ret_val = info->port.closing_wait / (HZ / 100); ret_val = info->port.closing_wait / (HZ / 100);
break; break;
case TIOCGSERIAL:
ret_val = cy_get_serial_info(info, argp);
break;
case TIOCSSERIAL:
ret_val = cy_set_serial_info(info, tty, argp);
break;
case TIOCSERGETLSR: /* Get line status register */ case TIOCSERGETLSR: /* Get line status register */
ret_val = get_lsr_info(info, argp); ret_val = get_lsr_info(info, argp);
break; break;
@ -4011,6 +4006,8 @@ static const struct tty_operations cy_ops = {
.tiocmget = cy_tiocmget, .tiocmget = cy_tiocmget,
.tiocmset = cy_tiocmset, .tiocmset = cy_tiocmset,
.get_icount = cy_get_icount, .get_icount = cy_get_icount,
.set_serial = cy_set_serial_info,
.get_serial = cy_get_serial_info,
.proc_show = cyclades_proc_show, .proc_show = cyclades_proc_show,
}; };