aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/mv643xx_eth.c
diff options
context:
space:
mode:
authorJonas Gorski <jogo@openwrt.org>2013-07-07 18:44:55 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-09 15:51:47 -0400
commit785bf6f7904352242d187ff6087d523a4ce1b3ac (patch)
treeac6398593dc4eb29b24d7ff590237e2bf9b1941d /drivers/net/ethernet/marvell/mv643xx_eth.c
parent8c2f414ad1b3aa3af05791cd7312eb8ff9d80e0d (diff)
net: mv643xx_eth: do not use port number as platform device id
The port number is only local to the ethernet block, not global, so there can be two ethernet blocks both using the same port, like kirkwood with both using port 0. Fix this by using the array index offset for the allocated platform devices as the id. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell/mv643xx_eth.c')
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 6495bea56ec8..c35db735958f 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2483,6 +2483,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
2483 struct resource res; 2483 struct resource res;
2484 const char *mac_addr; 2484 const char *mac_addr;
2485 int ret; 2485 int ret;
2486 int dev_num = 0;
2486 2487
2487 memset(&ppd, 0, sizeof(ppd)); 2488 memset(&ppd, 0, sizeof(ppd));
2488 ppd.shared = pdev; 2489 ppd.shared = pdev;
@@ -2503,6 +2504,14 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
2503 return -EINVAL; 2504 return -EINVAL;
2504 } 2505 }
2505 2506
2507 while (dev_num < 3 && port_platdev[dev_num])
2508 dev_num++;
2509
2510 if (dev_num == 3) {
2511 dev_err(&pdev->dev, "too many ports registered\n");
2512 return -EINVAL;
2513 }
2514
2506 mac_addr = of_get_mac_address(pnp); 2515 mac_addr = of_get_mac_address(pnp);
2507 if (mac_addr) 2516 if (mac_addr)
2508 memcpy(ppd.mac_addr, mac_addr, 6); 2517 memcpy(ppd.mac_addr, mac_addr, 6);
@@ -2521,7 +2530,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
2521 of_property_read_u32(pnp, "duplex", &ppd.duplex); 2530 of_property_read_u32(pnp, "duplex", &ppd.duplex);
2522 } 2531 }
2523 2532
2524 ppdev = platform_device_alloc(MV643XX_ETH_NAME, ppd.port_number); 2533 ppdev = platform_device_alloc(MV643XX_ETH_NAME, dev_num);
2525 if (!ppdev) 2534 if (!ppdev)
2526 return -ENOMEM; 2535 return -ENOMEM;
2527 ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); 2536 ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
@@ -2538,7 +2547,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
2538 if (ret) 2547 if (ret)
2539 goto port_err; 2548 goto port_err;
2540 2549
2541 port_platdev[ppd.port_number] = ppdev; 2550 port_platdev[dev_num] = ppdev;
2542 2551
2543 return 0; 2552 return 0;
2544 2553