diff options
| author | Jeff Garzik <jeff@garzik.org> | 2006-08-29 17:55:59 -0400 |
|---|---|---|
| committer | Jeff Garzik <jeff@garzik.org> | 2006-08-29 17:55:59 -0400 |
| commit | b01e86fee6c821e4e003fd4e9f65453ac478a58e (patch) | |
| tree | 21695e10cbe7001d2ccc8c87cee5e7a7865b1025 /drivers/net/phy/phy_device.c | |
| parent | e889173c2c67dc288e9b050ab066cfae151b047e (diff) | |
| parent | 60d4684068ff1eec78f55b5888d0bd2d4cca1520 (diff) | |
Merge /spare/repo/linux-2.6 into upstream
Diffstat (limited to 'drivers/net/phy/phy_device.c')
| -rw-r--r-- | drivers/net/phy/phy_device.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 1bc1e032c5d6..2d1ecfdc80db 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
| @@ -45,6 +45,35 @@ static struct phy_driver genphy_driver; | |||
| 45 | extern int mdio_bus_init(void); | 45 | extern int mdio_bus_init(void); |
| 46 | extern void mdio_bus_exit(void); | 46 | extern void mdio_bus_exit(void); |
| 47 | 47 | ||
| 48 | struct 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 | } | ||
| 75 | EXPORT_SYMBOL(phy_device_create); | ||
| 76 | |||
| 48 | /* get_phy_device | 77 | /* get_phy_device |
| 49 | * | 78 | * |
| 50 | * 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 |
| @@ -78,27 +107,7 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr) | |||
| 78 | if (0xffffffff == phy_id) | 107 | if (0xffffffff == phy_id) |
| 79 | return NULL; | 108 | return NULL; |
| 80 | 109 | ||
| 81 | /* Otherwise, we allocate the device, and initialize the | 110 | dev = phy_device_create(bus, addr, phy_id); |
| 82 | * default values */ | ||
| 83 | dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); | ||
| 84 | |||
| 85 | if (NULL == dev) | ||
| 86 | return ERR_PTR(-ENOMEM); | ||
| 87 | |||
| 88 | dev->speed = 0; | ||
| 89 | dev->duplex = -1; | ||
| 90 | dev->pause = dev->asym_pause = 0; | ||
| 91 | dev->link = 1; | ||
| 92 | |||
| 93 | dev->autoneg = AUTONEG_ENABLE; | ||
| 94 | |||
| 95 | dev->addr = addr; | ||
| 96 | dev->phy_id = phy_id; | ||
| 97 | dev->bus = bus; | ||
| 98 | |||
| 99 | dev->state = PHY_DOWN; | ||
| 100 | |||
| 101 | spin_lock_init(&dev->lock); | ||
| 102 | 111 | ||
| 103 | return dev; | 112 | return dev; |
| 104 | } | 113 | } |
