From: Zhang Zekun <zhangzekun11@huawei.com>
To: <linus.walleij@linaro.org>, <brgl@bgdev.pl>, <vz@mleia.com>,
<linux-gpio@vger.kernel.org>
Cc: <zhangzekun11@huawei.com>
Subject: [PATCH 2/4] gpio: lpc18xx: Use helper function devm_clk_get_enabled()
Date: Tue, 3 Sep 2024 16:06:25 +0800 [thread overview]
Message-ID: <20240903080627.53652-3-zhangzekun11@huawei.com> (raw)
In-Reply-To: <20240903080627.53652-1-zhangzekun11@huawei.com>
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>
---
drivers/gpio/gpio-lpc18xx.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c
index 5c6bb57a8c99..e7c0ef6e54fa 100644
--- a/drivers/gpio/gpio-lpc18xx.c
+++ b/drivers/gpio/gpio-lpc18xx.c
@@ -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[] = {
--
2.17.1
next prev parent reply other threads:[~2024-09-03 8:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 8:06 [PATCH 0/4] Simplify code with helper function devm_clk_get*() Zhang Zekun
2024-09-03 8:06 ` [PATCH 1/4] gpio: cadence: Use helper function devm_clk_get_enabled() Zhang Zekun
2024-09-03 8:06 ` Zhang Zekun [this message]
2024-09-03 8:06 ` [PATCH 3/4] gpio: mb86s7x: " Zhang Zekun
2024-09-03 8:06 ` [PATCH 4/4] gpio: xilinx: " Zhang Zekun
2024-09-04 8:01 ` [PATCH 0/4] Simplify code with helper function devm_clk_get*() Bartosz Golaszewski
2024-09-04 8:44 ` zhangzekun (A)
2024-09-04 9:05 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240903080627.53652-3-zhangzekun11@huawei.com \
--to=zhangzekun11@huawei.com \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=vz@mleia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).