0045-net-dsa-mediatek-turn-into-platform-driver.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 1e33784f665cb95c2af5481d3e776d2d3099921b Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Thu, 10 Aug 2017 15:57:17 +0200
  4. Subject: [PATCH 45/57] net: dsa: mediatek: turn into platform driver
  5. Signed-off-by: John Crispin <[email protected]>
  6. ---
  7. drivers/net/dsa/mt7530.c | 23 +++++++++++++++--------
  8. 1 file changed, 15 insertions(+), 8 deletions(-)
  9. --- a/drivers/net/dsa/mt7530.c
  10. +++ b/drivers/net/dsa/mt7530.c
  11. @@ -1049,10 +1049,10 @@ static const struct dsa_switch_ops mt753
  12. };
  13. static int
  14. -mt7530_probe(struct mdio_device *mdiodev)
  15. +mt7530_probe(struct platform_device *mdiodev)
  16. {
  17. struct mt7530_priv *priv;
  18. - struct device_node *dn;
  19. + struct device_node *dn, *mdio;
  20. dn = mdiodev->dev.of_node;
  21. @@ -1100,7 +1100,12 @@ mt7530_probe(struct mdio_device *mdiodev
  22. }
  23. }
  24. - priv->bus = mdiodev->bus;
  25. + mdio = of_parse_phandle(dn, "dsa,mii-bus", 0);
  26. + if (!mdio)
  27. + return -EINVAL;
  28. + priv->bus = of_mdio_find_bus(mdio);
  29. + if (!priv->bus)
  30. + return -EPROBE_DEFER;
  31. priv->dev = &mdiodev->dev;
  32. priv->ds->priv = priv;
  33. priv->ds->ops = &mt7530_switch_ops;
  34. @@ -1110,8 +1115,8 @@ mt7530_probe(struct mdio_device *mdiodev
  35. return dsa_register_switch(priv->ds);
  36. }
  37. -static void
  38. -mt7530_remove(struct mdio_device *mdiodev)
  39. +static int
  40. +mt7530_remove(struct platform_device *mdiodev)
  41. {
  42. struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
  43. int ret = 0;
  44. @@ -1128,6 +1133,8 @@ mt7530_remove(struct mdio_device *mdiode
  45. dsa_unregister_switch(priv->ds);
  46. mutex_destroy(&priv->reg_mutex);
  47. +
  48. + return 0;
  49. }
  50. static const struct of_device_id mt7530_of_match[] = {
  51. @@ -1136,16 +1143,16 @@ static const struct of_device_id mt7530_
  52. };
  53. MODULE_DEVICE_TABLE(of, mt7530_of_match);
  54. -static struct mdio_driver mt7530_mdio_driver = {
  55. +static struct platform_driver mtk_mt7530_driver = {
  56. .probe = mt7530_probe,
  57. .remove = mt7530_remove,
  58. - .mdiodrv.driver = {
  59. + .driver = {
  60. .name = "mt7530",
  61. .of_match_table = mt7530_of_match,
  62. },
  63. };
  64. +module_platform_driver(mtk_mt7530_driver);
  65. -mdio_module_driver(mt7530_mdio_driver);
  66. MODULE_AUTHOR("Sean Wang <[email protected]>");
  67. MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch");