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: Al Viro <viro@zeniv.linux.org.uk>hifive-unleashed-5.1
parent
b60f38c664
commit
1c729ab15a
|
@ -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 @@ copy:
|
||||||
}
|
}
|
||||||
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 = {
|
||||||
.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)
|
||||||
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);
|
MoxaSetFifo(info, ss->type == PORT_16550A);
|
||||||
new_serial.flags |= (info->port.flags & ASYNC_FLAGS);
|
|
||||||
|
|
||||||
MoxaSetFifo(info, new_serial.type == PORT_16550A);
|
info->type = ss->type;
|
||||||
|
mutex_unlock(&info->port.mutex);
|
||||||
info->type = new_serial.type;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue