Kernel 5.4
authorDavid Bauer <[email protected]>
Tue, 18 May 2021 15:16:19 +0000 (17:16 +0200)
committerDavid Bauer <[email protected]>
Wed, 26 May 2021 09:39:36 +0000 (11:39 +0200)
target/linux/ramips/files/drivers/pinctrl/pinctrl-aw9523.c

index 7a334e26e44f278352a00efe18899b235d8dd26f..182e11cdc6faf6d6ec5507d82e0d76f82b631797 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/version.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/pinctrl/pinconf.h>
@@ -385,6 +386,11 @@ static const struct pinconf_ops aw9523_pinconf_ops = {
        .is_generic = true,
 };
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 5, 0)
+#define GPIO_LINE_DIRECTION_IN 1
+#define GPIO_LINE_DIRECTION_OUT        0
+#endif
+
 /*
  * aw9523_get_pin_direction - Get pin direction
  * @regmap: Regmap structure
@@ -395,13 +401,13 @@ static const struct pinconf_ops aw9523_pinconf_ops = {
  */
 static int aw9523_get_pin_direction(struct regmap *regmap, u8 pin, u8 n)
 {
-       int ret;
+       int val, ret;
 
-       ret = regmap_test_bits(regmap, AW9523_REG_CONF_STATE(pin), BIT(n));
+       ret = regmap_read(regmap, AW9523_REG_CONF_STATE(pin), &val);
        if (ret < 0)
                return ret;
 
-       return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
+       return (val & BIT(n)) == BIT(n);
 }
 
 /*
@@ -431,6 +437,11 @@ static int aw9523_get_port_state(struct regmap *regmap, u8 pin,
        return regmap_read(regmap, reg, state);
 }
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 5, 0)
+#undef GPIO_LINE_DIRECTION_IN
+#undef GPIO_LINE_DIRECTION_OUT
+#endif
+
 static int aw9523_gpio_irq_type(struct irq_data *d, unsigned int type)
 {
        switch (type) {