Thread (7 messages) 7 messages, 6 authors, 2016-03-03

Re: [PATCH 3/3] hwrng: mxc-fsl - add support for Freescale RNGC

From: Uwe Kleine-König <hidden>
Date: 2016-02-29 21:38:50
Also in: linux-arm-kernel, linux-crypto

On Mon, Feb 29, 2016 at 06:16:50PM -0300, Fabio Estevam wrote:
On Mon, Feb 29, 2016 at 12:52 PM, Steffen Trumtrar
[off-list ref] wrote:
quoted
+       ret = clk_prepare_enable(rngc->clk);
+       if (ret)
+               return ret;
+
+       rngc->irq = platform_get_irq(pdev, 0);
+       if (!rngc->irq) {
+               dev_err(&pdev->dev, "FSL RNGC couldn't get irq\n");
+               clk_disable_unprepare(rngc->clk);
+
+               return ret;
You are returning the wrong error code here:

Better do like this:

       rngc->irq = platform_get_irq(pdev, 0);
       if (rngc->irq < 0) {
rngc->irq is unsigned, so this is never true.
               dev_err(&pdev->dev, "FSL RNGC couldn't get irq\n");
               clk_disable_unprepare(rngc->clk);
               return rngc->irq;
       }
So here comes my better approach:

	ret = platform_get_irq(pdev, 0);
	if (ret <= 0) {
		if (ret == 0)
			ret = -EINVAL;
		dev_err(&pdev->dev, "FSL RNGC couldn't get irq\n");
		clk_disable_unprepare(rngc->clk);

		return ret;
	}

	rngc->irq = ret;

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help