lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190702223248.31934-3-martin.blumenstingl@googlemail.com>
Date:   Wed,  3 Jul 2019 00:32:46 +0200
From:   Martin Blumenstingl <martin.blumenstingl@...glemail.com>
To:     blogic@...nwrt.org, linus.walleij@...aro.org,
        bgolaszewski@...libre.com, linux-gpio@...r.kernel.org
Cc:     dev@...sin.me, linux-kernel@...r.kernel.org,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Subject: [PATCH 2/4] gpio: stp-xway: improve module clock error handling

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@...glemail.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ