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

Fabio Estevam festevam at gmail.com
Mon Feb 29 15:54:19 PST 2016


On Mon, Feb 29, 2016 at 6:38 PM, Uwe Kleine-König
<u.kleine-koenig at pengutronix.de> wrote:
> On Mon, Feb 29, 2016 at 06:16:50PM -0300, Fabio Estevam wrote:
>> On Mon, Feb 29, 2016 at 12:52 PM, Steffen Trumtrar
>> <s.trumtrar at pengutronix.de> wrote:
>>
>> > +       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:

As irq is only used inside probe it can be removed from struct mxc_rngc.

Or maybe like this:

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



More information about the linux-arm-kernel mailing list