usb-serial: begin switching to ->[sg]et_serial()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 12 Sep 2018 03:28:07 +0000 (23:28 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 13 Oct 2018 04:50:34 +0000 (00:50 -0400)
add such methods for usb_serial_driver, provide tty_operations
->[sg]et_serial() calling those.  For now the lack of methods
in driver means ENOIOCTLCMD from usb-serial ->[sg]et_serial(),
making tty_ioctl() fall back to calling ->ioctl().  Once all
drivers are converted, we'll be returning -ENOTTY instead,
completing the switchover.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/usb/serial/usb-serial.c
include/linux/usb/serial.h

index f7aaa7f079e1a041f666cc0b0fefbc4da0474972..0f96d82fc575c99b99413b42ff5c3f29e78e0c0c 100644 (file)
@@ -396,6 +396,24 @@ static void serial_unthrottle(struct tty_struct *tty)
                port->serial->type->unthrottle(tty);
 }
 
                port->serial->type->unthrottle(tty);
 }
 
+static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss)
+{
+       struct usb_serial_port *port = tty->driver_data;
+
+       if (port->serial->type->get_serial)
+               return port->serial->type->get_serial(tty, ss);
+       return -ENOIOCTLCMD;
+}
+
+static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss)
+{
+       struct usb_serial_port *port = tty->driver_data;
+
+       if (port->serial->type->set_serial)
+               return port->serial->type->set_serial(tty, ss);
+       return -ENOIOCTLCMD;
+}
+
 static int serial_ioctl(struct tty_struct *tty,
                                        unsigned int cmd, unsigned long arg)
 {
 static int serial_ioctl(struct tty_struct *tty,
                                        unsigned int cmd, unsigned long arg)
 {
@@ -1177,6 +1195,8 @@ static const struct tty_operations serial_ops = {
        .tiocmget =             serial_tiocmget,
        .tiocmset =             serial_tiocmset,
        .get_icount =           serial_get_icount,
        .tiocmget =             serial_tiocmget,
        .tiocmset =             serial_tiocmset,
        .get_icount =           serial_get_icount,
+       .set_serial =           serial_set_serial,
+       .get_serial =           serial_get_serial,
        .cleanup =              serial_cleanup,
        .install =              serial_install,
        .proc_show =            serial_proc_show,
        .cleanup =              serial_cleanup,
        .install =              serial_install,
        .proc_show =            serial_proc_show,
index 106551a5616ed9a851987abc84db0d9c49198400..1c19f77ed54113aefabf4699affff6c0de5e74c4 100644 (file)
@@ -285,6 +285,8 @@ struct usb_serial_driver {
        int  (*write_room)(struct tty_struct *tty);
        int  (*ioctl)(struct tty_struct *tty,
                      unsigned int cmd, unsigned long arg);
        int  (*write_room)(struct tty_struct *tty);
        int  (*ioctl)(struct tty_struct *tty,
                      unsigned int cmd, unsigned long arg);
+       int  (*get_serial)(struct tty_struct *tty, struct serial_struct *ss);
+       int  (*set_serial)(struct tty_struct *tty, struct serial_struct *ss);
        void (*set_termios)(struct tty_struct *tty,
                        struct usb_serial_port *port, struct ktermios *old);
        void (*break_ctl)(struct tty_struct *tty, int break_state);
        void (*set_termios)(struct tty_struct *tty,
                        struct usb_serial_port *port, struct ktermios *old);
        void (*break_ctl)(struct tty_struct *tty, int break_state);