Skip to content

Commit 5138eb9

Browse files
committed
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 <[email protected]>
2 parents d9631c7 + 9662ec1 commit 5138eb9

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

drivers/net/ethernet/renesas/sh_eth.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
31253125
const struct platform_device_id *id = platform_get_device_id(pdev);
31263126
struct sh_eth_private *mdp;
31273127
struct net_device *ndev;
3128-
int ret, devno;
3128+
int ret;
31293129

31303130
/* get base addr */
31313131
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -3137,10 +3137,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
31373137
pm_runtime_enable(&pdev->dev);
31383138
pm_runtime_get_sync(&pdev->dev);
31393139

3140-
devno = pdev->id;
3141-
if (devno < 0)
3142-
devno = 0;
3143-
31443140
ret = platform_get_irq(pdev, 0);
31453141
if (ret < 0)
31463142
goto out_release;
@@ -3222,8 +3218,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
32223218
eth_hw_addr_random(ndev);
32233219
}
32243220

3225-
/* ioremap the TSU registers */
32263221
if (mdp->cd->tsu) {
3222+
int port = pdev->id < 0 ? 0 : pdev->id % 2;
32273223
struct resource *rtsu;
32283224

32293225
rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -3235,31 +3231,30 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
32353231
/* We can only request the TSU region for the first port
32363232
* of the two sharing this TSU for the probe to succeed...
32373233
*/
3238-
if (devno % 2 == 0 &&
3234+
if (port == 0 &&
32393235
!devm_request_mem_region(&pdev->dev, rtsu->start,
32403236
resource_size(rtsu),
32413237
dev_name(&pdev->dev))) {
32423238
dev_err(&pdev->dev, "can't request TSU resource.\n");
32433239
ret = -EBUSY;
32443240
goto out_release;
32453241
}
3242+
/* ioremap the TSU registers */
32463243
mdp->tsu_addr = devm_ioremap(&pdev->dev, rtsu->start,
32473244
resource_size(rtsu));
32483245
if (!mdp->tsu_addr) {
32493246
dev_err(&pdev->dev, "TSU region ioremap() failed.\n");
32503247
ret = -ENOMEM;
32513248
goto out_release;
32523249
}
3253-
mdp->port = devno % 2;
3250+
mdp->port = port;
32543251
ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER;
3255-
}
32563252

3257-
/* Need to init only the first port of the two sharing a TSU */
3258-
if (devno % 2 == 0) {
3259-
if (mdp->cd->chip_reset)
3260-
mdp->cd->chip_reset(ndev);
3253+
/* Need to init only the first port of the two sharing a TSU */
3254+
if (port == 0) {
3255+
if (mdp->cd->chip_reset)
3256+
mdp->cd->chip_reset(ndev);
32613257

3262-
if (mdp->cd->tsu) {
32633258
/* TSU init (Init only)*/
32643259
sh_eth_tsu_init(mdp);
32653260
}

0 commit comments

Comments
 (0)