Merge tag 'spi-fix-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[linux-2.6-microblaze.git] / drivers / gpio / gpiolib-of.c
index f90a161..b696e45 100644 (file)
@@ -50,7 +50,7 @@ static int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id)
  * This is used by external users of of_gpio_count() from <linux/of_gpio.h>
  *
  * FIXME: get rid of those external users by converting them to GPIO
- * descriptors and let them all use gpiod_get_count()
+ * descriptors and let them all use gpiod_count()
  */
 int of_gpio_get_count(struct device *dev, const char *con_id)
 {
@@ -111,8 +111,9 @@ static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip,
 /**
  * of_gpio_need_valid_mask() - figure out if the OF GPIO driver needs
  * to set the .valid_mask
- * @dev: the device for the GPIO provider
- * @return: true if the valid mask needs to be set
+ * @gc: the target gpio_chip
+ *
+ * Return: true if the valid mask needs to be set
  */
 bool of_gpio_need_valid_mask(const struct gpio_chip *gc)
 {
@@ -161,18 +162,20 @@ static void of_gpio_flags_quirks(struct device_node *np,
             (!(strcmp(propname, "enable-gpio") &&
                strcmp(propname, "enable-gpios")) &&
              of_device_is_compatible(np, "regulator-gpio")))) {
+               bool active_low = !of_property_read_bool(np,
+                                                        "enable-active-high");
                /*
                 * The regulator GPIO handles are specified such that the
                 * presence or absence of "enable-active-high" solely controls
                 * the polarity of the GPIO line. Any phandle flags must
                 * be actively ignored.
                 */
-               if (*flags & OF_GPIO_ACTIVE_LOW) {
+               if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) {
                        pr_warn("%s GPIO handle specifies active low - ignored\n",
                                of_node_full_name(np));
                        *flags &= ~OF_GPIO_ACTIVE_LOW;
                }
-               if (!of_property_read_bool(np, "enable-active-high"))
+               if (active_low)
                        *flags |= OF_GPIO_ACTIVE_LOW;
        }
        /*
@@ -344,7 +347,7 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
        transitory = flags & OF_GPIO_TRANSITORY;
 
        ret = gpiod_request(desc, label);
-       if (ret == -EBUSY && (flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE))
+       if (ret == -EBUSY && (dflags & GPIOD_FLAGS_BIT_NONEXCLUSIVE))
                return desc;
        if (ret)
                return ERR_PTR(ret);
@@ -909,16 +912,13 @@ int of_gpiochip_add(struct gpio_chip *chip)
        of_node_get(chip->of_node);
 
        ret = of_gpiochip_scan_gpios(chip);
-       if (ret) {
+       if (ret)
                of_node_put(chip->of_node);
-               gpiochip_remove_pin_ranges(chip);
-       }
 
        return ret;
 }
 
 void of_gpiochip_remove(struct gpio_chip *chip)
 {
-       gpiochip_remove_pin_ranges(chip);
        of_node_put(chip->of_node);
 }