]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
greybus: uart: Add runtime pm support
authorAxel Haslam <haslam_axel@projectara.com>
Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)
committerAlex Elder <elder@linaro.org>
Thu, 14 Jul 2016 21:53:55 +0000 (16:53 -0500)
This adds runtime pm support for the uart driver.

Testing Done: Using the test daughter board, let
the gpb bridge enter standby and do a uart transfer
operation.

Signed-off-by: Axel Haslam <haslam_axel@projectara.com>
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Alex Elder <elder@linaro.org>
drivers/staging/greybus/uart.c

index 6260569b2f25672c906ff96415113d51083ee6c6..01aeed1b3a9c0e1ad09af069d7d6a3a4e8b4dab9 100644 (file)
@@ -771,6 +771,16 @@ static void gb_tty_dtr_rts(struct tty_port *port, int on)
        send_control(gb_tty, newctrl);
 }
 
+static int gb_tty_port_activate(struct tty_port *port,
+                               struct tty_struct *tty)
+{
+       struct gb_tty *gb_tty;
+
+       gb_tty = container_of(port, struct gb_tty, port);
+
+       return gbphy_runtime_get_sync(gb_tty->gbphy_dev);
+}
+
 static void gb_tty_port_shutdown(struct tty_port *port)
 {
        struct gb_tty *gb_tty;
@@ -800,6 +810,8 @@ static void gb_tty_port_shutdown(struct tty_port *port)
 
 out:
        gb_tty->close_pending = false;
+
+       gbphy_runtime_put_autosuspend(gb_tty->gbphy_dev);
 }
 
 static const struct tty_operations gb_ops = {
@@ -822,6 +834,7 @@ static const struct tty_operations gb_ops = {
 
 static struct tty_port_operations gb_port_ops = {
        .dtr_rts =              gb_tty_dtr_rts,
+       .activate =             gb_tty_port_activate,
        .shutdown =             gb_tty_port_shutdown,
 };
 
@@ -922,6 +935,7 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
                goto exit_connection_disable;
        }
 
+       gbphy_runtime_put_autosuspend(gbphy_dev);
        return 0;
 
 exit_connection_disable:
@@ -945,6 +959,11 @@ static void gb_uart_remove(struct gbphy_device *gbphy_dev)
        struct gb_tty *gb_tty = gb_gbphy_get_data(gbphy_dev);
        struct gb_connection *connection = gb_tty->connection;
        struct tty_struct *tty;
+       int ret;
+
+       ret = gbphy_runtime_get_sync(gbphy_dev);
+       if (ret)
+               gbphy_runtime_get_noresume(gbphy_dev);
 
        mutex_lock(&gb_tty->mutex);
        gb_tty->disconnected = true;