diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-06-11 15:32:06 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-07-21 16:41:46 +0200 |
commit | 2f8df2a003a22e8b7397e51ac5f1796db920d579 (patch) | |
tree | f92f130a7a4522e6391174a02fdb3d82ba44e080 /drivers/net/miiphy.c | |
parent | 56139274fda2ce914860a978d32d79bd43099ae1 (diff) | |
download | barebox-2f8df2a003a22e8b7397e51ac5f1796db920d579.tar.gz barebox-2f8df2a003a22e8b7397e51ac5f1796db920d579.tar.xz |
add a device_d to ethernet devices
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/miiphy.c')
-rw-r--r-- | drivers/net/miiphy.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/net/miiphy.c b/drivers/net/miiphy.c index b4e6756a93..30f235390b 100644 --- a/drivers/net/miiphy.c +++ b/drivers/net/miiphy.c @@ -26,6 +26,7 @@ #include <miiphy.h> #include <clock.h> #include <net.h> +#include <malloc.h> int miiphy_restart_aneg(struct miiphy_device *mdev) { @@ -175,10 +176,8 @@ static struct file_operations miiphy_ops = { static int miiphy_probe(struct device_d *dev) { struct miiphy_device *mdev = dev->priv; - char name[MAX_DRIVER_NAME]; - get_free_deviceid(name, "phy"); - mdev->cdev.name = strdup(name); + mdev->cdev.name = asprintf("phy%d", dev->id); mdev->cdev.size = 32; mdev->cdev.ops = &miiphy_ops; mdev->cdev.priv = mdev; @@ -186,19 +185,33 @@ static int miiphy_probe(struct device_d *dev) return 0; } -int miiphy_register(struct miiphy_device *mdev) +static void miiphy_remove(struct device_d *dev) { - mdev->dev.priv = mdev; - strcpy(mdev->dev.name, "miiphy"); + struct miiphy_device *mdev = dev->priv; - return register_device(&mdev->dev); + free(mdev->cdev.name); + devfs_remove(&mdev->cdev); } static struct driver_d miiphy_drv = { .name = "miiphy", .probe = miiphy_probe, + .remove = miiphy_remove, }; +int miiphy_register(struct miiphy_device *mdev) +{ + mdev->dev.priv = mdev; + strcpy(mdev->dev.name, "miiphy"); + + return register_device(&mdev->dev); +} + +void miiphy_unregister(struct miiphy_device *mdev) +{ + unregister_device(&mdev->dev); +} + static int miiphy_init(void) { register_driver(&miiphy_drv); |