]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
serial: mctrl_gpio: add modem control read routine
authorYegor Yefremov <yegorslists@googlemail.com>
Tue, 31 May 2016 08:59:16 +0000 (10:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2016 21:30:42 +0000 (14:30 -0700)
mctrl_gpio_get_outputs() returns the state of following signals:

RTS, DTR

While defining the routine for reading outputs, fix the comment for
mctrl_gpio_get() routine as it returns only the state of the input
signals.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_mctrl_gpio.c
drivers/tty/serial/serial_mctrl_gpio.h

index e8dd5097dc5674d928a3f0f8c70658f737bb9aaa..a868595beab01b2ee391f71d41b5cf7ff5ece014 100644 (file)
@@ -86,6 +86,24 @@ unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl)
 }
 EXPORT_SYMBOL_GPL(mctrl_gpio_get);
 
+unsigned int
+mctrl_gpio_get_outputs(struct mctrl_gpios *gpios, unsigned int *mctrl)
+{
+       enum mctrl_gpio_idx i;
+
+       for (i = 0; i < UART_GPIO_MAX; i++) {
+               if (gpios->gpio[i] && mctrl_gpios_desc[i].dir_out) {
+                       if (gpiod_get_value(gpios->gpio[i]))
+                               *mctrl |= mctrl_gpios_desc[i].mctrl;
+                       else
+                               *mctrl &= ~mctrl_gpios_desc[i].mctrl;
+               }
+       }
+
+       return *mctrl;
+}
+EXPORT_SYMBOL_GPL(mctrl_gpio_get_outputs);
+
 struct mctrl_gpios *mctrl_gpio_init_noauto(struct device *dev, unsigned int idx)
 {
        struct mctrl_gpios *gpios;
index 332a33ab0647cbe3fe5d9b9b13dd1b8b78eb0b84..fa000bcff217004d29d05f5b943329fc07e0ca53 100644 (file)
@@ -48,11 +48,18 @@ struct mctrl_gpios;
 void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl);
 
 /*
- * Get state of the modem control output lines from GPIOs.
+ * Get state of the modem control input lines from GPIOs.
  * The mctrl flags are updated and returned.
  */
 unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl);
 
+/*
+ * Get state of the modem control output lines from GPIOs.
+ * The mctrl flags are updated and returned.
+ */
+unsigned int
+mctrl_gpio_get_outputs(struct mctrl_gpios *gpios, unsigned int *mctrl);
+
 /*
  * Returns the associated struct gpio_desc to the modem line gidx
  */
@@ -107,6 +114,12 @@ unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl)
        return *mctrl;
 }
 
+static inline unsigned int
+mctrl_gpio_get_outputs(struct mctrl_gpios *gpios, unsigned int *mctrl)
+{
+       return *mctrl;
+}
+
 static inline
 struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
                                      enum mctrl_gpio_idx gidx)