* [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code
@ 2014-02-17 22:05 Fabio Estevam
2014-02-17 22:05 ` [PATCH v2 2/2] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fabio Estevam @ 2014-02-17 22:05 UTC (permalink / raw)
To: tj; +Cc: linux-ide, sergei.shtylyov, 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>
---
Changes since v1:
- None
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 7e69797..3668e78 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;
@@ -135,10 +131,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] 4+ messages in thread
* [PATCH v2 2/2] pata_imx: Propagate the real error code on platform_get_irq() failure
2014-02-17 22:05 [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code Fabio Estevam
@ 2014-02-17 22:05 ` Fabio Estevam
2014-02-17 23:12 ` [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code Sergei Shtylyov
2014-02-18 22:41 ` Tejun Heo
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2014-02-17 22:05 UTC (permalink / raw)
To: tj; +Cc: linux-ide, sergei.shtylyov, 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.
Also, change the error condition to irq < 0, so that only negative values
are treated as errors.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Only return error on negative values
drivers/ata/pata_imx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 3668e78..fa8e69c 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -100,8 +100,8 @@ static int pata_imx_probe(struct platform_device *pdev)
int ret;
irq = platform_get_irq(pdev, 0);
- if (irq <= 0)
- return -EINVAL;
+ if (irq < 0)
+ return irq;
priv = devm_kzalloc(&pdev->dev,
sizeof(struct pata_imx_priv), GFP_KERNEL);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code
2014-02-17 22:05 [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code Fabio Estevam
2014-02-17 22:05 ` [PATCH v2 2/2] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
@ 2014-02-17 23:12 ` Sergei Shtylyov
2014-02-18 22:41 ` Tejun Heo
2 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2014-02-17 23:12 UTC (permalink / raw)
To: Fabio Estevam, tj; +Cc: linux-ide, Fabio Estevam
On 02/18/2014 01:05 AM, Fabio Estevam wrote:
> 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.
Not only OOM code, the function itself will cuss loudly too. :-)
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code
2014-02-17 22:05 [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code Fabio Estevam
2014-02-17 22:05 ` [PATCH v2 2/2] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
2014-02-17 23:12 ` [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code Sergei Shtylyov
@ 2014-02-18 22:41 ` Tejun Heo
2 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2014-02-18 22:41 UTC (permalink / raw)
To: Fabio Estevam; +Cc: linux-ide, sergei.shtylyov, Fabio Estevam
On Mon, Feb 17, 2014 at 07:05:56PM -0300, Fabio Estevam wrote:
> 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>
Applied 1-2 to libata/for-3.15.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-18 22:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17 22:05 [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code Fabio Estevam
2014-02-17 22:05 ` [PATCH v2 2/2] pata_imx: Propagate the real error code on platform_get_irq() failure Fabio Estevam
2014-02-17 23:12 ` [PATCH v2 1/2] pata_imx: Use devm_ioremap_resource() to simplify code Sergei Shtylyov
2014-02-18 22:41 ` Tejun Heo
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.