All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
To: blogic@openwrt.org, linus.walleij@linaro.org,
	bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org
Cc: dev@kresin.me, linux-kernel@vger.kernel.org,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Subject: [PATCH 2/4] gpio: stp-xway: improve module clock error handling
Date: Wed,  3 Jul 2019 00:32:46 +0200	[thread overview]
Message-ID: <20190702223248.31934-3-martin.blumenstingl@googlemail.com> (raw)
In-Reply-To: <20190702223248.31934-1-martin.blumenstingl@googlemail.com>

Three module clock error handling improvements:
- use devm_clk_get() so the clock instance can be freed if
  devm_gpiochip_add_data() fails later on
- switch to clk_prepare_enable() so the driver is ready whenever the
  lantiq target switches to the common clock framework
- disable the clock again (using clk_disable_unprepare()) if
  devm_gpiochip_add_data()

All of these are virtually no-ops with the current lantiq target.
However, these will be relevant if we switch to the common clock
framework.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpio/gpio-stp-xway.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
index a3326255ce3c..b31e08f84681 100644
--- a/drivers/gpio/gpio-stp-xway.c
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -256,18 +256,23 @@ static int xway_stp_probe(struct platform_device *pdev)
 	if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL))
 		chip->edge = XWAY_STP_FALLING;
 
-	clk = clk_get(&pdev->dev, NULL);
+	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
 		return PTR_ERR(clk);
 	}
-	clk_enable(clk);
+
+	ret = clk_prepare_enable(clk);
+	if (ret)
+		return ret;
 
 	xway_stp_hw_init(chip);
 
 	ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(clk);
 		return ret;
+	}
 
 	dev_info(&pdev->dev, "Init done\n");
 
-- 
2.22.0


  parent reply	other threads:[~2019-07-03  1:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-02 22:32 [PATCH 0/4] gpio: stp-xway: small cleanups and improvements Martin Blumenstingl
2019-07-02 22:32 ` [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe() Martin Blumenstingl
2019-07-04  7:39   ` Linus Walleij
2019-07-02 22:32 ` Martin Blumenstingl [this message]
2019-07-04  7:40   ` [PATCH 2/4] gpio: stp-xway: improve module clock error handling Linus Walleij
2019-07-02 22:32 ` [PATCH 3/4] gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency Martin Blumenstingl
2019-07-04  7:41   ` Linus Walleij
2019-07-02 22:32 ` [PATCH 4/4] gpio: stp-xway: allow compile-testing Martin Blumenstingl
2019-07-04  7:44   ` Linus Walleij

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=20190702223248.31934-3-martin.blumenstingl@googlemail.com \
    --to=martin.blumenstingl@googlemail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=blogic@openwrt.org \
    --cc=dev@kresin.me \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.