Skip to contentSkip to conversation

gpio: pxa: schedule a devm action for the clock struct

PATCH In review Bartosz Golaszewski 2 participants 5 messages Jul 5, 2022 – Jul 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: pxa: schedule a devm action for the clock struct

The clock is never released after probe(). Schedule devm actions for putting and disabling the clock.

---
 drivers/gpio/gpio-pxa.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/gpio/gpio-pxa.c +26 -6
index c7fbfa3ae43b..73a83b493b2e 100644
@@ -610,6 +610,20 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev,
 #define pxa_gpio_probe_dt(pdev, pchip)		(-1)
 #endif
 
+static void pxa_gpio_clk_put(void *data)
+{
+	struct clk *clk = data;
+
+	clk_put(clk);
+}
+
+static void pxa_gpio_clk_disable_unprepare(void *data)
+{
+	struct clk *clk = data;
+
+	clk_disable_unprepare(clk);
+}
+
 static int pxa_gpio_probe(struct platform_device *pdev)
 {
 	struct pxa_gpio_chip *pchip;
@@ -667,18 +681,24 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 			PTR_ERR(clk));
 		return PTR_ERR(clk);
 	}
+
+	ret = devm_add_action_or_reset(&pdev->dev, pxa_gpio_clk_put, clk);
+	if (ret)
+		return ret;
+
 	ret = clk_prepare_enable(clk);
-	if (ret) {
-		clk_put(clk);
+	if (ret)
+		return ret;
+
+	ret = devm_add_action_or_reset(&pdev->dev,
+				       pxa_gpio_clk_disable_unprepare, clk);
+	if (ret)
 		return ret;
-	}
 
 	/* Initialize GPIO chips */
 	ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, gpio_reg_base);
-	if (ret) {
-		clk_put(clk);
+	if (ret)
 		return ret;
-	}
 
 	/* clear all GPIO edge detects */
 	for_each_gpio_bank(gpio, c, pchip) {
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Bartosz Golaszewski

The clock is never released after probe(). Schedule devm actions for putting and disabling the clock.

...

Quoted 1 line

Me puzzled.

...

drivers/gpio/gpio-pxa.c static int pxa_gpio_probe(struct platform_device *pdev) · line 696

Quoted 12 lines
drivers/gpio/gpio-pxa.c +10 -0
+       ret = devm_add_action_or_reset(&pdev->dev, pxa_gpio_clk_put, clk);
+       if (ret)
+               return ret;
+
        ret = clk_prepare_enable(clk);
+       if (ret)
+               return ret;
+
+       ret = devm_add_action_or_reset(&pdev->dev,
+                                      pxa_gpio_clk_disable_unprepare, clk);
+       if (ret)
                return ret;

Can we use recently introduced clk APIs for that? Maybe Stephen has an immutable branch you may reuse?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw

On Wed, Jul 6, 2022 at 1:49 PM Andy Shevchenko
<[email protected]> wrote:
s>

Quoted 11 lines · Bartosz Golaszewski
Quoted 3 lines

The clock is never released after probe(). Schedule devm actions for putting and disabling the clock.

...

Quoted 1 line

Me puzzled.

Yuan Can sent the following patch:
https://patchwork.ozlabs.org/project/linux-gpio/patch/[email protected]/

I responded that it was not complete and sent this instead.

Quoted 18 lines

...

drivers/gpio/gpio-pxa.c static int pxa_gpio_probe(struct platform_device *pdev) · line 696

Quoted 12 lines
drivers/gpio/gpio-pxa.c +10 -0
+       ret = devm_add_action_or_reset(&pdev->dev, pxa_gpio_clk_put, clk);
+       if (ret)
+               return ret;
+
        ret = clk_prepare_enable(clk);
+       if (ret)
+               return ret;
+
+       ret = devm_add_action_or_reset(&pdev->dev,
+                                      pxa_gpio_clk_disable_unprepare, clk);
+       if (ret)
                return ret;

Can we use recently introduced clk APIs for that? Maybe Stephen has an immutable branch you may reuse?

Sure, sounds good! Stephen, would you mind providing me with a branch for that?

Bart

Quoted 4 lines

--
With Best Regards,
Andy Shevchenko

#3 lore raw
Quoted 3 lines · Bartosz Golaszewski
Quoted 1 line · Andy Shevchenko

On Tue, Jul 5, 2022 at 7:29 PM Bartosz Golaszewski <[email protected]> wrote:

...

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Me puzzled.

Yuan Can sent the following patch:
https://patchwork.ozlabs.org/project/linux-gpio/patch/[email protected]/

I responded that it was not complete and sent this instead.

I understand that, I am puzzled with Reported-by: followed by SoB. What is this format? Is it something new and documented?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 12 lines · Andy Shevchenko
Quoted 3 lines · Bartosz Golaszewski
Quoted 1 line · Andy Shevchenko

On Tue, Jul 5, 2022 at 7:29 PM Bartosz Golaszewski <[email protected]> wrote:

...

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Me puzzled.

Quoted 8 lines
Quoted 4 lines

Yuan Can sent the following patch:
https://patchwork.ozlabs.org/project/linux-gpio/patch/[email protected]/

I responded that it was not complete and sent this instead.

I understand that, I am puzzled with Reported-by: followed by SoB. What is this format? Is it something new and documented?

Ah! No, it's just my brain on not enough coffee I suppose. Thanks, I'll fix it.

Bart