]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - common/miiphyutil.c
mkimage: Report information about fpga
[karo-tx-uboot.git] / common / miiphyutil.c
index c88c28adbf4ede84eb62422557cd14c87307acba..7e41957185072123a81468309081ec4586730867 100644 (file)
@@ -114,6 +114,8 @@ void miiphy_register(const char *name,
        if (new_dev == NULL || ldev == NULL) {
                printf("miiphy_register: cannot allocate memory for '%s'\n",
                        name);
+               free(ldev);
+               mdio_free(new_dev);
                return;
        }
 
@@ -152,9 +154,14 @@ struct mii_dev *mdio_alloc(void)
        return bus;
 }
 
+void mdio_free(struct mii_dev *bus)
+{
+       free(bus);
+}
+
 int mdio_register(struct mii_dev *bus)
 {
-       if (!bus || !bus->name || !bus->read || !bus->write)
+       if (!bus || !bus->read || !bus->write)
                return -1;
 
        /* check if we have unique name */
@@ -173,6 +180,20 @@ int mdio_register(struct mii_dev *bus)
        return 0;
 }
 
+int mdio_unregister(struct mii_dev *bus)
+{
+       if (!bus)
+               return 0;
+
+       /* delete it from the list */
+       list_del(&bus->link);
+
+       if (current_mii == bus)
+               current_mii = NULL;
+
+       return 0;
+}
+
 void mdio_list_devices(void)
 {
        struct list_head *entry;