mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
amiserial: switch to ->[sg]et_serial()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
0aad5ad563
commit
b129cbc99b
@ -996,63 +996,55 @@ static void rs_unthrottle(struct tty_struct * tty)
|
||||
* ------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
|
||||
struct serial_struct __user * retinfo)
|
||||
static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
|
||||
{
|
||||
struct serial_struct tmp;
|
||||
|
||||
memset(&tmp, 0, sizeof(tmp));
|
||||
struct serial_state *state = tty->driver_data;
|
||||
|
||||
tty_lock(tty);
|
||||
tmp.line = tty->index;
|
||||
tmp.port = state->port;
|
||||
tmp.flags = state->tport.flags;
|
||||
tmp.xmit_fifo_size = state->xmit_fifo_size;
|
||||
tmp.baud_base = state->baud_base;
|
||||
tmp.close_delay = state->tport.close_delay;
|
||||
tmp.closing_wait = state->tport.closing_wait;
|
||||
tmp.custom_divisor = state->custom_divisor;
|
||||
ss->line = tty->index;
|
||||
ss->port = state->port;
|
||||
ss->flags = state->tport.flags;
|
||||
ss->xmit_fifo_size = state->xmit_fifo_size;
|
||||
ss->baud_base = state->baud_base;
|
||||
ss->close_delay = state->tport.close_delay;
|
||||
ss->closing_wait = state->tport.closing_wait;
|
||||
ss->custom_divisor = state->custom_divisor;
|
||||
tty_unlock(tty);
|
||||
if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
|
||||
struct serial_struct __user * new_info)
|
||||
static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
|
||||
{
|
||||
struct serial_state *state = tty->driver_data;
|
||||
struct tty_port *port = &state->tport;
|
||||
struct serial_struct new_serial;
|
||||
bool change_spd;
|
||||
int retval = 0;
|
||||
|
||||
if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
|
||||
return -EFAULT;
|
||||
|
||||
tty_lock(tty);
|
||||
change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
|
||||
new_serial.custom_divisor != state->custom_divisor;
|
||||
if (new_serial.irq || new_serial.port != state->port ||
|
||||
new_serial.xmit_fifo_size != state->xmit_fifo_size) {
|
||||
change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) ||
|
||||
ss->custom_divisor != state->custom_divisor;
|
||||
if (ss->irq || ss->port != state->port ||
|
||||
ss->xmit_fifo_size != state->xmit_fifo_size) {
|
||||
tty_unlock(tty);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!serial_isroot()) {
|
||||
if ((new_serial.baud_base != state->baud_base) ||
|
||||
(new_serial.close_delay != port->close_delay) ||
|
||||
(new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
|
||||
((new_serial.flags & ~ASYNC_USR_MASK) !=
|
||||
if ((ss->baud_base != state->baud_base) ||
|
||||
(ss->close_delay != port->close_delay) ||
|
||||
(ss->xmit_fifo_size != state->xmit_fifo_size) ||
|
||||
((ss->flags & ~ASYNC_USR_MASK) !=
|
||||
(port->flags & ~ASYNC_USR_MASK))) {
|
||||
tty_unlock(tty);
|
||||
return -EPERM;
|
||||
}
|
||||
port->flags = ((port->flags & ~ASYNC_USR_MASK) |
|
||||
(new_serial.flags & ASYNC_USR_MASK));
|
||||
state->custom_divisor = new_serial.custom_divisor;
|
||||
(ss->flags & ASYNC_USR_MASK));
|
||||
state->custom_divisor = ss->custom_divisor;
|
||||
goto check_and_exit;
|
||||
}
|
||||
|
||||
if (new_serial.baud_base < 9600) {
|
||||
if (ss->baud_base < 9600) {
|
||||
tty_unlock(tty);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -1062,19 +1054,19 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
|
||||
* At this point, we start making changes.....
|
||||
*/
|
||||
|
||||
state->baud_base = new_serial.baud_base;
|
||||
state->baud_base = ss->baud_base;
|
||||
port->flags = ((port->flags & ~ASYNC_FLAGS) |
|
||||
(new_serial.flags & ASYNC_FLAGS));
|
||||
state->custom_divisor = new_serial.custom_divisor;
|
||||
port->close_delay = new_serial.close_delay * HZ/100;
|
||||
port->closing_wait = new_serial.closing_wait * HZ/100;
|
||||
(ss->flags & ASYNC_FLAGS));
|
||||
state->custom_divisor = ss->custom_divisor;
|
||||
port->close_delay = ss->close_delay * HZ/100;
|
||||
port->closing_wait = ss->closing_wait * HZ/100;
|
||||
port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
|
||||
|
||||
check_and_exit:
|
||||
if (tty_port_initialized(port)) {
|
||||
if (change_spd) {
|
||||
/* 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");
|
||||
change_speed(tty, state, NULL);
|
||||
}
|
||||
@ -1084,7 +1076,6 @@ check_and_exit:
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_lsr_info - get line status register info
|
||||
*
|
||||
@ -1224,18 +1215,13 @@ static int rs_ioctl(struct tty_struct *tty,
|
||||
if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
|
||||
return -ENODEV;
|
||||
|
||||
if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
|
||||
(cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
|
||||
if ((cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
|
||||
(cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
|
||||
if (tty_io_error(tty))
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case TIOCGSERIAL:
|
||||
return get_serial_info(tty, info, argp);
|
||||
case TIOCSSERIAL:
|
||||
return set_serial_info(tty, info, argp);
|
||||
case TIOCSERCONFIG:
|
||||
return 0;
|
||||
|
||||
@ -1607,6 +1593,8 @@ static const struct tty_operations serial_ops = {
|
||||
.tiocmget = rs_tiocmget,
|
||||
.tiocmset = rs_tiocmset,
|
||||
.get_icount = rs_get_icount,
|
||||
.set_serial = set_serial_info,
|
||||
.get_serial = get_serial_info,
|
||||
.proc_show = rs_proc_show,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user