kernel: bump 4.14 to 4.14.118
[openwrt/staging/wigyori.git] / target / linux / lantiq / patches-4.14 / 0030-GPIO-add-named-gpio-exports.patch
index e2a421b27ed4a2372954d02fa7713d62c454d90a..8f0ac8d0f8854950c5b1242fff3a88d25d9717cd 100644 (file)
@@ -22,7 +22,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  
  #include "gpiolib.h"
  
-@@ -538,3 +540,73 @@ void of_gpiochip_remove(struct gpio_chip
+@@ -513,3 +515,72 @@ void of_gpiochip_remove(struct gpio_chip
        gpiochip_remove_pin_ranges(chip);
        of_node_put(chip->of_node);
  }
@@ -34,7 +34,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +      { /* sentinel */ }
 +};
 +
-+static int __init of_gpio_export_probe(struct platform_device *pdev)
++static int of_gpio_export_probe(struct platform_device *pdev)
 +{
 +      struct device_node *np = pdev->dev.of_node;
 +      struct device_node *cnp;
@@ -58,6 +58,8 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +                      enum of_gpio_flags of_flags;
 +
 +                      gpio = of_get_gpio_flags(cnp, i, &of_flags);
++                      if (!gpio_is_valid(gpio))
++                              return gpio;
 +
 +                      if (of_flags == OF_GPIO_ACTIVE_LOW)
 +                              flags |= GPIOF_ACTIVE_LOW;
@@ -87,18 +89,15 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +              .owner  = THIS_MODULE,
 +              .of_match_table = of_match_ptr(gpio_export_ids),
 +      },
++      .probe          = of_gpio_export_probe,
 +};
 +
-+static int __init of_gpio_export_init(void)
-+{
-+      return platform_driver_probe(&gpio_export_driver, of_gpio_export_probe);
-+}
-+device_initcall(of_gpio_export_init);
++module_platform_driver(gpio_export_driver);
 +
 +#endif
 --- a/include/asm-generic/gpio.h
 +++ b/include/asm-generic/gpio.h
-@@ -126,6 +126,12 @@ static inline int gpio_export(unsigned g
+@@ -127,6 +127,12 @@ static inline int gpio_export(unsigned g
        return gpiod_export(gpio_to_desc(gpio), direction_may_change);
  }
  
@@ -113,7 +112,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  {
 --- a/include/linux/gpio/consumer.h
 +++ b/include/linux/gpio/consumer.h
-@@ -427,6 +427,7 @@ static inline struct gpio_desc *devm_get
+@@ -451,6 +451,7 @@ struct gpio_desc *devm_fwnode_get_gpiod_
  
  #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
  
@@ -121,7 +120,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
  int gpiod_export_link(struct device *dev, const char *name,
                      struct gpio_desc *desc);
-@@ -434,6 +435,13 @@ void gpiod_unexport(struct gpio_desc *de
+@@ -458,6 +459,13 @@ void gpiod_unexport(struct gpio_desc *de
  
  #else  /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
  
@@ -137,7 +136,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  {
 --- a/drivers/gpio/gpiolib-sysfs.c
 +++ b/drivers/gpio/gpiolib-sysfs.c
-@@ -544,7 +544,7 @@ static struct class gpio_class = {
+@@ -553,7 +553,7 @@ static struct class gpio_class = {
   *
   * Returns zero on success, else an error.
   */
@@ -146,7 +145,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  {
        struct gpio_chip        *chip;
        struct gpio_device      *gdev;
-@@ -606,6 +606,8 @@ int gpiod_export(struct gpio_desc *desc,
+@@ -615,6 +615,8 @@ int gpiod_export(struct gpio_desc *desc,
        offset = gpio_chip_hwgpio(desc);
        if (chip->names && chip->names[offset])
                ioname = chip->names[offset];
@@ -155,7 +154,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
  
        dev = device_create_with_groups(&gpio_class, &gdev->dev,
                                        MKDEV(0, 0), data, gpio_groups,
-@@ -627,6 +629,12 @@ err_unlock:
+@@ -636,6 +638,12 @@ err_unlock:
        gpiod_dbg(desc, "%s: status %d\n", __func__, status);
        return status;
  }