diff mbox

[2/3] pata_imx: Propagate the real error code on platform_get_irq() failure

Message ID 1392468635-13373-2-git-send-email-festevam@gmail.com
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

Fabio Estevam Feb. 15, 2014, 12:50 p.m. UTC
From: Fabio Estevam <fabio.estevam@freescale.com>

No need to return a 'fake' return value on platform_get_irq() failure.

Just return the error code itself instead.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/ata/pata_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sergei Shtylyov Feb. 15, 2014, 8:38 p.m. UTC | #1
Hello.

On 15-02-2014 16:50, Fabio Estevam wrote:

> From: Fabio Estevam <fabio.estevam@freescale.com>

> No need to return a 'fake' return value on platform_get_irq() failure.

> Just return the error code itself instead.

> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>   drivers/ata/pata_imx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
> index 50e2cf2..1af71b7 100644
> --- a/drivers/ata/pata_imx.c
> +++ b/drivers/ata/pata_imx.c
> @@ -101,7 +101,7 @@ static int pata_imx_probe(struct platform_device *pdev)
>
>   	irq = platform_get_irq(pdev, 0);
>   	if (irq <= 0)
> -		return -EINVAL;
> +		return irq;

    If returned IRQ is 0 (unused), you'll return 0, indicating probe success 
while actually it failed. We need somewhat more complicated code here.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fabio Estevam Feb. 17, 2014, 7:48 p.m. UTC | #2
On Sat, Feb 15, 2014 at 6:38 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:

>>         irq = platform_get_irq(pdev, 0);
>>         if (irq <= 0)
>> -               return -EINVAL;
>> +               return irq;
>
>
>    If returned IRQ is 0 (unused), you'll return 0, indicating probe success
> while actually it failed. We need somewhat more complicated code here.

Right, then we should do this instead:

         irq = platform_get_irq(pdev, 0);
         if (irq < 0)
               return irq;

Regards,

Fabio Estevam
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov Feb. 17, 2014, 10:45 p.m. UTC | #3
Hello.

On 02/17/2014 10:48 PM, Fabio Estevam wrote:

>>>          irq = platform_get_irq(pdev, 0);
>>>          if (irq <= 0)
>>> -               return -EINVAL;
>>> +               return irq;

>>     If returned IRQ is 0 (unused), you'll return 0, indicating probe success
>> while actually it failed. We need somewhat more complicated code here.

> Right, then we should do this instead:

>           irq = platform_get_irq(pdev, 0);
>           if (irq < 0)
>                 return irq;

    Yes, but don't forget that 0 is not considered a valid IRQ either. Ask 
Linus why. ;-)

> Regards,

> Fabio Estevam

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 50e2cf2..1af71b7 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -101,7 +101,7 @@  static int pata_imx_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0)
-		return -EINVAL;
+		return irq;
 
 	priv = devm_kzalloc(&pdev->dev,
 				sizeof(struct pata_imx_priv), GFP_KERNEL);