Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phylib: two dynamic mii_bus allocation fallout fixes

1. arch/powerpc/platforms/pasemi/gpio_mdio.c also needs to be
converted over to mdiobus_{alloc,free}().

2. drivers/net/phy/fixed.c used to embed a struct mii_bus into its
struct fixed_mdio_bus and then use container_of() to go from the
former to the latter. Since mii bus structures are no longer
embedded, we need to do something like use the mii bus private
pointer to go from mii_bus to fixed_mdio_bus instead.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Lennert Buytenhek and committed by
David S. Miller
ec2a5652 724f8805

+4 -4
+2 -2
arch/powerpc/platforms/pasemi/gpio_mdio.c
··· 230 230 if (!priv) 231 231 goto out; 232 232 233 - new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL); 233 + new_bus = mdiobus_alloc(); 234 234 235 235 if (!new_bus) 236 236 goto out_free_priv; ··· 306 306 307 307 kfree(bus->priv); 308 308 bus->priv = NULL; 309 - kfree(bus); 309 + mdiobus_free(bus); 310 310 311 311 return 0; 312 312 }
+2 -2
drivers/net/phy/fixed.c
··· 115 115 116 116 static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) 117 117 { 118 - struct fixed_mdio_bus *fmb = container_of(bus, struct fixed_mdio_bus, 119 - mii_bus); 118 + struct fixed_mdio_bus *fmb = bus->priv; 120 119 struct fixed_phy *fp; 121 120 122 121 if (reg_num >= MII_REGS_NUM) ··· 220 221 221 222 snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "0"); 222 223 fmb->mii_bus->name = "Fixed MDIO Bus"; 224 + fmb->mii_bus->priv = fmb; 223 225 fmb->mii_bus->parent = &pdev->dev; 224 226 fmb->mii_bus->read = &fixed_mdio_read; 225 227 fmb->mii_bus->write = &fixed_mdio_write;