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>
struct resource res;
const char *mac_addr;
int ret;
struct resource res;
const char *mac_addr;
int ret;
memset(&ppd, 0, sizeof(ppd));
ppd.shared = pdev;
memset(&ppd, 0, sizeof(ppd));
ppd.shared = pdev;
+ while (dev_num < 3 && port_platdev[dev_num])
+ dev_num++;
+
+ if (dev_num == 3) {
+ dev_err(&pdev->dev, "too many ports registered\n");
+ return -EINVAL;
+ }
+
mac_addr = of_get_mac_address(pnp);
if (mac_addr)
memcpy(ppd.mac_addr, mac_addr, 6);
mac_addr = of_get_mac_address(pnp);
if (mac_addr)
memcpy(ppd.mac_addr, mac_addr, 6);
of_property_read_u32(pnp, "duplex", &ppd.duplex);
}
of_property_read_u32(pnp, "duplex", &ppd.duplex);
}
- ppdev = platform_device_alloc(MV643XX_ETH_NAME, ppd.port_number);
+ ppdev = platform_device_alloc(MV643XX_ETH_NAME, dev_num);
if (!ppdev)
return -ENOMEM;
ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
if (!ppdev)
return -ENOMEM;
ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
- port_platdev[ppd.port_number] = ppdev;
+ port_platdev[dev_num] = ppdev;