pata_imx: Use devm_ioremap_resource() to simplify code
Subsystems (2)
Fabio Estevam
reviewerPATCH v2 1/2 pata_imx: Use devm_ioremap_resource() to simplify code
From: Fabio Estevam <[email protected]>
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.
---
Changes since v1:
- None
drivers/ata/pata_imx.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/ata/pata_imx.c +2 -7
@@ -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; }
Signature · 1 line
1.8.1.2
Fabio Estevam
reviewerPATCH v2 2/2 pata_imx: Propagate the real error code on platform_get_irq() failure
From: Fabio Estevam <[email protected]>
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.
---
Changes since v1:
- Only return error on negative values
drivers/ata/pata_imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/pata_imx.c +2 -2
@@ -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 );
Signature · 1 line
1.8.1.2
Quoted 7 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Using
devm_ioremap_resource()can lead to code simplication, as we don't need to explicitily check for error returned byplatform_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
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Using
devm_ioremap_resource()can lead to code simplication, as we don't need to explicitily check for error returned byplatform_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 <[email protected]>
Applied 1-2 to libata/for-3.15.
Thanks.
Signature · 1 line
tejun