mdio_bus.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /* MDIO Bus interface
  2. *
  3. * Author: Andy Fleming
  4. *
  5. * Copyright (c) 2004 Freescale Semiconductor, Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. */
  13. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  14. #include <linux/kernel.h>
  15. #include <linux/string.h>
  16. #include <linux/errno.h>
  17. #include <linux/unistd.h>
  18. #include <linux/slab.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/init.h>
  21. #include <linux/delay.h>
  22. #include <linux/device.h>
  23. #include <linux/of_device.h>
  24. #include <linux/of_mdio.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/etherdevice.h>
  27. #include <linux/skbuff.h>
  28. #include <linux/spinlock.h>
  29. #include <linux/mm.h>
  30. #include <linux/module.h>
  31. #include <linux/mii.h>
  32. #include <linux/ethtool.h>
  33. #include <linux/phy.h>
  34. #include <linux/io.h>
  35. #include <linux/uaccess.h>
  36. #include <asm/irq.h>
  37. /**
  38. * mdiobus_alloc_size - allocate a mii_bus structure
  39. * @size: extra amount of memory to allocate for private storage.
  40. * If non-zero, then bus->priv is points to that memory.
  41. *
  42. * Description: called by a bus driver to allocate an mii_bus
  43. * structure to fill in.
  44. */
  45. struct mii_bus *mdiobus_alloc_size(size_t size)
  46. {
  47. struct mii_bus *bus;
  48. size_t aligned_size = ALIGN(sizeof(*bus), NETDEV_ALIGN);
  49. size_t alloc_size;
  50. /* If we alloc extra space, it should be aligned */
  51. if (size)
  52. alloc_size = aligned_size + size;
  53. else
  54. alloc_size = sizeof(*bus);
  55. bus = kzalloc(alloc_size, GFP_KERNEL);
  56. if (bus) {
  57. bus->state = MDIOBUS_ALLOCATED;
  58. if (size)
  59. bus->priv = (void *)bus + aligned_size;
  60. }
  61. return bus;
  62. }
  63. EXPORT_SYMBOL(mdiobus_alloc_size);
  64. static void _devm_mdiobus_free(struct device *dev, void *res)
  65. {
  66. mdiobus_free(*(struct mii_bus **)res);
  67. }
  68. static int devm_mdiobus_match(struct device *dev, void *res, void *data)
  69. {
  70. struct mii_bus **r = res;
  71. if (WARN_ON(!r || !*r))
  72. return 0;
  73. return *r == data;
  74. }
  75. /**
  76. * devm_mdiobus_alloc_size - Resource-managed mdiobus_alloc_size()
  77. * @dev: Device to allocate mii_bus for
  78. * @sizeof_priv: Space to allocate for private structure.
  79. *
  80. * Managed mdiobus_alloc_size. mii_bus allocated with this function is
  81. * automatically freed on driver detach.
  82. *
  83. * If an mii_bus allocated with this function needs to be freed separately,
  84. * devm_mdiobus_free() must be used.
  85. *
  86. * RETURNS:
  87. * Pointer to allocated mii_bus on success, NULL on failure.
  88. */
  89. struct mii_bus *devm_mdiobus_alloc_size(struct device *dev, int sizeof_priv)
  90. {
  91. struct mii_bus **ptr, *bus;
  92. ptr = devres_alloc(_devm_mdiobus_free, sizeof(*ptr), GFP_KERNEL);
  93. if (!ptr)
  94. return NULL;
  95. /* use raw alloc_dr for kmalloc caller tracing */
  96. bus = mdiobus_alloc_size(sizeof_priv);
  97. if (bus) {
  98. *ptr = bus;
  99. devres_add(dev, ptr);
  100. } else {
  101. devres_free(ptr);
  102. }
  103. return bus;
  104. }
  105. EXPORT_SYMBOL_GPL(devm_mdiobus_alloc_size);
  106. /**
  107. * devm_mdiobus_free - Resource-managed mdiobus_free()
  108. * @dev: Device this mii_bus belongs to
  109. * @bus: the mii_bus associated with the device
  110. *
  111. * Free mii_bus allocated with devm_mdiobus_alloc_size().
  112. */
  113. void devm_mdiobus_free(struct device *dev, struct mii_bus *bus)
  114. {
  115. int rc;
  116. rc = devres_release(dev, _devm_mdiobus_free,
  117. devm_mdiobus_match, bus);
  118. WARN_ON(rc);
  119. }
  120. EXPORT_SYMBOL_GPL(devm_mdiobus_free);
  121. /**
  122. * mdiobus_release - mii_bus device release callback
  123. * @d: the target struct device that contains the mii_bus
  124. *
  125. * Description: called when the last reference to an mii_bus is
  126. * dropped, to free the underlying memory.
  127. */
  128. static void mdiobus_release(struct device *d)
  129. {
  130. struct mii_bus *bus = to_mii_bus(d);
  131. BUG_ON(bus->state != MDIOBUS_RELEASED &&
  132. /* for compatibility with error handling in drivers */
  133. bus->state != MDIOBUS_ALLOCATED);
  134. kfree(bus);
  135. }
  136. static struct class mdio_bus_class = {
  137. .name = "mdio_bus",
  138. .dev_release = mdiobus_release,
  139. };
  140. #if IS_ENABLED(CONFIG_OF_MDIO)
  141. /* Helper function for of_mdio_find_bus */
  142. static int of_mdio_bus_match(struct device *dev, const void *mdio_bus_np)
  143. {
  144. return dev->of_node == mdio_bus_np;
  145. }
  146. /**
  147. * of_mdio_find_bus - Given an mii_bus node, find the mii_bus.
  148. * @mdio_bus_np: Pointer to the mii_bus.
  149. *
  150. * Returns a reference to the mii_bus, or NULL if none found. The
  151. * embedded struct device will have its reference count incremented,
  152. * and this must be put once the bus is finished with.
  153. *
  154. * Because the association of a device_node and mii_bus is made via
  155. * of_mdiobus_register(), the mii_bus cannot be found before it is
  156. * registered with of_mdiobus_register().
  157. *
  158. */
  159. struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
  160. {
  161. struct device *d;
  162. if (!mdio_bus_np)
  163. return NULL;
  164. d = class_find_device(&mdio_bus_class, NULL, mdio_bus_np,
  165. of_mdio_bus_match);
  166. return d ? to_mii_bus(d) : NULL;
  167. }
  168. EXPORT_SYMBOL(of_mdio_find_bus);
  169. /* Walk the list of subnodes of a mdio bus and look for a node that matches the
  170. * phy's address with its 'reg' property. If found, set the of_node pointer for
  171. * the phy. This allows auto-probed pyh devices to be supplied with information
  172. * passed in via DT.
  173. */
  174. static void of_mdiobus_link_phydev(struct mii_bus *mdio,
  175. struct phy_device *phydev)
  176. {
  177. struct device *dev = &phydev->dev;
  178. struct device_node *child;
  179. if (dev->of_node || !mdio->dev.of_node)
  180. return;
  181. for_each_available_child_of_node(mdio->dev.of_node, child) {
  182. int addr;
  183. int ret;
  184. ret = of_property_read_u32(child, "reg", &addr);
  185. if (ret < 0) {
  186. dev_err(dev, "%s has invalid PHY address\n",
  187. child->full_name);
  188. continue;
  189. }
  190. /* A PHY must have a reg property in the range [0-31] */
  191. if (addr >= PHY_MAX_ADDR) {
  192. dev_err(dev, "%s PHY address %i is too large\n",
  193. child->full_name, addr);
  194. continue;
  195. }
  196. if (addr == phydev->addr) {
  197. dev->of_node = child;
  198. return;
  199. }
  200. }
  201. }
  202. #else /* !IS_ENABLED(CONFIG_OF_MDIO) */
  203. static inline void of_mdiobus_link_phydev(struct mii_bus *mdio,
  204. struct phy_device *phydev)
  205. {
  206. }
  207. #endif
  208. /**
  209. * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
  210. * @bus: target mii_bus
  211. * @owner: module containing bus accessor functions
  212. *
  213. * Description: Called by a bus driver to bring up all the PHYs
  214. * on a given bus, and attach them to the bus. Drivers should use
  215. * mdiobus_register() rather than __mdiobus_register() unless they
  216. * need to pass a specific owner module.
  217. *
  218. * Returns 0 on success or < 0 on error.
  219. */
  220. int __mdiobus_register(struct mii_bus *bus, struct module *owner)
  221. {
  222. int i, err;
  223. if (NULL == bus || NULL == bus->name ||
  224. NULL == bus->read || NULL == bus->write)
  225. return -EINVAL;
  226. BUG_ON(bus->state != MDIOBUS_ALLOCATED &&
  227. bus->state != MDIOBUS_UNREGISTERED);
  228. bus->owner = owner;
  229. bus->dev.parent = bus->parent;
  230. bus->dev.class = &mdio_bus_class;
  231. bus->dev.groups = NULL;
  232. dev_set_name(&bus->dev, "%s", bus->id);
  233. err = device_register(&bus->dev);
  234. if (err) {
  235. pr_err("mii_bus %s failed to register\n", bus->id);
  236. return -EINVAL;
  237. }
  238. mutex_init(&bus->mdio_lock);
  239. if (bus->reset)
  240. bus->reset(bus);
  241. for (i = 0; i < PHY_MAX_ADDR; i++) {
  242. if ((bus->phy_mask & (1 << i)) == 0) {
  243. struct phy_device *phydev;
  244. phydev = mdiobus_scan(bus, i);
  245. if (IS_ERR(phydev)) {
  246. err = PTR_ERR(phydev);
  247. goto error;
  248. }
  249. }
  250. }
  251. bus->state = MDIOBUS_REGISTERED;
  252. pr_info("%s: probed\n", bus->name);
  253. return 0;
  254. error:
  255. while (--i >= 0) {
  256. struct phy_device *phydev = bus->phy_map[i];
  257. if (phydev) {
  258. phy_device_remove(phydev);
  259. phy_device_free(phydev);
  260. }
  261. }
  262. device_del(&bus->dev);
  263. return err;
  264. }
  265. EXPORT_SYMBOL(__mdiobus_register);
  266. void mdiobus_unregister(struct mii_bus *bus)
  267. {
  268. int i;
  269. BUG_ON(bus->state != MDIOBUS_REGISTERED);
  270. bus->state = MDIOBUS_UNREGISTERED;
  271. for (i = 0; i < PHY_MAX_ADDR; i++) {
  272. struct phy_device *phydev = bus->phy_map[i];
  273. if (phydev) {
  274. phy_device_remove(phydev);
  275. phy_device_free(phydev);
  276. }
  277. }
  278. device_del(&bus->dev);
  279. }
  280. EXPORT_SYMBOL(mdiobus_unregister);
  281. /**
  282. * mdiobus_free - free a struct mii_bus
  283. * @bus: mii_bus to free
  284. *
  285. * This function releases the reference to the underlying device
  286. * object in the mii_bus. If this is the last reference, the mii_bus
  287. * will be freed.
  288. */
  289. void mdiobus_free(struct mii_bus *bus)
  290. {
  291. /* For compatibility with error handling in drivers. */
  292. if (bus->state == MDIOBUS_ALLOCATED) {
  293. kfree(bus);
  294. return;
  295. }
  296. BUG_ON(bus->state != MDIOBUS_UNREGISTERED);
  297. bus->state = MDIOBUS_RELEASED;
  298. put_device(&bus->dev);
  299. }
  300. EXPORT_SYMBOL(mdiobus_free);
  301. struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
  302. {
  303. struct phy_device *phydev;
  304. int err;
  305. phydev = get_phy_device(bus, addr, false);
  306. if (IS_ERR(phydev) || phydev == NULL)
  307. return phydev;
  308. /*
  309. * For DT, see if the auto-probed phy has a correspoding child
  310. * in the bus node, and set the of_node pointer in this case.
  311. */
  312. of_mdiobus_link_phydev(bus, phydev);
  313. err = phy_device_register(phydev);
  314. if (err) {
  315. phy_device_free(phydev);
  316. return NULL;
  317. }
  318. return phydev;
  319. }
  320. EXPORT_SYMBOL(mdiobus_scan);
  321. /**
  322. * mdiobus_read_nested - Nested version of the mdiobus_read function
  323. * @bus: the mii_bus struct
  324. * @addr: the phy address
  325. * @regnum: register number to read
  326. *
  327. * In case of nested MDIO bus access avoid lockdep false positives by
  328. * using mutex_lock_nested().
  329. *
  330. * NOTE: MUST NOT be called from interrupt context,
  331. * because the bus read/write functions may wait for an interrupt
  332. * to conclude the operation.
  333. */
  334. int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum)
  335. {
  336. int retval;
  337. BUG_ON(in_interrupt());
  338. mutex_lock_nested(&bus->mdio_lock, SINGLE_DEPTH_NESTING);
  339. retval = bus->read(bus, addr, regnum);
  340. mutex_unlock(&bus->mdio_lock);
  341. return retval;
  342. }
  343. EXPORT_SYMBOL(mdiobus_read_nested);
  344. /**
  345. * mdiobus_read - Convenience function for reading a given MII mgmt register
  346. * @bus: the mii_bus struct
  347. * @addr: the phy address
  348. * @regnum: register number to read
  349. *
  350. * NOTE: MUST NOT be called from interrupt context,
  351. * because the bus read/write functions may wait for an interrupt
  352. * to conclude the operation.
  353. */
  354. int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)
  355. {
  356. int retval;
  357. BUG_ON(in_interrupt());
  358. mutex_lock(&bus->mdio_lock);
  359. retval = bus->read(bus, addr, regnum);
  360. mutex_unlock(&bus->mdio_lock);
  361. return retval;
  362. }
  363. EXPORT_SYMBOL(mdiobus_read);
  364. /**
  365. * mdiobus_write_nested - Nested version of the mdiobus_write function
  366. * @bus: the mii_bus struct
  367. * @addr: the phy address
  368. * @regnum: register number to write
  369. * @val: value to write to @regnum
  370. *
  371. * In case of nested MDIO bus access avoid lockdep false positives by
  372. * using mutex_lock_nested().
  373. *
  374. * NOTE: MUST NOT be called from interrupt context,
  375. * because the bus read/write functions may wait for an interrupt
  376. * to conclude the operation.
  377. */
  378. int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val)
  379. {
  380. int err;
  381. BUG_ON(in_interrupt());
  382. mutex_lock_nested(&bus->mdio_lock, SINGLE_DEPTH_NESTING);
  383. err = bus->write(bus, addr, regnum, val);
  384. mutex_unlock(&bus->mdio_lock);
  385. return err;
  386. }
  387. EXPORT_SYMBOL(mdiobus_write_nested);
  388. /**
  389. * mdiobus_write - Convenience function for writing a given MII mgmt register
  390. * @bus: the mii_bus struct
  391. * @addr: the phy address
  392. * @regnum: register number to write
  393. * @val: value to write to @regnum
  394. *
  395. * NOTE: MUST NOT be called from interrupt context,
  396. * because the bus read/write functions may wait for an interrupt
  397. * to conclude the operation.
  398. */
  399. int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val)
  400. {
  401. int err;
  402. BUG_ON(in_interrupt());
  403. mutex_lock(&bus->mdio_lock);
  404. err = bus->write(bus, addr, regnum, val);
  405. mutex_unlock(&bus->mdio_lock);
  406. return err;
  407. }
  408. EXPORT_SYMBOL(mdiobus_write);
  409. /**
  410. * mdio_bus_match - determine if given PHY driver supports the given PHY device
  411. * @dev: target PHY device
  412. * @drv: given PHY driver
  413. *
  414. * Description: Given a PHY device, and a PHY driver, return 1 if
  415. * the driver supports the device. Otherwise, return 0.
  416. */
  417. static int mdio_bus_match(struct device *dev, struct device_driver *drv)
  418. {
  419. struct phy_device *phydev = to_phy_device(dev);
  420. struct phy_driver *phydrv = to_phy_driver(drv);
  421. const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids);
  422. int i;
  423. if (of_driver_match_device(dev, drv))
  424. return 1;
  425. if (phydrv->match_phy_device)
  426. return phydrv->match_phy_device(phydev);
  427. if (phydev->is_c45) {
  428. for (i = 1; i < num_ids; i++) {
  429. if (!(phydev->c45_ids.devices_in_package & (1 << i)))
  430. continue;
  431. if ((phydrv->phy_id & phydrv->phy_id_mask) ==
  432. (phydev->c45_ids.device_ids[i] &
  433. phydrv->phy_id_mask))
  434. return 1;
  435. }
  436. return 0;
  437. } else {
  438. return (phydrv->phy_id & phydrv->phy_id_mask) ==
  439. (phydev->phy_id & phydrv->phy_id_mask);
  440. }
  441. }
  442. #ifdef CONFIG_PM
  443. static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
  444. {
  445. struct device_driver *drv = phydev->dev.driver;
  446. struct phy_driver *phydrv = to_phy_driver(drv);
  447. struct net_device *netdev = phydev->attached_dev;
  448. if (!drv || !phydrv->suspend)
  449. return false;
  450. /* PHY not attached? May suspend if the PHY has not already been
  451. * suspended as part of a prior call to phy_disconnect() ->
  452. * phy_detach() -> phy_suspend() because the parent netdev might be the
  453. * MDIO bus driver and clock gated at this point.
  454. */
  455. if (!netdev)
  456. return !phydev->suspended;
  457. /* Don't suspend PHY if the attched netdev parent may wakeup.
  458. * The parent may point to a PCI device, as in tg3 driver.
  459. */
  460. if (netdev->dev.parent && device_may_wakeup(netdev->dev.parent))
  461. return false;
  462. /* Also don't suspend PHY if the netdev itself may wakeup. This
  463. * is the case for devices w/o underlaying pwr. mgmt. aware bus,
  464. * e.g. SoC devices.
  465. */
  466. if (device_may_wakeup(&netdev->dev))
  467. return false;
  468. return true;
  469. }
  470. static int mdio_bus_suspend(struct device *dev)
  471. {
  472. struct phy_device *phydev = to_phy_device(dev);
  473. /* We must stop the state machine manually, otherwise it stops out of
  474. * control, possibly with the phydev->lock held. Upon resume, netdev
  475. * may call phy routines that try to grab the same lock, and that may
  476. * lead to a deadlock.
  477. */
  478. if (phydev->attached_dev && phydev->adjust_link)
  479. phy_stop_machine(phydev);
  480. if (!mdio_bus_phy_may_suspend(phydev))
  481. return 0;
  482. return phy_suspend(phydev);
  483. }
  484. static int mdio_bus_resume(struct device *dev)
  485. {
  486. struct phy_device *phydev = to_phy_device(dev);
  487. int ret;
  488. if (!mdio_bus_phy_may_suspend(phydev))
  489. goto no_resume;
  490. ret = phy_resume(phydev);
  491. if (ret < 0)
  492. return ret;
  493. no_resume:
  494. if (phydev->attached_dev && phydev->adjust_link)
  495. phy_start_machine(phydev);
  496. return 0;
  497. }
  498. static int mdio_bus_restore(struct device *dev)
  499. {
  500. struct phy_device *phydev = to_phy_device(dev);
  501. struct net_device *netdev = phydev->attached_dev;
  502. int ret;
  503. if (!netdev)
  504. return 0;
  505. ret = phy_init_hw(phydev);
  506. if (ret < 0)
  507. return ret;
  508. /* The PHY needs to renegotiate. */
  509. phydev->link = 0;
  510. phydev->state = PHY_UP;
  511. phy_start_machine(phydev);
  512. return 0;
  513. }
  514. static const struct dev_pm_ops mdio_bus_pm_ops = {
  515. .suspend = mdio_bus_suspend,
  516. .resume = mdio_bus_resume,
  517. .freeze = mdio_bus_suspend,
  518. .thaw = mdio_bus_resume,
  519. .restore = mdio_bus_restore,
  520. };
  521. #define MDIO_BUS_PM_OPS (&mdio_bus_pm_ops)
  522. #else
  523. #define MDIO_BUS_PM_OPS NULL
  524. #endif /* CONFIG_PM */
  525. static ssize_t
  526. phy_id_show(struct device *dev, struct device_attribute *attr, char *buf)
  527. {
  528. struct phy_device *phydev = to_phy_device(dev);
  529. return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id);
  530. }
  531. static DEVICE_ATTR_RO(phy_id);
  532. static ssize_t
  533. phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
  534. {
  535. struct phy_device *phydev = to_phy_device(dev);
  536. const char *mode = NULL;
  537. if (phy_is_internal(phydev))
  538. mode = "internal";
  539. else
  540. mode = phy_modes(phydev->interface);
  541. return sprintf(buf, "%s\n", mode);
  542. }
  543. static DEVICE_ATTR_RO(phy_interface);
  544. static ssize_t
  545. phy_has_fixups_show(struct device *dev, struct device_attribute *attr, char *buf)
  546. {
  547. struct phy_device *phydev = to_phy_device(dev);
  548. return sprintf(buf, "%d\n", phydev->has_fixups);
  549. }
  550. static DEVICE_ATTR_RO(phy_has_fixups);
  551. static struct attribute *mdio_dev_attrs[] = {
  552. &dev_attr_phy_id.attr,
  553. &dev_attr_phy_interface.attr,
  554. &dev_attr_phy_has_fixups.attr,
  555. NULL,
  556. };
  557. ATTRIBUTE_GROUPS(mdio_dev);
  558. struct bus_type mdio_bus_type = {
  559. .name = "mdio_bus",
  560. .match = mdio_bus_match,
  561. .pm = MDIO_BUS_PM_OPS,
  562. .dev_groups = mdio_dev_groups,
  563. };
  564. EXPORT_SYMBOL(mdio_bus_type);
  565. int __init mdio_bus_init(void)
  566. {
  567. int ret;
  568. ret = class_register(&mdio_bus_class);
  569. if (!ret) {
  570. ret = bus_register(&mdio_bus_type);
  571. if (ret)
  572. class_unregister(&mdio_bus_class);
  573. }
  574. return ret;
  575. }
  576. void mdio_bus_exit(void)
  577. {
  578. class_unregister(&mdio_bus_class);
  579. bus_unregister(&mdio_bus_type);
  580. }