Commit 1c729ab1 authored by Al Viro's avatar Al Viro

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

Pointless dead assignments in moxa_set_serial_info() killed off;
they would've been a bug, if not for the fact that user-settable
flags had never been used in that driver.  Bogus from day 1,
though...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b60f38c6
...@@ -221,8 +221,8 @@ static int MoxaPortRxQueue(struct moxa_port *); ...@@ -221,8 +221,8 @@ static int MoxaPortRxQueue(struct moxa_port *);
static int MoxaPortTxFree(struct moxa_port *); static int MoxaPortTxFree(struct moxa_port *);
static void MoxaPortTxDisable(struct moxa_port *); static void MoxaPortTxDisable(struct moxa_port *);
static void MoxaPortTxEnable(struct moxa_port *); static void MoxaPortTxEnable(struct moxa_port *);
static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *); static int moxa_get_serial_info(struct tty_struct *, struct serial_struct *);
static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *); static int moxa_set_serial_info(struct tty_struct *, struct serial_struct *);
static void MoxaSetFifo(struct moxa_port *port, int enable); static void MoxaSetFifo(struct moxa_port *port, int enable);
/* /*
...@@ -375,16 +375,6 @@ static int moxa_ioctl(struct tty_struct *tty, ...@@ -375,16 +375,6 @@ static int moxa_ioctl(struct tty_struct *tty,
} }
break; break;
} }
case TIOCGSERIAL:
mutex_lock(&ch->port.mutex);
ret = moxa_get_serial_info(ch, argp);
mutex_unlock(&ch->port.mutex);
break;
case TIOCSSERIAL:
mutex_lock(&ch->port.mutex);
ret = moxa_set_serial_info(ch, argp);
mutex_unlock(&ch->port.mutex);
break;
default: default:
ret = -ENOIOCTLCMD; ret = -ENOIOCTLCMD;
} }
...@@ -415,6 +405,8 @@ static const struct tty_operations moxa_ops = { ...@@ -415,6 +405,8 @@ static const struct tty_operations moxa_ops = {
.break_ctl = moxa_break_ctl, .break_ctl = moxa_break_ctl,
.tiocmget = moxa_tiocmget, .tiocmget = moxa_tiocmget,
.tiocmset = moxa_tiocmset, .tiocmset = moxa_tiocmset,
.set_serial = moxa_set_serial_info,
.get_serial = moxa_get_serial_info,
}; };
static const struct tty_port_operations moxa_port_ops = { static const struct tty_port_operations moxa_port_ops = {
...@@ -2034,46 +2026,55 @@ static void MoxaPortTxEnable(struct moxa_port *port) ...@@ -2034,46 +2026,55 @@ static void MoxaPortTxEnable(struct moxa_port *port)
moxafunc(port->tableAddr, FC_SetXonState, Magic_code); moxafunc(port->tableAddr, FC_SetXonState, Magic_code);
} }
static int moxa_get_serial_info(struct moxa_port *info, static int moxa_get_serial_info(struct tty_struct *tty,
struct serial_struct __user *retinfo) struct serial_struct *ss)
{ {
struct serial_struct tmp = { struct moxa_port *info = tty->driver_data;
.type = info->type,
.line = info->port.tty->index, if (tty->index == MAX_PORTS)
.flags = info->port.flags, return -EINVAL;
.baud_base = 921600, if (!info)
.close_delay = info->port.close_delay return -ENODEV;
}; mutex_lock(&info->port.mutex);
return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; ss->type = info->type,
ss->line = info->port.tty->index,
ss->flags = info->port.flags,
ss->baud_base = 921600,
ss->close_delay = info->port.close_delay;
mutex_unlock(&info->port.mutex);
return 0;
} }
static int moxa_set_serial_info(struct moxa_port *info, static int moxa_set_serial_info(struct tty_struct *tty,
struct serial_struct __user *new_info) struct serial_struct *ss)
{ {
struct serial_struct new_serial; struct moxa_port *info = tty->driver_data;
if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) if (tty->index == MAX_PORTS)
return -EFAULT; return -EINVAL;
if (!info)
return -ENODEV;
if (new_serial.irq != 0 || new_serial.port != 0 || if (ss->irq != 0 || ss->port != 0 ||
new_serial.custom_divisor != 0 || ss->custom_divisor != 0 ||
new_serial.baud_base != 921600) ss->baud_base != 921600)
return -EPERM; return -EPERM;
mutex_lock(&info->port.mutex);
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
if (((new_serial.flags & ~ASYNC_USR_MASK) != if (((ss->flags & ~ASYNC_USR_MASK) !=
(info->port.flags & ~ASYNC_USR_MASK))) (info->port.flags & ~ASYNC_USR_MASK))) {
mutex_unlock(&info->port.mutex);
return -EPERM; return -EPERM;
} else }
info->port.close_delay = new_serial.close_delay * HZ / 100; }
info->port.close_delay = ss->close_delay * HZ / 100;
new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS);
new_serial.flags |= (info->port.flags & ASYNC_FLAGS);
MoxaSetFifo(info, new_serial.type == PORT_16550A); MoxaSetFifo(info, ss->type == PORT_16550A);
info->type = new_serial.type; info->type = ss->type;
mutex_unlock(&info->port.mutex);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment