950-add-boardinfo-platform-data.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --- a/drivers/net/phy/mdio-boardinfo.c
  2. +++ b/drivers/net/phy/mdio-boardinfo.c
  3. @@ -15,8 +15,11 @@
  4. #include "mdio-boardinfo.h"
  5. -static LIST_HEAD(mdio_board_list);
  6. -static DEFINE_MUTEX(mdio_board_lock);
  7. +LIST_HEAD(mdio_board_list);
  8. +EXPORT_SYMBOL_GPL(mdio_board_list);
  9. +
  10. +DEFINE_MUTEX(mdio_board_lock);
  11. +EXPORT_SYMBOL_GPL(mdio_board_lock);
  12. /**
  13. * mdiobus_setup_mdiodev_from_board_info - create and setup MDIO devices
  14. --- a/drivers/net/phy/mdio-boardinfo.h
  15. +++ b/drivers/net/phy/mdio-boardinfo.h
  16. @@ -20,4 +20,7 @@ void mdiobus_setup_mdiodev_from_board_in
  17. (struct mii_bus *bus,
  18. struct mdio_board_info *bi));
  19. +extern struct mutex mdio_board_lock;
  20. +extern struct list_head mdio_board_list;
  21. +
  22. #endif /* __MDIO_BOARD_INFO_H */
  23. --- a/drivers/net/phy/mdio_bus.c
  24. +++ b/drivers/net/phy/mdio_bus.c
  25. @@ -455,6 +455,17 @@ void mdiobus_free(struct mii_bus *bus)
  26. }
  27. EXPORT_SYMBOL(mdiobus_free);
  28. +static void mdiobus_setup_phydev_from_boardinfo(struct mii_bus *bus,
  29. + struct phy_device *phydev,
  30. + struct mdio_board_info *bi)
  31. +{
  32. + if (strcmp(bus->id, bi->bus_id) ||
  33. + bi->mdio_addr != phydev->mdio.addr)
  34. + return;
  35. +
  36. + phydev->mdio.dev.platform_data = (void *) bi->platform_data;
  37. +}
  38. +
  39. /**
  40. * mdiobus_scan - scan a bus for MDIO devices.
  41. * @bus: mii_bus to scan
  42. @@ -470,6 +481,7 @@ EXPORT_SYMBOL(mdiobus_free);
  43. struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
  44. {
  45. struct phy_device *phydev;
  46. + struct mdio_board_entry *be;
  47. int err;
  48. phydev = get_phy_device(bus, addr, false);
  49. @@ -482,6 +494,12 @@ struct phy_device *mdiobus_scan(struct m
  50. */
  51. of_mdiobus_link_mdiodev(bus, &phydev->mdio);
  52. + mutex_lock(&mdio_board_lock);
  53. + list_for_each_entry(be, &mdio_board_list, list)
  54. + mdiobus_setup_phydev_from_boardinfo(bus, phydev,
  55. + &be->board_info);
  56. + mutex_unlock(&mdio_board_lock);
  57. +
  58. err = phy_device_register(phydev);
  59. if (err) {
  60. phy_device_free(phydev);