From e352b06d09a2822cf2295374768c08d889ef69a9 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Tue, 4 Dec 2007 16:17:33 +0300 Subject: [PATCH] --- yaml --- r: 74579 b: refs/heads/master c: 6f4a7f4183bdbd02741dcd8edbd10b8628acc5d5 h: refs/heads/master i: 74577: 45ffb94a7a07bc91794482975e6c2f43d34d0756 74575: 1700f1633cc5bc7bb991fcd4758ea0e2cb33a0fe v: v3 --- [refs] | 2 +- trunk/drivers/net/phy/mdio_bus.c | 9 +++++---- trunk/drivers/net/phy/phy_device.c | 12 ++++++++++++ trunk/include/linux/phy.h | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index fb5f68596c4c..949a2c643816 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f9663aea2a938f9dc60dbfef34b9e7847a69c947 +refs/heads/master: 6f4a7f4183bdbd02741dcd8edbd10b8628acc5d5 diff --git a/trunk/drivers/net/phy/mdio_bus.c b/trunk/drivers/net/phy/mdio_bus.c index fc2f0e695a13..c30196d0ad16 100644 --- a/trunk/drivers/net/phy/mdio_bus.c +++ b/trunk/drivers/net/phy/mdio_bus.c @@ -91,9 +91,12 @@ int mdiobus_register(struct mii_bus *bus) err = device_register(&phydev->dev); - if (err) + if (err) { printk(KERN_ERR "phy %d failed to register\n", i); + phy_device_free(phydev); + phydev = NULL; + } } bus->phy_map[i] = phydev; @@ -110,10 +113,8 @@ void mdiobus_unregister(struct mii_bus *bus) int i; for (i = 0; i < PHY_MAX_ADDR; i++) { - if (bus->phy_map[i]) { + if (bus->phy_map[i]) device_unregister(&bus->phy_map[i]->dev); - kfree(bus->phy_map[i]); - } } } EXPORT_SYMBOL(mdiobus_unregister); diff --git a/trunk/drivers/net/phy/phy_device.c b/trunk/drivers/net/phy/phy_device.c index f6e484812a98..5b9e1751e1b4 100644 --- a/trunk/drivers/net/phy/phy_device.c +++ b/trunk/drivers/net/phy/phy_device.c @@ -44,6 +44,16 @@ static struct phy_driver genphy_driver; extern int mdio_bus_init(void); extern void mdio_bus_exit(void); +void phy_device_free(struct phy_device *phydev) +{ + kfree(phydev); +} + +static void phy_device_release(struct device *dev) +{ + phy_device_free(to_phy_device(dev)); +} + struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) { struct phy_device *dev; @@ -54,6 +64,8 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) if (NULL == dev) return (struct phy_device*) PTR_ERR((void*)-ENOMEM); + dev->dev.release = phy_device_release; + dev->speed = 0; dev->duplex = -1; dev->pause = dev->asym_pause = 0; diff --git a/trunk/include/linux/phy.h b/trunk/include/linux/phy.h index e10763d79181..554836edd915 100644 --- a/trunk/include/linux/phy.h +++ b/trunk/include/linux/phy.h @@ -403,6 +403,7 @@ int phy_mii_ioctl(struct phy_device *phydev, int phy_start_interrupts(struct phy_device *phydev); void phy_print_status(struct phy_device *phydev); struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id); +void phy_device_free(struct phy_device *phydev); extern struct bus_type mdio_bus_type; #endif /* __PHY_H */