aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-01-15 15:09:46 -0500
committerDavid S. Miller <davem@davemloft.net>2018-01-15 15:09:46 -0500
commit5138eb9b2a744f780194b292bffd8638c7a6d423 (patch)
treee70392bc439e7e364300a69972613636900e4c68
parentd9631c7a5decd657265627cec2d27dd8ed972985 (diff)
parent9662ec19229c89825acac1d62a9d78fb89f8dda5 (diff)
Merge branch 'sh_eth-simplify-TSU-initialization'
Sergei Shtylyov says: ==================== sh_eth: simplify TSU initialization Here's a set of 2 patches against DaveM's 'net-next.git' repo. With those, I'm somewhat simplifying the TSU init code in the driver probe() method... ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 7aa1c12750b3..a0fe05968348 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3125,7 +3125,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3125 const struct platform_device_id *id = platform_get_device_id(pdev); 3125 const struct platform_device_id *id = platform_get_device_id(pdev);
3126 struct sh_eth_private *mdp; 3126 struct sh_eth_private *mdp;
3127 struct net_device *ndev; 3127 struct net_device *ndev;
3128 int ret, devno; 3128 int ret;
3129 3129
3130 /* get base addr */ 3130 /* get base addr */
3131 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 3131 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -3137,10 +3137,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3137 pm_runtime_enable(&pdev->dev); 3137 pm_runtime_enable(&pdev->dev);
3138 pm_runtime_get_sync(&pdev->dev); 3138 pm_runtime_get_sync(&pdev->dev);
3139 3139
3140 devno = pdev->id;
3141 if (devno < 0)
3142 devno = 0;
3143
3144 ret = platform_get_irq(pdev, 0); 3140 ret = platform_get_irq(pdev, 0);
3145 if (ret < 0) 3141 if (ret < 0)
3146 goto out_release; 3142 goto out_release;
@@ -3222,8 +3218,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3222 eth_hw_addr_random(ndev); 3218 eth_hw_addr_random(ndev);
3223 } 3219 }
3224 3220
3225 /* ioremap the TSU registers */
3226 if (mdp->cd->tsu) { 3221 if (mdp->cd->tsu) {
3222 int port = pdev->id < 0 ? 0 : pdev->id % 2;
3227 struct resource *rtsu; 3223 struct resource *rtsu;
3228 3224
3229 rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); 3225 rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -3235,7 +3231,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3235 /* We can only request the TSU region for the first port 3231 /* We can only request the TSU region for the first port
3236 * of the two sharing this TSU for the probe to succeed... 3232 * of the two sharing this TSU for the probe to succeed...
3237 */ 3233 */
3238 if (devno % 2 == 0 && 3234 if (port == 0 &&
3239 !devm_request_mem_region(&pdev->dev, rtsu->start, 3235 !devm_request_mem_region(&pdev->dev, rtsu->start,
3240 resource_size(rtsu), 3236 resource_size(rtsu),
3241 dev_name(&pdev->dev))) { 3237 dev_name(&pdev->dev))) {
@@ -3243,6 +3239,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3243 ret = -EBUSY; 3239 ret = -EBUSY;
3244 goto out_release; 3240 goto out_release;
3245 } 3241 }
3242 /* ioremap the TSU registers */
3246 mdp->tsu_addr = devm_ioremap(&pdev->dev, rtsu->start, 3243 mdp->tsu_addr = devm_ioremap(&pdev->dev, rtsu->start,
3247 resource_size(rtsu)); 3244 resource_size(rtsu));
3248 if (!mdp->tsu_addr) { 3245 if (!mdp->tsu_addr) {
@@ -3250,16 +3247,14 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
3250 ret = -ENOMEM; 3247 ret = -ENOMEM;
3251 goto out_release; 3248 goto out_release;
3252 } 3249 }
3253 mdp->port = devno % 2; 3250 mdp->port = port;
3254 ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER; 3251 ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER;
3255 }
3256 3252
3257 /* Need to init only the first port of the two sharing a TSU */ 3253 /* Need to init only the first port of the two sharing a TSU */
3258 if (devno % 2 == 0) { 3254 if (port == 0) {
3259 if (mdp->cd->chip_reset) 3255 if (mdp->cd->chip_reset)
3260 mdp->cd->chip_reset(ndev); 3256 mdp->cd->chip_reset(ndev);
3261 3257
3262 if (mdp->cd->tsu) {
3263 /* TSU init (Init only)*/ 3258 /* TSU init (Init only)*/
3264 sh_eth_tsu_init(mdp); 3259 sh_eth_tsu_init(mdp);
3265 } 3260 }