2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-05 20:24:09 +08:00

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

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2018-09-12 07:45:23 -04:00
parent fc6cc979e4
commit 15cc7bad48
3 changed files with 22 additions and 48 deletions

View File

@ -1962,7 +1962,8 @@ static struct usb_serial_driver option_1port_device = {
.chars_in_buffer = usb_wwan_chars_in_buffer, .chars_in_buffer = usb_wwan_chars_in_buffer,
.tiocmget = usb_wwan_tiocmget, .tiocmget = usb_wwan_tiocmget,
.tiocmset = usb_wwan_tiocmset, .tiocmset = usb_wwan_tiocmset,
.ioctl = usb_wwan_ioctl, .get_serial = usb_wwan_get_serial_info,
.set_serial = usb_wwan_set_serial_info,
.attach = option_attach, .attach = option_attach,
.release = option_release, .release = option_release,
.port_probe = usb_wwan_port_probe, .port_probe = usb_wwan_port_probe,

View File

@ -15,8 +15,10 @@ extern int usb_wwan_write_room(struct tty_struct *tty);
extern int usb_wwan_tiocmget(struct tty_struct *tty); extern int usb_wwan_tiocmget(struct tty_struct *tty);
extern int usb_wwan_tiocmset(struct tty_struct *tty, extern int usb_wwan_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear); unsigned int set, unsigned int clear);
extern int usb_wwan_ioctl(struct tty_struct *tty, extern int usb_wwan_get_serial_info(struct tty_struct *tty,
unsigned int cmd, unsigned long arg); struct serial_struct *ss);
extern int usb_wwan_set_serial_info(struct tty_struct *tty,
struct serial_struct *ss);
extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count); const unsigned char *buf, int count);
extern int usb_wwan_chars_in_buffer(struct tty_struct *tty); extern int usb_wwan_chars_in_buffer(struct tty_struct *tty);

View File

@ -132,38 +132,32 @@ int usb_wwan_tiocmset(struct tty_struct *tty,
} }
EXPORT_SYMBOL(usb_wwan_tiocmset); EXPORT_SYMBOL(usb_wwan_tiocmset);
static int get_serial_info(struct usb_serial_port *port, int usb_wwan_get_serial_info(struct tty_struct *tty,
struct serial_struct __user *retinfo) struct serial_struct *ss)
{ {
struct serial_struct tmp; struct usb_serial_port *port = tty->driver_data;
memset(&tmp, 0, sizeof(tmp)); ss->line = port->minor;
tmp.line = port->minor; ss->port = port->port_number;
tmp.port = port->port_number; ss->baud_base = tty_get_baud_rate(port->port.tty);
tmp.baud_base = tty_get_baud_rate(port->port.tty); ss->close_delay = port->port.close_delay / 10;
tmp.close_delay = port->port.close_delay / 10; ss->closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
tmp.closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE : ASYNC_CLOSING_WAIT_NONE :
port->port.closing_wait / 10; port->port.closing_wait / 10;
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
return -EFAULT;
return 0; return 0;
} }
EXPORT_SYMBOL(usb_wwan_get_serial_info);
static int set_serial_info(struct usb_serial_port *port, int usb_wwan_set_serial_info(struct tty_struct *tty,
struct serial_struct __user *newinfo) struct serial_struct *ss)
{ {
struct serial_struct new_serial; struct usb_serial_port *port = tty->driver_data;
unsigned int closing_wait, close_delay; unsigned int closing_wait, close_delay;
int retval = 0; int retval = 0;
if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) close_delay = ss->close_delay * 10;
return -EFAULT; closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10;
close_delay = new_serial.close_delay * 10;
closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
mutex_lock(&port->port.mutex); mutex_lock(&port->port.mutex);
@ -181,30 +175,7 @@ static int set_serial_info(struct usb_serial_port *port,
mutex_unlock(&port->port.mutex); mutex_unlock(&port->port.mutex);
return retval; return retval;
} }
EXPORT_SYMBOL(usb_wwan_set_serial_info);
int usb_wwan_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
struct usb_serial_port *port = tty->driver_data;
dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
switch (cmd) {
case TIOCGSERIAL:
return get_serial_info(port,
(struct serial_struct __user *) arg);
case TIOCSSERIAL:
return set_serial_info(port,
(struct serial_struct __user *) arg);
default:
break;
}
dev_dbg(&port->dev, "%s arg not supported\n", __func__);
return -ENOIOCTLCMD;
}
EXPORT_SYMBOL(usb_wwan_ioctl);
int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count) const unsigned char *buf, int count)