Commit 464a5728 authored by Cai Huoqing's avatar Cai Huoqing Committed by David S. Miller

net/mlxbf_gige: Make use of devm_platform_ioremap_resourcexxx()

Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately

Use the devm_platform_ioremap_resource() helper instead of
calling platform_get_resource() and devm_ioremap_resource()
separately
Signed-off-by: default avatarCai Huoqing <caihuoqing@baidu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 672a1c39
...@@ -227,7 +227,6 @@ static int liteeth_probe(struct platform_device *pdev) ...@@ -227,7 +227,6 @@ static int liteeth_probe(struct platform_device *pdev)
{ {
struct net_device *netdev; struct net_device *netdev;
void __iomem *buf_base; void __iomem *buf_base;
struct resource *res;
struct liteeth *priv; struct liteeth *priv;
int irq, err; int irq, err;
...@@ -249,13 +248,11 @@ static int liteeth_probe(struct platform_device *pdev) ...@@ -249,13 +248,11 @@ static int liteeth_probe(struct platform_device *pdev)
} }
netdev->irq = irq; netdev->irq = irq;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac"); priv->base = devm_platform_ioremap_resource_byname(pdev, "mac");
priv->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->base)) if (IS_ERR(priv->base))
return PTR_ERR(priv->base); return PTR_ERR(priv->base);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "buffer"); buf_base = devm_platform_ioremap_resource_byname(pdev, "buffer");
buf_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(buf_base)) if (IS_ERR(buf_base))
return PTR_ERR(buf_base); return PTR_ERR(buf_base);
......
...@@ -269,9 +269,6 @@ static int mlxbf_gige_probe(struct platform_device *pdev) ...@@ -269,9 +269,6 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
{ {
struct phy_device *phydev; struct phy_device *phydev;
struct net_device *netdev; struct net_device *netdev;
struct resource *mac_res;
struct resource *llu_res;
struct resource *plu_res;
struct mlxbf_gige *priv; struct mlxbf_gige *priv;
void __iomem *llu_base; void __iomem *llu_base;
void __iomem *plu_base; void __iomem *plu_base;
...@@ -280,27 +277,15 @@ static int mlxbf_gige_probe(struct platform_device *pdev) ...@@ -280,27 +277,15 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
int addr; int addr;
int err; int err;
mac_res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_MAC); base = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MAC);
if (!mac_res)
return -ENXIO;
base = devm_ioremap_resource(&pdev->dev, mac_res);
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
llu_res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_LLU); llu_base = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_LLU);
if (!llu_res)
return -ENXIO;
llu_base = devm_ioremap_resource(&pdev->dev, llu_res);
if (IS_ERR(llu_base)) if (IS_ERR(llu_base))
return PTR_ERR(llu_base); return PTR_ERR(llu_base);
plu_res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_PLU); plu_base = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_PLU);
if (!plu_res)
return -ENXIO;
plu_base = devm_ioremap_resource(&pdev->dev, plu_res);
if (IS_ERR(plu_base)) if (IS_ERR(plu_base))
return PTR_ERR(plu_base); return PTR_ERR(plu_base);
......
...@@ -145,14 +145,9 @@ static int mlxbf_gige_mdio_write(struct mii_bus *bus, int phy_add, ...@@ -145,14 +145,9 @@ static int mlxbf_gige_mdio_write(struct mii_bus *bus, int phy_add,
int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv) int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *res;
int ret; int ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_MDIO9); priv->mdio_io = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MDIO9);
if (!res)
return -ENODEV;
priv->mdio_io = devm_ioremap_resource(dev, res);
if (IS_ERR(priv->mdio_io)) if (IS_ERR(priv->mdio_io))
return PTR_ERR(priv->mdio_io); return PTR_ERR(priv->mdio_io);
......
...@@ -1229,7 +1229,6 @@ static int nixge_of_get_resources(struct platform_device *pdev) ...@@ -1229,7 +1229,6 @@ static int nixge_of_get_resources(struct platform_device *pdev)
{ {
const struct of_device_id *of_id; const struct of_device_id *of_id;
enum nixge_version version; enum nixge_version version;
struct resource *ctrlres;
struct net_device *ndev; struct net_device *ndev;
struct nixge_priv *priv; struct nixge_priv *priv;
...@@ -1248,13 +1247,10 @@ static int nixge_of_get_resources(struct platform_device *pdev) ...@@ -1248,13 +1247,10 @@ static int nixge_of_get_resources(struct platform_device *pdev)
netdev_err(ndev, "failed to map dma regs\n"); netdev_err(ndev, "failed to map dma regs\n");
return PTR_ERR(priv->dma_regs); return PTR_ERR(priv->dma_regs);
} }
if (version <= NIXGE_V2) { if (version <= NIXGE_V2)
priv->ctrl_regs = priv->dma_regs + NIXGE_REG_CTRL_OFFSET; priv->ctrl_regs = priv->dma_regs + NIXGE_REG_CTRL_OFFSET;
} else { else
ctrlres = platform_get_resource_byname(pdev, IORESOURCE_MEM, priv->ctrl_regs = devm_platform_ioremap_resource_byname(pdev, "ctrl");
"ctrl");
priv->ctrl_regs = devm_ioremap_resource(&pdev->dev, ctrlres);
}
if (IS_ERR(priv->ctrl_regs)) { if (IS_ERR(priv->ctrl_regs)) {
netdev_err(ndev, "failed to map ctrl regs\n"); netdev_err(ndev, "failed to map ctrl regs\n");
return PTR_ERR(priv->ctrl_regs); return PTR_ERR(priv->ctrl_regs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment