Replace a call to deprecated devm_request_and_ioremap by devm_ioremap_resource.
also remove tests on 'r' since devm_ioremap_resource() checks for it
in a better way.
Found with coccicheck and this semantic patch:
scripts/coccinelle/api/devm_ioremap_resource.cocci
Signed-off-by: Laurent Navet <[email protected]>
---
drivers/net/ethernet/freescale/fec_main.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index aff0310..0afc7ff 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1843,8 +1843,6 @@ fec_probe(struct platform_device *pdev)
pdev->id_entry = of_id->data;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!r)
- return -ENXIO;
/* Init network device */
ndev = alloc_etherdev(sizeof(struct fec_enet_private));
@@ -1861,17 +1859,16 @@ fec_probe(struct platform_device *pdev)
(pdev->id_entry->driver_data & FEC_QUIRK_HAS_GBIT))
fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG;
- fep->hwp = devm_request_and_ioremap(&pdev->dev, r);
+ fep->hwp = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(fep->hwp)) {
+ ret = PTR_ERR(fep->hwp);
+ goto failed_ioremap;
+ }
fep->pdev = pdev;
fep->dev_id = dev_id++;
fep->bufdesc_ex = 0;
- if (!fep->hwp) {
- ret = -ENOMEM;
- goto failed_ioremap;
- }
-
platform_set_drvdata(pdev, ndev);
ret = of_get_phy_mode(pdev->dev.of_node);
--
1.7.10.4
2013/5/14 Laurent Navet <[email protected]>:
> Replace a call to deprecated devm_request_and_ioremap by devm_ioremap_resource.
> also remove tests on 'r' since devm_ioremap_resource() checks for it
> in a better way.
>
> Found with coccicheck and this semantic patch:
> scripts/coccinelle/api/devm_ioremap_resource.cocci
>
> Signed-off-by: Laurent Navet <[email protected]>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index aff0310..0afc7ff 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1843,8 +1843,6 @@ fec_probe(struct platform_device *pdev)
> pdev->id_entry = of_id->data;
>
> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!r)
> - return -ENXIO;
>
why remove this check?
> /* Init network device */
> ndev = alloc_etherdev(sizeof(struct fec_enet_private));
> @@ -1861,17 +1859,16 @@ fec_probe(struct platform_device *pdev)
> (pdev->id_entry->driver_data & FEC_QUIRK_HAS_GBIT))
> fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG;
>
> - fep->hwp = devm_request_and_ioremap(&pdev->dev, r);
> + fep->hwp = devm_ioremap_resource(&pdev->dev, r);
> + if (IS_ERR(fep->hwp)) {
> + ret = PTR_ERR(fep->hwp);
> + goto failed_ioremap;
> + }
> fep->pdev = pdev;
> fep->dev_id = dev_id++;
>
> fep->bufdesc_ex = 0;
>
> - if (!fep->hwp) {
> - ret = -ENOMEM;
> - goto failed_ioremap;
> - }
> -
> platform_set_drvdata(pdev, ndev);
>
> ret = of_get_phy_mode(pdev->dev.of_node);
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> --- a/drivers/net/ethernet/freescale/fec_main.c
>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>> @@ -1843,8 +1843,6 @@ fec_probe(struct platform_device *pdev)
>> pdev->id_entry = of_id->data;
>>
>> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> - if (!r)
>> - return -ENXIO;
>>
>
> why remove this check?
it's already checked in devm_ioremap_resource in a better way,
void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
{
...
if (!res || resource_type(res) != IORESOURCE_MEM) {
dev_err(dev, "invalid resource\n");
return ERR_PTR(-EINVAL);
}
...
Laurent.
2013/5/14 Laurent Navet <[email protected]>:
> struct resource *res)
> {
> ...
> if (!res || resource_type(res) != IORESOURCE_MEM) {
> dev_err(dev, "invalid resource\n");
> return ERR_PTR(-EINVAL);
Okay, thanks.
Acked
Hi Laurent,
On Mon, May 13, 2013 at 4:37 PM, Laurent Navet <[email protected]> wrote:
> Replace a call to deprecated devm_request_and_ioremap by devm_ioremap_resource.
> also remove tests on 'r' since devm_ioremap_resource() checks for it
> in a better way.
>
> Found with coccicheck and this semantic patch:
> scripts/coccinelle/api/devm_ioremap_resource.cocci
>
> Signed-off-by: Laurent Navet <[email protected]>
I was about to do the same change, then I saw your patch :-)
Looks good:
Tested-by: Fabio Estevam <[email protected]>