0179-phy-phy-mtk-tphy-use-of_device_get_match_data.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 3e53007a55e70d5036a527900befecf9a6316d05 Mon Sep 17 00:00:00 2001
  2. From: Chunfeng Yun <[email protected]>
  3. Date: Thu, 28 Dec 2017 16:40:36 +0530
  4. Subject: [PATCH 179/224] phy: phy-mtk-tphy: use of_device_get_match_data()
  5. reduce the boilerplate code to get the specific data
  6. Signed-off-by: Chunfeng Yun <[email protected]>
  7. Signed-off-by: Kishon Vijay Abraham I <[email protected]>
  8. ---
  9. drivers/phy/mediatek/phy-mtk-tphy.c | 11 +++++------
  10. 1 file changed, 5 insertions(+), 6 deletions(-)
  11. --- a/drivers/phy/mediatek/phy-mtk-tphy.c
  12. +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
  13. @@ -20,6 +20,7 @@
  14. #include <linux/iopoll.h>
  15. #include <linux/module.h>
  16. #include <linux/of_address.h>
  17. +#include <linux/of_device.h>
  18. #include <linux/phy/phy.h>
  19. #include <linux/platform_device.h>
  20. @@ -995,7 +996,6 @@ MODULE_DEVICE_TABLE(of, mtk_tphy_id_tabl
  21. static int mtk_tphy_probe(struct platform_device *pdev)
  22. {
  23. - const struct of_device_id *match;
  24. struct device *dev = &pdev->dev;
  25. struct device_node *np = dev->of_node;
  26. struct device_node *child_np;
  27. @@ -1005,15 +1005,14 @@ static int mtk_tphy_probe(struct platfor
  28. struct resource res;
  29. int port, retval;
  30. - match = of_match_node(mtk_tphy_id_table, pdev->dev.of_node);
  31. - if (!match)
  32. - return -EINVAL;
  33. -
  34. tphy = devm_kzalloc(dev, sizeof(*tphy), GFP_KERNEL);
  35. if (!tphy)
  36. return -ENOMEM;
  37. - tphy->pdata = match->data;
  38. + tphy->pdata = of_device_get_match_data(dev);
  39. + if (!tphy->pdata)
  40. + return -EINVAL;
  41. +
  42. tphy->nphys = of_get_child_count(np);
  43. tphy->phys = devm_kcalloc(dev, tphy->nphys,
  44. sizeof(*tphy->phys), GFP_KERNEL);