]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
greybus: uart: Implement dtr_rts callback.
authorAxel Haslam <ahaslam@baylibre.com>
Tue, 31 May 2016 12:36:09 +0000 (14:36 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 1 Jun 2016 00:18:18 +0000 (17:18 -0700)
Dtr_dts allows the tty layer to set the flow control lines
to the correct state during open and close.

Note that locking for newctrl is missing throughout the
driver and will be addressed on a separate patch.

Suggested-and-reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/uart.c

index 44d8b9ad183ac083c1b5582cb9f02a4fe2cae74e..c257fbf40b79815024217f547b44b2b0d6b53c53 100644 (file)
@@ -604,6 +604,22 @@ static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
        return -ENOIOCTLCMD;
 }
 
+static void gb_tty_dtr_rts(struct tty_port *port, int on)
+{
+       struct gb_tty *gb_tty;
+       u8 newctrl;
+
+       gb_tty = container_of(port, struct gb_tty, port);
+       newctrl = gb_tty->ctrlout;
+
+       if (on)
+               newctrl |= (GB_UART_CTRL_DTR | GB_UART_CTRL_RTS);
+       else
+               newctrl &= ~(GB_UART_CTRL_DTR | GB_UART_CTRL_RTS);
+
+       gb_tty->ctrlout = newctrl;
+       send_control(gb_tty, newctrl);
+}
 
 static const struct tty_operations gb_ops = {
        .install =              gb_tty_install,
@@ -623,7 +639,9 @@ static const struct tty_operations gb_ops = {
        .tiocmset =             gb_tty_tiocmset,
 };
 
-static struct tty_port_operations null_ops = { };
+static struct tty_port_operations gb_port_ops = {
+       .dtr_rts =              gb_tty_dtr_rts,
+};
 
 static int gb_uart_probe(struct gbphy_device *gbphy_dev,
                         const struct gbphy_device_id *id)
@@ -681,7 +699,7 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
        mutex_init(&gb_tty->mutex);
 
        tty_port_init(&gb_tty->port);
-       gb_tty->port.ops = &null_ops;
+       gb_tty->port.ops = &gb_port_ops;
 
        gb_tty->connection = connection;
        gb_tty->gbphy_dev = gbphy_dev;