net: dsa: bcm_sf2: use devm_platform_ioremap_resource() to simplify code
authorYueHaibing <yuehaibing@huawei.com>
Thu, 1 Aug 2019 12:29:11 +0000 (20:29 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Aug 2019 17:10:34 +0000 (13:10 -0400)
Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/bcm_sf2.c

index 3811fdb..49f9943 100644 (file)
@@ -1041,7 +1041,6 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
        struct b53_device *dev;
        struct dsa_switch *ds;
        void __iomem **base;
-       struct resource *r;
        unsigned int i;
        u32 reg, rev;
        int ret;
@@ -1107,8 +1106,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 
        base = &priv->core;
        for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
-               r = platform_get_resource(pdev, IORESOURCE_MEM, i);
-               *base = devm_ioremap_resource(&pdev->dev, r);
+               *base = devm_platform_ioremap_resource(pdev, i);
                if (IS_ERR(*base)) {
                        pr_err("unable to find register: %s\n", reg_names[i]);
                        return PTR_ERR(*base);