All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] pata_imx: Use devm_ioremap_resource() to simplify code
@ 2014-02-15 12:50 Fabio Estevam
  2014-02-15 12:50 ` [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
  2014-02-15 12:50 ` [PATCH 3/3] pata_imx: Check the return value from clk_prepare_enable() Fabio Estevam
  0 siblings, 2 replies; 6+ messages in thread
From: Fabio Estevam @ 2014-02-15 12:50 UTC (permalink / raw)
  To: tj; +Cc: linux-ide, Fabio Estevam

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

Using devm_ioremap_resource() can lead to code simplication, as we don't need
to explicitily check for error returned by platform_get_resource().

Also, no need to print an error message when devm_ioremap_resource() fails,
as the OOM code code will shout loudly on such condition.

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

diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 97417d5..50e2cf2 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -99,10 +99,6 @@ static int pata_imx_probe(struct platform_device *pdev)
 	struct resource *io_res;
 	int ret;
 
-	io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (io_res == NULL)
-		return -EINVAL;
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0)
 		return -EINVAL;
@@ -133,10 +129,9 @@ static int pata_imx_probe(struct platform_device *pdev)
 	ap->pio_mask = ATA_PIO0;
 	ap->flags |= ATA_FLAG_SLAVE_POSS;
 
-	priv->host_regs = devm_ioremap(&pdev->dev, io_res->start,
-		resource_size(io_res));
+	io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	priv->host_regs = devm_ioremap_resource(&pdev->dev, io_res);
 	if (!priv->host_regs) {
-		dev_err(&pdev->dev, "failed to map IO/CTL base\n");
 		ret = -EBUSY;
 		goto err;
 	}
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure
  2014-02-15 12:50 [PATCH 1/3] pata_imx: Use devm_ioremap_resource() to simplify code Fabio Estevam
@ 2014-02-15 12:50 ` Fabio Estevam
  2014-02-15 20:38   ` Sergei Shtylyov
  2014-02-15 12:50 ` [PATCH 3/3] pata_imx: Check the return value from clk_prepare_enable() Fabio Estevam
  1 sibling, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2014-02-15 12:50 UTC (permalink / raw)
  To: tj; +Cc: linux-ide, Fabio Estevam

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;
 
 	priv = devm_kzalloc(&pdev->dev,
 				sizeof(struct pata_imx_priv), GFP_KERNEL);
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] pata_imx: Check the return value from clk_prepare_enable()
  2014-02-15 12:50 [PATCH 1/3] pata_imx: Use devm_ioremap_resource() to simplify code Fabio Estevam
  2014-02-15 12:50 ` [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
@ 2014-02-15 12:50 ` Fabio Estevam
  1 sibling, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2014-02-15 12:50 UTC (permalink / raw)
  To: tj; +Cc: linux-ide, Fabio Estevam

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

clk_prepare_enable() may fail, so let's check its return value and propagate it
in the case of error.

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

diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 1af71b7..7b669f6 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -114,7 +114,9 @@ static int pata_imx_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->clk);
 	}
 
-	clk_prepare_enable(priv->clk);
+	ret = clk_prepare_enable(priv->clk);
+	if (ret)
+		return ret;
 
 	host = ata_host_alloc(&pdev->dev, 1);
 	if (!host) {
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure
  2014-02-15 12:50 ` [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
@ 2014-02-15 20:38   ` Sergei Shtylyov
  2014-02-17 19:48     ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2014-02-15 20:38 UTC (permalink / raw)
  To: Fabio Estevam, tj; +Cc: linux-ide, Fabio Estevam

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure
  2014-02-15 20:38   ` Sergei Shtylyov
@ 2014-02-17 19:48     ` Fabio Estevam
  2014-02-17 22:45       ` Sergei Shtylyov
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2014-02-17 19:48 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Tejun Heo, linux-ide, Fabio Estevam

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure
  2014-02-17 19:48     ` Fabio Estevam
@ 2014-02-17 22:45       ` Sergei Shtylyov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2014-02-17 22:45 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Tejun Heo, linux-ide, Fabio Estevam

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-02-17 21:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-15 12:50 [PATCH 1/3] pata_imx: Use devm_ioremap_resource() to simplify code Fabio Estevam
2014-02-15 12:50 ` [PATCH 2/3] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
2014-02-15 20:38   ` Sergei Shtylyov
2014-02-17 19:48     ` Fabio Estevam
2014-02-17 22:45       ` Sergei Shtylyov
2014-02-15 12:50 ` [PATCH 3/3] pata_imx: Check the return value from clk_prepare_enable() Fabio Estevam

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.