+struct mii_dev *mdio_alloc(void)
+{
+ struct mii_dev *bus;
+
+ bus = malloc(sizeof(*bus));
+ if (!bus)
+ return bus;
+
+ memset(bus, 0, sizeof(*bus));
+
+ /* initalize mii_dev struct fields */
+ INIT_LIST_HEAD(&bus->link);
+
+ 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)
+ return -1;
+
+ /* check if we have unique name */
+ if (miiphy_get_dev_by_name(bus->name)) {
+ printf("mdio_register: non unique device name '%s'\n",
+ bus->name);
+ return -1;
+ }
+
+ /* add it to the list */
+ list_add_tail(&bus->link, &mii_devs);
+
+ if (!current_mii)
+ current_mii = 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)