Merge tag 'driver-core-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / drivers / gpio / gpiolib-of.c
index 1436cdb5fa2686273cbdd1b407d2a48f1fc25766..531faabead0f40feb60e583f33b7e0bbfa70e0e3 100644 (file)
@@ -209,6 +209,8 @@ static void of_gpio_set_polarity_by_property(const struct device_node *np,
                                             const char *propname,
                                             enum of_gpio_flags *flags)
 {
+       const struct device_node *np_compat = np;
+       const struct device_node *np_propname = np;
        static const struct {
                const char *compatible;
                const char *gpio_propname;
@@ -252,15 +254,29 @@ static void of_gpio_set_polarity_by_property(const struct device_node *np,
 #if IS_ENABLED(CONFIG_REGULATOR_GPIO)
                { "regulator-gpio",    "enable-gpio",  "enable-active-high" },
                { "regulator-gpio",    "enable-gpios", "enable-active-high" },
+#endif
+#if IS_ENABLED(CONFIG_MMC_ATMELMCI)
+               { "atmel,hsmci",       "cd-gpios",     "cd-inverted" },
 #endif
        };
        unsigned int i;
        bool active_high;
 
+#if IS_ENABLED(CONFIG_MMC_ATMELMCI)
+       /*
+        * The Atmel HSMCI has compatible property in the parent node and
+        * gpio property in a child node
+        */
+       if (of_device_is_compatible(np->parent, "atmel,hsmci")) {
+               np_compat = np->parent;
+               np_propname = np;
+       }
+#endif
+
        for (i = 0; i < ARRAY_SIZE(gpios); i++) {
-               if (of_device_is_compatible(np, gpios[i].compatible) &&
+               if (of_device_is_compatible(np_compat, gpios[i].compatible) &&
                    !strcmp(propname, gpios[i].gpio_propname)) {
-                       active_high = of_property_read_bool(np,
+                       active_high = of_property_read_bool(np_propname,
                                                gpios[i].polarity_propname);
                        of_gpio_quirk_polarity(np, active_high, flags);
                        break;
@@ -1078,16 +1094,16 @@ int of_gpiochip_add(struct gpio_chip *chip)
        if (ret)
                return ret;
 
-       fwnode_handle_get(chip->fwnode);
+       of_node_get(np);
 
        ret = of_gpiochip_scan_gpios(chip);
        if (ret)
-               fwnode_handle_put(chip->fwnode);
+               of_node_put(np);
 
        return ret;
 }
 
 void of_gpiochip_remove(struct gpio_chip *chip)
 {
-       fwnode_handle_put(chip->fwnode);
+       of_node_put(dev_of_node(&chip->gpiodev->dev));
 }