[PATCH 10/50] cyclades: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/cyclades.c | 77 --
 1 file 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)
}
 }  /* set_line_char */
 
-static int cy_get_serial_info(struct cyclades_port *info,
-   struct serial_struct __user *retinfo)
+static int cy_get_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
+   struct cyclades_port *info = tty->driver_data;
struct cyclades_card *cinfo = info->card;
-   struct serial_struct tmp = {
-   .type = info->type,
-   .line = info->line,
-   .port = (info->card - cy_card) * 0x100 + info->line -
-   cinfo->first_line,
-   .irq = cinfo->irq,
-   .flags = info->port.flags,
-   .close_delay = info->port.close_delay,
-   .closing_wait = info->port.closing_wait,
-   .baud_base = info->baud,
-   .custom_divisor = info->custom_divisor,
-   };
-   return copy_to_user(retinfo, , sizeof(*retinfo)) ? -EFAULT : 0;
+
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
+   ss->type = info->type;
+   ss->line = info->line;
+   ss->port = (info->card - cy_card) * 0x100 + info->line -
+   cinfo->first_line;
+   ss->irq = cinfo->irq;
+   ss->flags = info->port.flags;
+   ss->close_delay = info->port.close_delay;
+   ss->closing_wait = info->port.closing_wait;
+   ss->baud_base = info->baud;
+   ss->custom_divisor = info->custom_divisor;
+   return 0;
 }
 
-static int
-cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
-   struct serial_struct __user *new_info)
+static int cy_set_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
-   struct serial_struct new_serial;
+   struct cyclades_port *info = tty->driver_data;
int old_flags;
int ret;
 
-   if (copy_from_user(_serial, new_info, sizeof(new_serial)))
-   return -EFAULT;
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
 
mutex_lock(>port.mutex);
 
old_flags = info->port.flags;
 
if (!capable(CAP_SYS_ADMIN)) {
-   if (new_serial.close_delay != info->port.close_delay ||
-   new_serial.baud_base != info->baud ||
-   (new_serial.flags & ASYNC_FLAGS &
+   if (ss->close_delay != info->port.close_delay ||
+   ss->baud_base != info->baud ||
+   (ss->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;
}
info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
-   (new_serial.flags & ASYNC_USR_MASK);
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   (ss->flags & ASYNC_USR_MASK);
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
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.
 */
 
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
-   (new_serial.flags & ASYNC_FLAGS);
-   info->port.close_delay = new_serial.close_delay * HZ / 100;
-   info->port.closing_wait = new_serial.closing_wait * HZ / 100;
+   (ss->flags & ASYNC_FLAGS);
+   info->port.close_delay = ss->close_delay * HZ / 100;
+   info->port.closing_wait = ss->closing_wait * HZ / 100;
 
 check_and_exit:
if (tty_port_initialized(>port)) {
-   if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) {
+   if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) {
/* warn about deprecation unless clearing */
-   if (new_serial.flags & ASYNC_SPD_MASK)
+

[PATCH 10/50] cyclades: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/cyclades.c | 77 --
 1 file 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)
}
 }  /* set_line_char */
 
-static int cy_get_serial_info(struct cyclades_port *info,
-   struct serial_struct __user *retinfo)
+static int cy_get_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
+   struct cyclades_port *info = tty->driver_data;
struct cyclades_card *cinfo = info->card;
-   struct serial_struct tmp = {
-   .type = info->type,
-   .line = info->line,
-   .port = (info->card - cy_card) * 0x100 + info->line -
-   cinfo->first_line,
-   .irq = cinfo->irq,
-   .flags = info->port.flags,
-   .close_delay = info->port.close_delay,
-   .closing_wait = info->port.closing_wait,
-   .baud_base = info->baud,
-   .custom_divisor = info->custom_divisor,
-   };
-   return copy_to_user(retinfo, , sizeof(*retinfo)) ? -EFAULT : 0;
+
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
+   ss->type = info->type;
+   ss->line = info->line;
+   ss->port = (info->card - cy_card) * 0x100 + info->line -
+   cinfo->first_line;
+   ss->irq = cinfo->irq;
+   ss->flags = info->port.flags;
+   ss->close_delay = info->port.close_delay;
+   ss->closing_wait = info->port.closing_wait;
+   ss->baud_base = info->baud;
+   ss->custom_divisor = info->custom_divisor;
+   return 0;
 }
 
-static int
-cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
-   struct serial_struct __user *new_info)
+static int cy_set_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
-   struct serial_struct new_serial;
+   struct cyclades_port *info = tty->driver_data;
int old_flags;
int ret;
 
-   if (copy_from_user(_serial, new_info, sizeof(new_serial)))
-   return -EFAULT;
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
 
mutex_lock(>port.mutex);
 
old_flags = info->port.flags;
 
if (!capable(CAP_SYS_ADMIN)) {
-   if (new_serial.close_delay != info->port.close_delay ||
-   new_serial.baud_base != info->baud ||
-   (new_serial.flags & ASYNC_FLAGS &
+   if (ss->close_delay != info->port.close_delay ||
+   ss->baud_base != info->baud ||
+   (ss->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;
}
info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
-   (new_serial.flags & ASYNC_USR_MASK);
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   (ss->flags & ASYNC_USR_MASK);
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
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.
 */
 
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
-   (new_serial.flags & ASYNC_FLAGS);
-   info->port.close_delay = new_serial.close_delay * HZ / 100;
-   info->port.closing_wait = new_serial.closing_wait * HZ / 100;
+   (ss->flags & ASYNC_FLAGS);
+   info->port.close_delay = ss->close_delay * HZ / 100;
+   info->port.closing_wait = ss->closing_wait * HZ / 100;
 
 check_and_exit:
if (tty_port_initialized(>port)) {
-   if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) {
+   if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) {
/* warn about deprecation unless clearing */
-   if (new_serial.flags & ASYNC_SPD_MASK)
+