diff options
-rw-r--r-- | drivers/net/phy/mdio_bus.c | 9 | ||||
-rw-r--r-- | drivers/net/phy/phy_device.c | 12 | ||||
-rw-r--r-- | include/linux/phy.h | 1 |
3 files changed, 18 insertions, 4 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index fc2f0e695a13..c30196d0ad16 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
@@ -91,9 +91,12 @@ int mdiobus_register(struct mii_bus *bus) | |||
91 | 91 | ||
92 | err = device_register(&phydev->dev); | 92 | err = device_register(&phydev->dev); |
93 | 93 | ||
94 | if (err) | 94 | if (err) { |
95 | printk(KERN_ERR "phy %d failed to register\n", | 95 | printk(KERN_ERR "phy %d failed to register\n", |
96 | i); | 96 | i); |
97 | phy_device_free(phydev); | ||
98 | phydev = NULL; | ||
99 | } | ||
97 | } | 100 | } |
98 | 101 | ||
99 | bus->phy_map[i] = phydev; | 102 | bus->phy_map[i] = phydev; |
@@ -110,10 +113,8 @@ void mdiobus_unregister(struct mii_bus *bus) | |||
110 | int i; | 113 | int i; |
111 | 114 | ||
112 | for (i = 0; i < PHY_MAX_ADDR; i++) { | 115 | for (i = 0; i < PHY_MAX_ADDR; i++) { |
113 | if (bus->phy_map[i]) { | 116 | if (bus->phy_map[i]) |
114 | device_unregister(&bus->phy_map[i]->dev); | 117 | device_unregister(&bus->phy_map[i]->dev); |
115 | kfree(bus->phy_map[i]); | ||
116 | } | ||
117 | } | 118 | } |
118 | } | 119 | } |
119 | EXPORT_SYMBOL(mdiobus_unregister); | 120 | EXPORT_SYMBOL(mdiobus_unregister); |
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f6e484812a98..5b9e1751e1b4 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -44,6 +44,16 @@ static struct phy_driver genphy_driver; | |||
44 | extern int mdio_bus_init(void); | 44 | extern int mdio_bus_init(void); |
45 | extern void mdio_bus_exit(void); | 45 | extern void mdio_bus_exit(void); |
46 | 46 | ||
47 | void phy_device_free(struct phy_device *phydev) | ||
48 | { | ||
49 | kfree(phydev); | ||
50 | } | ||
51 | |||
52 | static void phy_device_release(struct device *dev) | ||
53 | { | ||
54 | phy_device_free(to_phy_device(dev)); | ||
55 | } | ||
56 | |||
47 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) | 57 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) |
48 | { | 58 | { |
49 | struct phy_device *dev; | 59 | struct phy_device *dev; |
@@ -54,6 +64,8 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) | |||
54 | if (NULL == dev) | 64 | if (NULL == dev) |
55 | return (struct phy_device*) PTR_ERR((void*)-ENOMEM); | 65 | return (struct phy_device*) PTR_ERR((void*)-ENOMEM); |
56 | 66 | ||
67 | dev->dev.release = phy_device_release; | ||
68 | |||
57 | dev->speed = 0; | 69 | dev->speed = 0; |
58 | dev->duplex = -1; | 70 | dev->duplex = -1; |
59 | dev->pause = dev->asym_pause = 0; | 71 | dev->pause = dev->asym_pause = 0; |
diff --git a/include/linux/phy.h b/include/linux/phy.h index e10763d79181..554836edd915 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
@@ -403,6 +403,7 @@ int phy_mii_ioctl(struct phy_device *phydev, | |||
403 | int phy_start_interrupts(struct phy_device *phydev); | 403 | int phy_start_interrupts(struct phy_device *phydev); |
404 | void phy_print_status(struct phy_device *phydev); | 404 | void phy_print_status(struct phy_device *phydev); |
405 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id); | 405 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id); |
406 | void phy_device_free(struct phy_device *phydev); | ||
406 | 407 | ||
407 | extern struct bus_type mdio_bus_type; | 408 | extern struct bus_type mdio_bus_type; |
408 | #endif /* __PHY_H */ | 409 | #endif /* __PHY_H */ |