* [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review
@ 2021-11-21 16:56 Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 01/11] pinctrl: apple: fix some formatting issues Joey Gouly
                   ` (11 more replies)
  0 siblings, 12 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
Hi all,
Here's a series of small fixes that Andy made comments about, after the driver
was already in the pinctrl tree.
Changes since v1[1]:
  - No actual code changes (git diff pinctrl_apple_fixes_v1 pinctrl_apple_fixes_v2 is empty)
  - Split non-whitespace changes out from the first commit.
  - Add suggested-by tags
Thanks,
Joey
A branch can be found here:
    https://gitlab.arm.com/linux-arm/jg-open/-/tree/pinctrl_apple_fixes_v2
Joey Gouly (11):
  pinctrl: apple: fix some formatting issues
  pinctrl: apple: add missing comma
  pinctrl: apple: use C style comment
  pinctrl: apple: add missing bits.h header
  pinctrl: apple: handle regmap_read errors
  pinctrl: apple: make apple_gpio_get_direction more readable
  pinctrl: apple: give error label a specific name
  pinctrl: apple: remove gpio-controller check
  pinctrl: apple: don't set gpio_chip.of_node
  pinctrl: apple: use modulo rather than bitwise and
  pinctrl: apple: return an error if pinmux is missing in the DT
 drivers/pinctrl/pinctrl-apple-gpio.c | 103 ++++++++++++---------------
 1 file changed, 46 insertions(+), 57 deletions(-)
-- 
2.17.1
^ permalink raw reply	[flat|nested] 16+ messages in thread
* [PATCH v2 01/11] pinctrl: apple: fix some formatting issues
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 02/11] pinctrl: apple: add missing comma Joey Gouly
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
Reflow some of the code now that the extra '_gpio' was removed.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 69 +++++++++++-----------------
 1 file changed, 28 insertions(+), 41 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index a7861079a650..7299c7686f7f 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -75,13 +75,13 @@ struct regmap_config regmap_config = {
 
 // No locking needed to mask/unmask IRQs as the interrupt mode is per pin-register.
 static void apple_gpio_set_reg(struct apple_gpio_pinctrl *pctl,
-			       unsigned int pin, u32 mask, u32 value)
+                               unsigned int pin, u32 mask, u32 value)
 {
 	regmap_update_bits(pctl->map, REG_GPIO(pin), mask, value);
 }
 
 static uint32_t apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
-				   unsigned int pin)
+                              unsigned int pin)
 {
 	unsigned int val = 0;
 
@@ -92,9 +92,9 @@ static uint32_t apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
 /* Pin controller functions */
 
 static int apple_gpio_dt_node_to_map(struct pinctrl_dev *pctldev,
-				     struct device_node *node,
-				     struct pinctrl_map **map,
-				     unsigned *num_maps)
+                                     struct device_node *node,
+                                     struct pinctrl_map **map,
+                                     unsigned *num_maps)
 {
 	unsigned reserved_maps;
 	struct apple_gpio_pinctrl *pctl;
@@ -119,8 +119,7 @@ static int apple_gpio_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	num_pins = ret;
 
-	ret = pinctrl_utils_reserve_map(pctldev, map, &reserved_maps, num_maps,
-					num_pins);
+	ret = pinctrl_utils_reserve_map(pctldev, map, &reserved_maps, num_maps, num_pins);
 	if (ret)
 		return ret;
 
@@ -138,11 +137,10 @@ static int apple_gpio_dt_node_to_map(struct pinctrl_dev *pctldev,
 		}
 
 		group_name = pinctrl_generic_get_group_name(pctldev, pin);
-		function_name =
-			pinmux_generic_get_function_name(pctl->pctldev, func);
+		function_name = pinmux_generic_get_function_name(pctl->pctldev, func);
 		ret = pinctrl_utils_add_map_mux(pctl->pctldev, map,
-						&reserved_maps, num_maps,
-						group_name, function_name);
+		                                &reserved_maps, num_maps,
+		                                group_name, function_name);
 		if (ret)
 			goto free_map;
 	}
@@ -165,7 +163,7 @@ static const struct pinctrl_ops apple_gpio_pinctrl_ops = {
 /* Pin multiplexer functions */
 
 static int apple_gpio_pinmux_set(struct pinctrl_dev *pctldev, unsigned func,
-				    unsigned group)
+                                 unsigned group)
 {
 	struct apple_gpio_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
@@ -186,8 +184,7 @@ static const struct pinmux_ops apple_gpio_pinmux_ops = {
 
 /* GPIO chip functions */
 
-static int apple_gpio_get_direction(struct gpio_chip *chip,
-					 unsigned int offset)
+static int apple_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip);
 	unsigned int reg = apple_gpio_get_reg(pctl, offset);
@@ -211,17 +208,14 @@ static int apple_gpio_get(struct gpio_chip *chip, unsigned offset)
 	return !!(reg & REG_GPIOx_DATA);
 }
 
-static void apple_gpio_set(struct gpio_chip *chip, unsigned int offset,
-				int value)
+static void apple_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
 {
 	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip);
 
-	apple_gpio_set_reg(pctl, offset, REG_GPIOx_DATA,
-			   value ? REG_GPIOx_DATA : 0);
+	apple_gpio_set_reg(pctl, offset, REG_GPIOx_DATA, value ? REG_GPIOx_DATA : 0);
 }
 
-static int apple_gpio_direction_input(struct gpio_chip *chip,
-					   unsigned int offset)
+static int apple_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
 {
 	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip);
 
@@ -234,7 +228,7 @@ static int apple_gpio_direction_input(struct gpio_chip *chip,
 }
 
 static int apple_gpio_direction_output(struct gpio_chip *chip,
-					    unsigned int offset, int value)
+                                       unsigned int offset, int value)
 {
 	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip);
 
@@ -249,13 +243,10 @@ static int apple_gpio_direction_output(struct gpio_chip *chip,
 
 static void apple_gpio_irq_ack(struct irq_data *data)
 {
-	struct apple_gpio_pinctrl *pctl =
-		gpiochip_get_data(irq_data_get_irq_chip_data(data));
-	unsigned int irqgrp =
-		FIELD_GET(REG_GPIOx_GRP, apple_gpio_get_reg(pctl, data->hwirq));
+	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data));
+	unsigned int irqgrp = FIELD_GET(REG_GPIOx_GRP, apple_gpio_get_reg(pctl, data->hwirq));
 
-	writel(BIT(data->hwirq & 31),
-	       pctl->base + REG_IRQ(irqgrp, data->hwirq));
+	writel(BIT(data->hwirq & 31), pctl->base + REG_IRQ(irqgrp, data->hwirq));
 }
 
 static unsigned int apple_gpio_irq_type(unsigned int type)
@@ -278,20 +269,19 @@ static unsigned int apple_gpio_irq_type(unsigned int type)
 
 static void apple_gpio_irq_mask(struct irq_data *data)
 {
-	struct apple_gpio_pinctrl *pctl =
-		gpiochip_get_data(irq_data_get_irq_chip_data(data));
+	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data));
+
 	apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE,
-			   FIELD_PREP(REG_GPIOx_MODE, REG_GPIOx_IN_IRQ_OFF));
+	                   FIELD_PREP(REG_GPIOx_MODE, REG_GPIOx_IN_IRQ_OFF));
 }
 
 static void apple_gpio_irq_unmask(struct irq_data *data)
 {
-	struct apple_gpio_pinctrl *pctl =
-		gpiochip_get_data(irq_data_get_irq_chip_data(data));
+	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data));
 	unsigned int irqtype = apple_gpio_irq_type(irqd_get_trigger_type(data));
 
 	apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE,
-			   FIELD_PREP(REG_GPIOx_MODE, irqtype));
+	                   FIELD_PREP(REG_GPIOx_MODE, irqtype));
 }
 
 static unsigned int apple_gpio_irq_startup(struct irq_data *data)
@@ -300,7 +290,7 @@ static unsigned int apple_gpio_irq_startup(struct irq_data *data)
 	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip);
 
 	apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_GRP,
-			   FIELD_PREP(REG_GPIOx_GRP, 0));
+	                   FIELD_PREP(REG_GPIOx_GRP, 0));
 
 	apple_gpio_direction_input(chip, data->hwirq);
 	apple_gpio_irq_unmask(data);
@@ -308,18 +298,16 @@ static unsigned int apple_gpio_irq_startup(struct irq_data *data)
 	return 0;
 }
 
-static int apple_gpio_irq_set_type(struct irq_data *data,
-					unsigned int type)
+static int apple_gpio_irq_set_type(struct irq_data *data, unsigned int type)
 {
-	struct apple_gpio_pinctrl *pctl =
-		gpiochip_get_data(irq_data_get_irq_chip_data(data));
+	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data));
 	unsigned int irqtype = apple_gpio_irq_type(type);
 
 	if (irqtype == REG_GPIOx_IN_IRQ_OFF)
 		return -EINVAL;
 
 	apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE,
-			   FIELD_PREP(REG_GPIOx_MODE, irqtype));
+	                   FIELD_PREP(REG_GPIOx_MODE, irqtype));
 
 	if (type & IRQ_TYPE_LEVEL_MASK)
 		irq_set_handler_locked(data, handle_level_irq);
@@ -402,8 +390,7 @@ static int apple_gpio_register(struct apple_gpio_pinctrl *pctl)
 		}
 
 		for (i = 0; i < girq->num_parents; i++) {
-			ret = platform_get_irq(to_platform_device(pctl->dev),
-					       i);
+			ret = platform_get_irq(to_platform_device(pctl->dev), i);
 			if (ret < 0)
 				goto out;
 
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 02/11] pinctrl: apple: add missing comma
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 01/11] pinctrl: apple: fix some formatting issues Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 03/11] pinctrl: apple: use C style comment Joey Gouly
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
Add a missing comma at the end of the regmap initialisation.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 7299c7686f7f..60d46ce26115 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -70,7 +70,7 @@ struct regmap_config regmap_config = {
 	.cache_type = REGCACHE_FLAT,
 	.max_register = 512 * sizeof(u32),
 	.num_reg_defaults_raw = 512,
-	.use_relaxed_mmio = true
+	.use_relaxed_mmio = true,
 };
 
 // No locking needed to mask/unmask IRQs as the interrupt mode is per pin-register.
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 03/11] pinctrl: apple: use C style comment
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 01/11] pinctrl: apple: fix some formatting issues Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 02/11] pinctrl: apple: add missing comma Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 04/11] pinctrl: apple: add missing bits.h header Joey Gouly
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
This is the preferred comment style.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 60d46ce26115..102940058a11 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -73,7 +73,7 @@ struct regmap_config regmap_config = {
 	.use_relaxed_mmio = true,
 };
 
-// No locking needed to mask/unmask IRQs as the interrupt mode is per pin-register.
+/* No locking needed to mask/unmask IRQs as the interrupt mode is per pin-register. */
 static void apple_gpio_set_reg(struct apple_gpio_pinctrl *pctl,
                                unsigned int pin, u32 mask, u32 value)
 {
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 04/11] pinctrl: apple: add missing bits.h header
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (2 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 03/11] pinctrl: apple: use C style comment Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 05/11] pinctrl: apple: handle regmap_read errors Joey Gouly
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
This is needed for the BIT(n) macro.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 102940058a11..cce95367c156 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -11,6 +11,7 @@
  */
 
 #include <dt-bindings/pinctrl/apple.h>
+#include <linux/bits.h>
 #include <linux/gpio/driver.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 05/11] pinctrl: apple: handle regmap_read errors
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (3 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 04/11] pinctrl: apple: add missing bits.h header Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 06/11] pinctrl: apple: make apple_gpio_get_direction more readable Joey Gouly
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
Explicitly return 0 if the regmap_read fails.
Also change a uint32_t to a u32.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index cce95367c156..bd7f28150ac0 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -81,12 +81,16 @@ static void apple_gpio_set_reg(struct apple_gpio_pinctrl *pctl,
 	regmap_update_bits(pctl->map, REG_GPIO(pin), mask, value);
 }
 
-static uint32_t apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
+static u32 apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
                               unsigned int pin)
 {
-	unsigned int val = 0;
+	int ret;
+	u32 val;
+
+	ret = regmap_read(pctl->map, REG_GPIO(pin), &val);
+	if (ret)
+		return 0;
 
-	regmap_read(pctl->map, REG_GPIO(pin), &val);
 	return val;
 }
 
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 06/11] pinctrl: apple: make apple_gpio_get_direction more readable
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (4 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 05/11] pinctrl: apple: handle regmap_read errors Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 07/11] pinctrl: apple: give error label a specific name Joey Gouly
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
Try to make this more readable by not using a long line with
a ternary operator.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index bd7f28150ac0..fba2d4ec383c 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -194,8 +194,9 @@ static int apple_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
 	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip);
 	unsigned int reg = apple_gpio_get_reg(pctl, offset);
 
-	return (FIELD_GET(REG_GPIOx_MODE, reg) == REG_GPIOx_OUT) ?
-		       GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
+	if (FIELD_GET(REG_GPIOx_MODE, reg) == REG_GPIOx_OUT)
+		return GPIO_LINE_DIRECTION_OUT;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int apple_gpio_get(struct gpio_chip *chip, unsigned offset)
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 07/11] pinctrl: apple: give error label a specific name
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (5 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 06/11] pinctrl: apple: make apple_gpio_get_direction more readable Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 08/11] pinctrl: apple: remove gpio-controller check Joey Gouly
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index fba2d4ec383c..fb34cbe189ce 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -392,13 +392,13 @@ static int apple_gpio_register(struct apple_gpio_pinctrl *pctl)
 					 GFP_KERNEL);
 		if (!girq->parents || !irq_data) {
 			ret = -ENOMEM;
-			goto out;
+			goto out_free_irq_data;
 		}
 
 		for (i = 0; i < girq->num_parents; i++) {
 			ret = platform_get_irq(to_platform_device(pctl->dev), i);
 			if (ret < 0)
-				goto out;
+				goto out_free_irq_data;
 
 			girq->parents[i] = ret;
 			pctl->irqgrps[i] = i;
@@ -412,7 +412,8 @@ static int apple_gpio_register(struct apple_gpio_pinctrl *pctl)
 	}
 
 	ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl);
-out:
+
+out_free_irq_data:
 	kfree(girq->parents);
 	kfree(irq_data);
 
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 08/11] pinctrl: apple: remove gpio-controller check
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (6 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 07/11] pinctrl: apple: give error label a specific name Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 09/11] pinctrl: apple: don't set gpio_chip.of_node Joey Gouly
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
Having this missing, but everything else valid shouldn't result
in a failure.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 4 ----
 1 file changed, 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index fb34cbe189ce..471d3abf9d99 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -360,10 +360,6 @@ static int apple_gpio_register(struct apple_gpio_pinctrl *pctl)
 	void **irq_data = NULL;
 	int ret;
 
-	if (!of_property_read_bool(pctl->dev->of_node, "gpio-controller"))
-		return dev_err_probe(pctl->dev,	-ENODEV,
-				     "No gpio-controller property\n");
-
 	pctl->irq_chip = apple_gpio_irqchip;
 
 	pctl->gpio_chip.label = dev_name(pctl->dev);
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 09/11] pinctrl: apple: don't set gpio_chip.of_node
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (7 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 08/11] pinctrl: apple: remove gpio-controller check Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 10/11] pinctrl: apple: use modulo rather than bitwise and Joey Gouly
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
The gpio core code sets of_node, so no need to do it here.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 471d3abf9d99..8e794ebb47da 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -373,7 +373,6 @@ static int apple_gpio_register(struct apple_gpio_pinctrl *pctl)
 	pctl->gpio_chip.base = -1;
 	pctl->gpio_chip.ngpio = pctl->pinctrl_desc.npins;
 	pctl->gpio_chip.parent = pctl->dev;
-	pctl->gpio_chip.of_node = pctl->dev->of_node;
 
 	if (girq->num_parents) {
 		int i;
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 10/11] pinctrl: apple: use modulo rather than bitwise and
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (8 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 09/11] pinctrl: apple: don't set gpio_chip.of_node Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-21 16:56 ` [PATCH v2 11/11] pinctrl: apple: return an error if pinmux is missing in the DT Joey Gouly
  2021-11-22  0:15 ` [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Linus Walleij
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
This expresses the intention clearer.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 8e794ebb47da..8a58c862c33a 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -252,7 +252,7 @@ static void apple_gpio_irq_ack(struct irq_data *data)
 	struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data));
 	unsigned int irqgrp = FIELD_GET(REG_GPIOx_GRP, apple_gpio_get_reg(pctl, data->hwirq));
 
-	writel(BIT(data->hwirq & 31), pctl->base + REG_IRQ(irqgrp, data->hwirq));
+	writel(BIT(data->hwirq % 32), pctl->base + REG_IRQ(irqgrp, data->hwirq));
 }
 
 static unsigned int apple_gpio_irq_type(unsigned int type)
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 11/11] pinctrl: apple: return an error if pinmux is missing in the DT
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (9 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 10/11] pinctrl: apple: use modulo rather than bitwise and Joey Gouly
@ 2021-11-21 16:56 ` Joey Gouly
  2021-11-22  0:15 ` [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Linus Walleij
  11 siblings, 0 replies; 16+ messages in thread
From: Joey Gouly @ 2021-11-21 16:56 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Andy Shevchenko, Hector Martin, nd, Joey Gouly
If of_property_count_u32_elems returned 0, return -EINVAL to indicate
a failure. Previously this would return 0.
Fixes: a0f160ffcb83 ("pinctrl: add pinctrl/GPIO driver for Apple SoCs")
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/pinctrl-apple-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 8a58c862c33a..89602aa14c6a 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -119,7 +119,7 @@ static int apple_gpio_dt_node_to_map(struct pinctrl_dev *pctldev,
 		dev_err(pctl->dev,
 			"missing or empty pinmux property in node %pOFn.\n",
 			node);
-		return ret;
+		return ret ? ret : -EINVAL;
 	}
 
 	num_pins = ret;
-- 
2.17.1
^ permalink raw reply related	[flat|nested] 16+ messages in thread
* Re: [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review
  2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
                   ` (10 preceding siblings ...)
  2021-11-21 16:56 ` [PATCH v2 11/11] pinctrl: apple: return an error if pinmux is missing in the DT Joey Gouly
@ 2021-11-22  0:15 ` Linus Walleij
  2021-11-26  0:53   ` Linus Walleij
  11 siblings, 1 reply; 16+ messages in thread
From: Linus Walleij @ 2021-11-22  0:15 UTC (permalink / raw)
  To: Joey Gouly; +Cc: linux-gpio, Andy Shevchenko, Hector Martin, nd
Hi Joel,
On Sun, Nov 21, 2021 at 5:57 PM Joey Gouly <joey.gouly@arm.com> wrote:
> Here's a series of small fixes that Andy made comments about, after the driver
> was already in the pinctrl tree.
I tried to apply this on the pinctrl tree based on v5.16-rc1, have you tested
this?
It didn't work for me :(
Can you try to rebase to v5.16-rc1 so this can go in as non urgent fixes
for v5.17?
Yours,
Linus Walleij
^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review
  2021-11-22  0:15 ` [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Linus Walleij
@ 2021-11-26  0:53   ` Linus Walleij
  2021-11-26 22:30     ` Joey Gouly
  0 siblings, 1 reply; 16+ messages in thread
From: Linus Walleij @ 2021-11-26  0:53 UTC (permalink / raw)
  To: Joey Gouly; +Cc: linux-gpio, Andy Shevchenko, Hector Martin, nd
On Mon, Nov 22, 2021 at 1:15 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> I tried to apply this on the pinctrl tree based on v5.16-rc1, have you tested
> this?
>
> It didn't work for me :(
Still doesn't work. Please try on top of this branch:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=devel
This happens:
$ git am --signoff
./v2_20211121_joey_gouly_pinctrl_apple_misc_fixes_from_post_commit_review.mbx
Applying: pinctrl: apple: fix some formatting issues
error: patch failed: drivers/pinctrl/pinctrl-apple-gpio.c:249
error: drivers/pinctrl/pinctrl-apple-gpio.c: patch does not apply
Patch failed at 0001 pinctrl: apple: fix some formatting issues
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
Trying manually:
$ patch -p1 < ./v2_20211121_joey_gouly_pinctrl_apple_misc_fixes_from_post_commit_review.mbx
patching file drivers/pinctrl/pinctrl-apple-gpio.c
Hunk #9 succeeded at 243 with fuzz 1.
Hunk #10 FAILED at 269.
Hunk #12 FAILED at 299.
2 out of 13 hunks FAILED -- saving rejects to file
drivers/pinctrl/pinctrl-apple-gpio.c.rej
What am I doing wrong?
Yours,
Linus Walleij
^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review
  2021-11-26  0:53   ` Linus Walleij
@ 2021-11-26 22:30     ` Joey Gouly
  2021-11-27  0:01       ` Linus Walleij
  0 siblings, 1 reply; 16+ messages in thread
From: Joey Gouly @ 2021-11-26 22:30 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, Andy Shevchenko, Hector Martin, nd
Hi,
On Fri, Nov 26, 2021 at 01:53:13AM +0100, Linus Walleij wrote:
> On Mon, Nov 22, 2021 at 1:15 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> 
> > I tried to apply this on the pinctrl tree based on v5.16-rc1, have you tested
> > this?
> >
> > It didn't work for me :(
> 
> Still doesn't work. Please try on top of this branch:
> https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=devel
> 
> This happens:
> $ git am --signoff
> ./v2_20211121_joey_gouly_pinctrl_apple_misc_fixes_from_post_commit_review.mbx
> Applying: pinctrl: apple: fix some formatting issues
> error: patch failed: drivers/pinctrl/pinctrl-apple-gpio.c:249
> error: drivers/pinctrl/pinctrl-apple-gpio.c: patch does not apply
> Patch failed at 0001 pinctrl: apple: fix some formatting issues
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> 
> Trying manually:
> $ patch -p1 < ./v2_20211121_joey_gouly_pinctrl_apple_misc_fixes_from_post_commit_review.mbx
> patching file drivers/pinctrl/pinctrl-apple-gpio.c
> Hunk #9 succeeded at 243 with fuzz 1.
> Hunk #10 FAILED at 269.
> Hunk #12 FAILED at 299.
> 2 out of 13 hunks FAILED -- saving rejects to file
> drivers/pinctrl/pinctrl-apple-gpio.c.rej
> 
> What am I doing wrong?
Sorry, I see the problem now. I thought you were appling the patches on top of:
  https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=for-next
Which has the commit by Sven (9b3b94e9eb14a "pinctrl: apple: Always return valid type in apple_gpio_irq_type"). 
I can rebase onto devel, but you will get a (trivial) conflict when merging devel and for-next.
If that's fine, let me know and I will send a v3 based on devel.
Thanks,
Joey
> 
> Yours,
> Linus Walleij
^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review
  2021-11-26 22:30     ` Joey Gouly
@ 2021-11-27  0:01       ` Linus Walleij
  0 siblings, 0 replies; 16+ messages in thread
From: Linus Walleij @ 2021-11-27  0:01 UTC (permalink / raw)
  To: Joey Gouly; +Cc: linux-gpio, Andy Shevchenko, Hector Martin, nd
On Fri, Nov 26, 2021 at 11:31 PM Joey Gouly <joey.gouly@arm.com> wrote:
> Sorry, I see the problem now. I thought you were appling the patches on top of:
>   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=for-next
No that is a mix-down branch for next. I apply the patches on devel...
> Which has the commit by Sven (9b3b94e9eb14a "pinctrl: apple: Always return valid type in apple_gpio_irq_type").
>
> I can rebase onto devel, but you will get a (trivial) conflict when merging devel and for-next.
> If that's fine, let me know and I will send a v3 based on devel.
No need, I just merged in v5.16-rc2 as this has the required patch,
then applied these fixes on top, now it works!
Yours,
Linus Walleij
^ permalink raw reply	[flat|nested] 16+ messages in thread
end of thread, other threads:[~2021-11-27  0:03 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-21 16:56 [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Joey Gouly
2021-11-21 16:56 ` [PATCH v2 01/11] pinctrl: apple: fix some formatting issues Joey Gouly
2021-11-21 16:56 ` [PATCH v2 02/11] pinctrl: apple: add missing comma Joey Gouly
2021-11-21 16:56 ` [PATCH v2 03/11] pinctrl: apple: use C style comment Joey Gouly
2021-11-21 16:56 ` [PATCH v2 04/11] pinctrl: apple: add missing bits.h header Joey Gouly
2021-11-21 16:56 ` [PATCH v2 05/11] pinctrl: apple: handle regmap_read errors Joey Gouly
2021-11-21 16:56 ` [PATCH v2 06/11] pinctrl: apple: make apple_gpio_get_direction more readable Joey Gouly
2021-11-21 16:56 ` [PATCH v2 07/11] pinctrl: apple: give error label a specific name Joey Gouly
2021-11-21 16:56 ` [PATCH v2 08/11] pinctrl: apple: remove gpio-controller check Joey Gouly
2021-11-21 16:56 ` [PATCH v2 09/11] pinctrl: apple: don't set gpio_chip.of_node Joey Gouly
2021-11-21 16:56 ` [PATCH v2 10/11] pinctrl: apple: use modulo rather than bitwise and Joey Gouly
2021-11-21 16:56 ` [PATCH v2 11/11] pinctrl: apple: return an error if pinmux is missing in the DT Joey Gouly
2021-11-22  0:15 ` [PATCH v2 00/11] pinctrl: apple: misc fixes from post-commit review Linus Walleij
2021-11-26  0:53   ` Linus Walleij
2021-11-26 22:30     ` Joey Gouly
2021-11-27  0:01       ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).