Skip to content

Commit 9662ec1

Browse files
Sergei Shtylyovdavem330
authored andcommitted
sh_eth: get Ether port # only when needed
The dual-port Ether configurations always have a shared TSU to e.g. pass the packets between those ports. With the TSU init. code gathered under the single *if*, we now can only get the port # from 'platform_device::id' only when we actually need it (and not recalculate it each time)... Signed-off-by: Sergei Shtylyov <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3e14c96 commit 9662ec1

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

drivers/net/ethernet/renesas/sh_eth.c

Lines changed: 5 additions & 8 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;
@@ -3223,6 +3219,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
32233219
}
32243220

32253221
if (mdp->cd->tsu) {
3222+
int port = pdev->id < 0 ? 0 : pdev->id % 2;
32263223
struct resource *rtsu;
32273224

32283225
rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -3234,7 +3231,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
32343231
/* We can only request the TSU region for the first port
32353232
* of the two sharing this TSU for the probe to succeed...
32363233
*/
3237-
if (devno % 2 == 0 &&
3234+
if (port == 0 &&
32383235
!devm_request_mem_region(&pdev->dev, rtsu->start,
32393236
resource_size(rtsu),
32403237
dev_name(&pdev->dev))) {
@@ -3250,11 +3247,11 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
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;
32553252

32563253
/* Need to init only the first port of the two sharing a TSU */
3257-
if (devno % 2 == 0) {
3254+
if (port == 0) {
32583255
if (mdp->cd->chip_reset)
32593256
mdp->cd->chip_reset(ndev);
32603257

0 commit comments

Comments
 (0)