check_msr_delta(port, mask, &prev));
}
-static int get_serial_info(struct fwtty_port *port,
- struct serial_struct __user *info)
+static int get_serial_info(struct tty_struct *tty,
+ struct serial_struct *ss)
{
- struct serial_struct tmp;
-
- memset(&tmp, 0, sizeof(tmp));
-
- tmp.type = PORT_UNKNOWN;
- tmp.line = port->port.tty->index;
- tmp.flags = port->port.flags;
- tmp.xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
- tmp.baud_base = 400000000;
- tmp.close_delay = port->port.close_delay;
-
- return (copy_to_user(info, &tmp, sizeof(*info))) ? -EFAULT : 0;
+ struct fwtty_port *port = tty->driver_data;
+ mutex_lock(&port->port.mutex);
+ ss->type = PORT_UNKNOWN;
+ ss->line = port->port.tty->index;
+ ss->flags = port->port.flags;
+ ss->xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
+ ss->baud_base = 400000000;
+ ss->close_delay = port->port.close_delay;
+ mutex_unlock(&port->port.mutex);
+ return 0;
}
-static int set_serial_info(struct fwtty_port *port,
- struct serial_struct __user *info)
+static int set_serial_info(struct tty_struct *tty,
+ struct serial_struct *ss)
{
- struct serial_struct tmp;
-
- if (copy_from_user(&tmp, info, sizeof(tmp)))
- return -EFAULT;
+ struct fwtty_port *port = tty->driver_data;
- if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 ||
- tmp.baud_base != 400000000)
+ if (ss->irq != 0 || ss->port != 0 || ss->custom_divisor != 0 ||
+ ss->baud_base != 400000000)
return -EPERM;
+ mutex_lock(&port->port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
- if (((tmp.flags & ~ASYNC_USR_MASK) !=
- (port->port.flags & ~ASYNC_USR_MASK)))
+ if (((ss->flags & ~ASYNC_USR_MASK) !=
+ (port->port.flags & ~ASYNC_USR_MASK))) {
+ mutex_unlock(&port->port.mutex);
return -EPERM;
- } else {
- port->port.close_delay = tmp.close_delay * HZ / 100;
+ }
}
+ port->port.close_delay = ss->close_delay * HZ / 100;
+ mutex_unlock(&port->port.mutex);
return 0;
}
int err;
switch (cmd) {
- case TIOCGSERIAL:
- mutex_lock(&port->port.mutex);
- err = get_serial_info(port, (void __user *)arg);
- mutex_unlock(&port->port.mutex);
- break;
-
- case TIOCSSERIAL:
- mutex_lock(&port->port.mutex);
- err = set_serial_info(port, (void __user *)arg);
- mutex_unlock(&port->port.mutex);
- break;
-
case TIOCMIWAIT:
err = wait_msr_change(port, arg);
break;
.tiocmget = fwtty_tiocmget,
.tiocmset = fwtty_tiocmset,
.get_icount = fwtty_get_icount,
+ .set_serial = set_serial_info,
+ .get_serial = get_serial_info,
.proc_show = fwtty_proc_show,
};
.tiocmget = fwtty_tiocmget,
.tiocmset = fwtty_tiocmset,
.get_icount = fwtty_get_icount,
+ .set_serial = set_serial_info,
+ .get_serial = get_serial_info,
};
static inline int mgmt_pkt_expected_len(__be16 code)