aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/phy_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r--drivers/net/phy/phy_device.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7da0e3dd5fe3..ecd3da151e2d 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -14,7 +14,6 @@
14 * option) any later version. 14 * option) any later version.
15 * 15 *
16 */ 16 */
17#include <linux/config.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/sched.h> 18#include <linux/sched.h>
20#include <linux/string.h> 19#include <linux/string.h>
@@ -46,6 +45,35 @@ static struct phy_driver genphy_driver;
46extern int mdio_bus_init(void); 45extern int mdio_bus_init(void);
47extern void mdio_bus_exit(void); 46extern void mdio_bus_exit(void);
48 47
48struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
49{
50 struct phy_device *dev;
51 /* We allocate the device, and initialize the
52 * default values */
53 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
54
55 if (NULL == dev)
56 return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
57
58 dev->speed = 0;
59 dev->duplex = -1;
60 dev->pause = dev->asym_pause = 0;
61 dev->link = 1;
62
63 dev->autoneg = AUTONEG_ENABLE;
64
65 dev->addr = addr;
66 dev->phy_id = phy_id;
67 dev->bus = bus;
68
69 dev->state = PHY_DOWN;
70
71 spin_lock_init(&dev->lock);
72
73 return dev;
74}
75EXPORT_SYMBOL(phy_device_create);
76
49/* get_phy_device 77/* get_phy_device
50 * 78 *
51 * description: Reads the ID registers of the PHY at addr on the 79 * description: Reads the ID registers of the PHY at addr on the
@@ -79,27 +107,7 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
79 if (0xffffffff == phy_id) 107 if (0xffffffff == phy_id)
80 return NULL; 108 return NULL;
81 109
82 /* Otherwise, we allocate the device, and initialize the 110 dev = phy_device_create(bus, addr, phy_id);
83 * default values */
84 dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
85
86 if (NULL == dev)
87 return ERR_PTR(-ENOMEM);
88
89 dev->speed = 0;
90 dev->duplex = -1;
91 dev->pause = dev->asym_pause = 0;
92 dev->link = 1;
93
94 dev->autoneg = AUTONEG_ENABLE;
95
96 dev->addr = addr;
97 dev->phy_id = phy_id;
98 dev->bus = bus;
99
100 dev->state = PHY_DOWN;
101
102 spin_lock_init(&dev->lock);
103 111
104 return dev; 112 return dev;
105} 113}
@@ -514,7 +522,7 @@ EXPORT_SYMBOL(genphy_read_status);
514 522
515static int genphy_config_init(struct phy_device *phydev) 523static int genphy_config_init(struct phy_device *phydev)
516{ 524{
517 u32 val; 525 int val;
518 u32 features; 526 u32 features;
519 527
520 /* For now, I'll claim that the generic driver supports 528 /* For now, I'll claim that the generic driver supports