Commit 88a972d7 authored by Robert Hancock's avatar Robert Hancock Committed by David S. Miller

net: axienet: fix MDIO bus naming

The MDIO bus for this driver was being named using the result of
of_address_to_resource on a node which may not have any resource on it,
but the return value of that call was not checked so it was using some
random value in the bus name. Change to name the MDIO bus based on the
resource start of the actual Ethernet register block.
Signed-off-by: default avatarRobert Hancock <hancock@sedsystems.ca>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d85f5f3e
...@@ -380,6 +380,7 @@ struct axidma_bd { ...@@ -380,6 +380,7 @@ struct axidma_bd {
* @dev: Pointer to device structure * @dev: Pointer to device structure
* @phy_node: Pointer to device node structure * @phy_node: Pointer to device node structure
* @mii_bus: Pointer to MII bus structure * @mii_bus: Pointer to MII bus structure
* @regs_start: Resource start for axienet device addresses
* @regs: Base address for the axienet_local device address space * @regs: Base address for the axienet_local device address space
* @dma_regs: Base address for the axidma device address space * @dma_regs: Base address for the axidma device address space
* @dma_err_tasklet: Tasklet structure to process Axi DMA errors * @dma_err_tasklet: Tasklet structure to process Axi DMA errors
...@@ -421,6 +422,7 @@ struct axienet_local { ...@@ -421,6 +422,7 @@ struct axienet_local {
struct mii_bus *mii_bus; /* MII bus reference */ struct mii_bus *mii_bus; /* MII bus reference */
/* IO registers, dma functions and IRQs */ /* IO registers, dma functions and IRQs */
resource_size_t regs_start;
void __iomem *regs; void __iomem *regs;
void __iomem *dma_regs; void __iomem *dma_regs;
......
...@@ -1480,6 +1480,7 @@ static int axienet_probe(struct platform_device *pdev) ...@@ -1480,6 +1480,7 @@ static int axienet_probe(struct platform_device *pdev)
lp->options = XAE_OPTION_DEFAULTS; lp->options = XAE_OPTION_DEFAULTS;
/* Map device registers */ /* Map device registers */
ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0); ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
lp->regs_start = ethres->start;
lp->regs = devm_ioremap_resource(&pdev->dev, ethres); lp->regs = devm_ioremap_resource(&pdev->dev, ethres);
if (IS_ERR(lp->regs)) { if (IS_ERR(lp->regs)) {
dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n"); dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n");
......
...@@ -127,7 +127,7 @@ int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np) ...@@ -127,7 +127,7 @@ int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np)
int ret; int ret;
u32 clk_div, host_clock; u32 clk_div, host_clock;
struct mii_bus *bus; struct mii_bus *bus;
struct resource res; struct device_node *mdio_node;
struct device_node *np1; struct device_node *np1;
/* clk_div can be calculated by deriving it from the equation: /* clk_div can be calculated by deriving it from the equation:
...@@ -199,10 +199,9 @@ int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np) ...@@ -199,10 +199,9 @@ int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np)
if (!bus) if (!bus)
return -ENOMEM; return -ENOMEM;
np1 = of_get_parent(lp->phy_node); mdio_node = of_get_parent(lp->phy_node);
of_address_to_resource(np1, 0, &res); snprintf(bus->id, MII_BUS_ID_SIZE, "axienet-%.8llx",
snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", (unsigned long long)lp->regs_start);
(unsigned long long) res.start);
bus->priv = lp; bus->priv = lp;
bus->name = "Xilinx Axi Ethernet MDIO"; bus->name = "Xilinx Axi Ethernet MDIO";
...@@ -211,7 +210,7 @@ int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np) ...@@ -211,7 +210,7 @@ int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np)
bus->parent = lp->dev; bus->parent = lp->dev;
lp->mii_bus = bus; lp->mii_bus = bus;
ret = of_mdiobus_register(bus, np1); ret = of_mdiobus_register(bus, mdio_node);
if (ret) { if (ret) {
mdiobus_free(bus); mdiobus_free(bus);
lp->mii_bus = NULL; lp->mii_bus = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment