summaryrefslogtreecommitdiffstats
path: root/drivers/net/miiphy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/miiphy.c')
-rw-r--r--drivers/net/miiphy.c27
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);