[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220705171835.4923-1-brgl@bgdev.pl>
Date: Tue, 5 Jul 2022 19:18:35 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Robert Jarzmik <robert.jarzmik@...e.fr>,
Linus Walleij <linus.walleij@...aro.org>
Cc: linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
Bartosz Golaszewski <brgl@...ev.pl>,
Hulk Robot <hulkci@...wei.com>,
"Signed-off-by : Yuan Can" <yuancan@...wei.com>
Subject: [PATCH] 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.
Reported-by: Hulk Robot <hulkci@...wei.com>
Reported-by: Signed-off-by: Yuan Can <yuancan@...wei.com>
Signed-off-by: Bartosz Golaszewski <brgl@...ev.pl>
---
drivers/gpio/gpio-pxa.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index c7fbfa3ae43b..73a83b493b2e 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -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) {
--
2.34.1
Powered by blists - more mailing lists