]> exis.tech > repos - linux.git/blobdiff - drivers/tty/serial/max310x.c
Merge tag 'hwmon-for-v7.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groec...
[linux.git] / drivers / tty / serial / max310x.c
index 59e71306a5d46583fc8af194a4ed57f72fa927a7..5fe12577ce8b887bd03698808d38fabdae2b9754 100644 (file)
@@ -1243,6 +1243,17 @@ static int max310x_gpio_set(struct gpio_chip *chip, unsigned int offset,
        return 0;
 }
 
+static int max310x_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
+{
+       struct max310x_port *s = gpiochip_get_data(chip);
+       struct uart_port *port = &s->p[offset / 4].port;
+       unsigned int val;
+
+       val = max310x_port_read(port, MAX310X_GPIOCFG_REG);
+
+       return val & BIT(offset % 4) ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
+}
+
 static int max310x_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
 {
        struct max310x_port *s = gpiochip_get_data(chip);
@@ -1446,6 +1457,7 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
        s->gpio.owner           = THIS_MODULE;
        s->gpio.parent          = dev;
        s->gpio.label           = devtype->name;
+       s->gpio.get_direction   = max310x_gpio_get_direction;
        s->gpio.direction_input = max310x_gpio_direction_input;
        s->gpio.get             = max310x_gpio_get;
        s->gpio.direction_output= max310x_gpio_direction_output;