Skip to contentSkip to conversation

gpio: of: Check propname before applying "cs-gpios" quirks

PATCH In review Andrey Smirnov 2 participants 4 messages Mar 26, 2019 – Mar 28, 2019 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gpio: of: Check propname before applying "cs-gpios" quirks

SPI GPIO device has more than just "cs-gpio" property in its node and would request those GPIOs as a part of its initialization. To avoid applying CS-specific quirk to all of them add a check to make sure that propname is "cs-gpios".

---
 drivers/gpio/gpiolib-of.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-of.c +2 -1
index 8b9c3ab70f6e..ee7f08386a72 100644
@@ -120,7 +120,8 @@ static void of_gpio_flags_quirks(struct device_node *np,
 	 * to determine if the flags should have inverted semantics.
 	 */
 	if (IS_ENABLED(CONFIG_SPI_MASTER) &&
-	    of_property_read_bool(np, "cs-gpios")) {
+	    of_property_read_bool(np, "cs-gpios") &&
+	    !strcmp(propname, "cs-gpios")) {
 		struct device_node *child;
 		u32 cs;
 		int ret;
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 gpio: of: Check for "spi-cs-high" in child instead of parent node

"spi-cs-high" is going to be specified in child node of an SPI controller's representing attached SPI device, so change the code to look for it there, instead of checking parent node.

---
 drivers/gpio/gpiolib-of.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib-of.c +3 -3
index ee7f08386a72..0220dd6d64ed 100644
@@ -143,16 +143,16 @@ static void of_gpio_flags_quirks(struct device_node *np,
 				 * conflict and the "spi-cs-high" flag will
 				 * take precedence.
 				 */
-				if (of_property_read_bool(np, "spi-cs-high")) {
+				if (of_property_read_bool(child, "spi-cs-high")) {
 					if (*flags & OF_GPIO_ACTIVE_LOW) {
 						pr_warn("%s GPIO handle specifies active low - ignored\n",
-							of_node_full_name(np));
+							of_node_full_name(child));
 						*flags &= ~OF_GPIO_ACTIVE_LOW;
 					}
 				} else {
 					if (!(*flags & OF_GPIO_ACTIVE_LOW))
 						pr_info("%s enforce active low on chipselect handle\n",
-							of_node_full_name(np));
+							of_node_full_name(child));
 					*flags |= OF_GPIO_ACTIVE_LOW;
 				}
 				break;
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 2/2] gpio: of: Check for "spi-cs-high" in child instead of parent node

Quoted 10 lines · Andrey Smirnov

"spi-cs-high" is going to be specified in child node of an SPI controller's representing attached SPI device, so change the code to look for it there, instead of checking parent node.

Patch applied for fixes.

I could bet I exercised these code paths just the other week, but I don't know how it all ended up like this... :/

Thanks for fixing it up!!

Yours,
Linus Walleij

#3 lore raw
In reply to Andrey Smirnov
Quoted 11 lines · Andrey Smirnov

SPI GPIO device has more than just "cs-gpio" property in its node and would request those GPIOs as a part of its initialization. To avoid applying CS-specific quirk to all of them add a check to make sure that propname is "cs-gpios".

Patch applied for fixes.

Sorry for my mistakes...

Yours,
Linus Walleij