gpio: pxa: use devres for the clock struct
authorBartosz Golaszewski <brgl@bgdev.pl>
Mon, 15 Aug 2022 09:19:29 +0000 (11:19 +0200)
committerBartosz Golaszewski <brgl@bgdev.pl>
Fri, 19 Aug 2022 12:35:11 +0000 (14:35 +0200)
The clock is never released after probe(). Use devres to not leak
resources.

Reported-by: Hulk Robot <hulkci@huawei.com>
Reported-by: Yuan Can <yuancan@huawei.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-pxa.c

index c7fbfa3ae43b920eca9e6a9c0d6b3696e64ac851..1198ab0305d037bcd787c091c9e183e489406db2 100644 (file)
@@ -661,24 +661,17 @@ static int pxa_gpio_probe(struct platform_device *pdev)
        if (IS_ERR(gpio_reg_base))
                return PTR_ERR(gpio_reg_base);
 
-       clk = clk_get(&pdev->dev, NULL);
+       clk = devm_clk_get_enabled(&pdev->dev, NULL);
        if (IS_ERR(clk)) {
                dev_err(&pdev->dev, "Error %ld to get gpio clock\n",
                        PTR_ERR(clk));
                return PTR_ERR(clk);
        }
-       ret = clk_prepare_enable(clk);
-       if (ret) {
-               clk_put(clk);
-               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) {