Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net:stmmac: convert driver to use devm_request_and_ioremap.

This patch moves calls to ioremap and request_mem_region to
devm_request_and_ioremap call.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Srinivas Kandagatla and committed by
David S. Miller
3f8bdecd d56631a6

+8 -32
+8 -32
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 78 78 { 79 79 int ret = 0; 80 80 struct resource *res; 81 + struct device *dev = &pdev->dev; 81 82 void __iomem *addr = NULL; 82 83 struct stmmac_priv *priv = NULL; 83 84 struct plat_stmmacenet_data *plat_dat = NULL; ··· 88 87 if (!res) 89 88 return -ENODEV; 90 89 91 - if (!request_mem_region(res->start, resource_size(res), pdev->name)) { 92 - pr_err("%s: ERROR: memory allocation failed" 93 - "cannot get the I/O addr 0x%x\n", 94 - __func__, (unsigned int)res->start); 95 - return -EBUSY; 96 - } 97 - 98 - addr = ioremap(res->start, resource_size(res)); 90 + addr = devm_request_and_ioremap(dev, res); 99 91 if (!addr) { 100 92 pr_err("%s: ERROR: memory mapping failed", __func__); 101 - ret = -ENOMEM; 102 - goto out_release_region; 93 + return -ENOMEM; 103 94 } 104 95 105 96 if (pdev->dev.of_node) { ··· 100 107 GFP_KERNEL); 101 108 if (!plat_dat) { 102 109 pr_err("%s: ERROR: no memory", __func__); 103 - ret = -ENOMEM; 104 - goto out_unmap; 110 + return -ENOMEM; 105 111 } 106 112 107 113 ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); 108 114 if (ret) { 109 115 pr_err("%s: main dt probe failed", __func__); 110 - goto out_unmap; 116 + return ret; 111 117 } 112 118 } else { 113 119 plat_dat = pdev->dev.platform_data; ··· 116 124 if (plat_dat->init) { 117 125 ret = plat_dat->init(pdev); 118 126 if (unlikely(ret)) 119 - goto out_unmap; 127 + return ret; 120 128 } 121 129 122 130 priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr); 123 131 if (!priv) { 124 132 pr_err("%s: main driver probe failed", __func__); 125 - goto out_unmap; 133 + return -ENODEV; 126 134 } 127 135 128 136 /* Get MAC address if available (DT) */ ··· 134 142 if (priv->dev->irq == -ENXIO) { 135 143 pr_err("%s: ERROR: MAC IRQ configuration " 136 144 "information not found\n", __func__); 137 - ret = -ENXIO; 138 - goto out_unmap; 145 + return -ENXIO; 139 146 } 140 147 141 148 /* ··· 156 165 pr_debug("STMMAC platform driver registration completed"); 157 166 158 167 return 0; 159 - 160 - out_unmap: 161 - iounmap(addr); 162 - platform_set_drvdata(pdev, NULL); 163 - 164 - out_release_region: 165 - release_mem_region(res->start, resource_size(res)); 166 - 167 - return ret; 168 168 } 169 169 170 170 /** ··· 168 186 { 169 187 struct net_device *ndev = platform_get_drvdata(pdev); 170 188 struct stmmac_priv *priv = netdev_priv(ndev); 171 - void __iomem *addr = priv->ioaddr; 172 - struct resource *res; 173 189 int ret = stmmac_dvr_remove(ndev); 174 190 175 191 if (priv->plat->exit) 176 192 priv->plat->exit(pdev); 177 193 178 194 platform_set_drvdata(pdev, NULL); 179 - 180 - iounmap(addr); 181 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 182 - release_mem_region(res->start, resource_size(res)); 183 195 184 196 return ret; 185 197 }