]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: lpc18xx: Use helper function devm_clk_get_enabled()
authorZhang Zekun <zhangzekun11@huawei.com>
Wed, 4 Sep 2024 09:23:09 +0000 (17:23 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thu, 5 Sep 2024 13:04:44 +0000 (15:04 +0200)
devm_clk_get() and clk_prepare_enable() can be replaced by helper
function devm_clk_get_enabled(). Let's use devm_clk_get_enabled() to
simplify code and avoid calling clk_disable_unprepare().

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240904092311.9544-3-zhangzekun11@huawei.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-lpc18xx.c

index 5c6bb57a8c99b951bb084a79b455b2630876c4ef..e7c0ef6e54fabc272fc957f3e833d37b5e435d46 100644 (file)
@@ -47,7 +47,6 @@ struct lpc18xx_gpio_pin_ic {
 struct lpc18xx_gpio_chip {
        struct gpio_chip gpio;
        void __iomem *base;
-       struct clk *clk;
        struct lpc18xx_gpio_pin_ic *pin_ic;
        spinlock_t lock;
 };
@@ -328,6 +327,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct lpc18xx_gpio_chip *gc;
        int index, ret;
+       struct clk *clk;
 
        gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
        if (!gc)
@@ -352,16 +352,10 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
        if (IS_ERR(gc->base))
                return PTR_ERR(gc->base);
 
-       gc->clk = devm_clk_get(dev, NULL);
-       if (IS_ERR(gc->clk)) {
+       clk = devm_clk_get_enabled(dev, NULL);
+       if (IS_ERR(clk)) {
                dev_err(dev, "input clock not found\n");
-               return PTR_ERR(gc->clk);
-       }
-
-       ret = clk_prepare_enable(gc->clk);
-       if (ret) {
-               dev_err(dev, "unable to enable clock\n");
-               return ret;
+               return PTR_ERR(clk);
        }
 
        spin_lock_init(&gc->lock);
@@ -369,11 +363,8 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
        gc->gpio.parent = dev;
 
        ret = devm_gpiochip_add_data(dev, &gc->gpio, gc);
-       if (ret) {
-               dev_err(dev, "failed to add gpio chip\n");
-               clk_disable_unprepare(gc->clk);
-               return ret;
-       }
+       if (ret)
+               return dev_err_probe(dev, ret, "failed to add gpio chip\n");
 
        /* On error GPIO pin interrupt controller just won't be registered */
        lpc18xx_gpio_pin_ic_probe(gc);
@@ -387,8 +378,6 @@ static void lpc18xx_gpio_remove(struct platform_device *pdev)
 
        if (gc->pin_ic)
                irq_domain_remove(gc->pin_ic->domain);
-
-       clk_disable_unprepare(gc->clk);
 }
 
 static const struct of_device_id lpc18xx_gpio_match[] = {