192-stmmac-use-platform-data-with-compat.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From 34722924d416c3521de2bc8d10dfcd07a55135ea Mon Sep 17 00:00:00 2001
  2. From: Chen-Yu Tsai <[email protected]>
  3. Date: Sat, 7 Dec 2013 01:29:36 +0800
  4. Subject: [PATCH] net: stmmac: Use platform data tied with compatible strings
  5. Signed-off-by: Chen-Yu Tsai <[email protected]>
  6. ---
  7. .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 29 ++++++++++++++--------
  8. 1 file changed, 19 insertions(+), 10 deletions(-)
  9. --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
  10. +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
  11. @@ -26,8 +26,19 @@
  12. #include <linux/io.h>
  13. #include <linux/of.h>
  14. #include <linux/of_net.h>
  15. +#include <linux/of_device.h>
  16. #include "stmmac.h"
  17. +static const struct of_device_id stmmac_dt_ids[] = {
  18. + { .compatible = "st,spear600-gmac"},
  19. + { .compatible = "snps,dwmac-3.610"},
  20. + { .compatible = "snps,dwmac-3.70a"},
  21. + { .compatible = "snps,dwmac-3.710"},
  22. + { .compatible = "snps,dwmac"},
  23. + { /* sentinel */ }
  24. +};
  25. +MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
  26. +
  27. #ifdef CONFIG_OF
  28. static int stmmac_probe_config_dt(struct platform_device *pdev,
  29. struct plat_stmmacenet_data *plat,
  30. @@ -35,10 +46,18 @@ static int stmmac_probe_config_dt(struct
  31. {
  32. struct device_node *np = pdev->dev.of_node;
  33. struct stmmac_dma_cfg *dma_cfg;
  34. + const struct of_device_id *device;
  35. if (!np)
  36. return -ENODEV;
  37. + device = of_match_device(stmmac_dt_ids, &pdev->dev);
  38. + if (!device)
  39. + return -ENODEV;
  40. +
  41. + if (device->data)
  42. + memcpy(plat, device->data, sizeof(*plat));
  43. +
  44. *mac = of_get_mac_address(np);
  45. plat->interface = of_get_phy_mode(np);
  46. @@ -257,16 +276,6 @@ static const struct dev_pm_ops stmmac_pl
  47. static const struct dev_pm_ops stmmac_pltfr_pm_ops;
  48. #endif /* CONFIG_PM */
  49. -static const struct of_device_id stmmac_dt_ids[] = {
  50. - { .compatible = "st,spear600-gmac"},
  51. - { .compatible = "snps,dwmac-3.610"},
  52. - { .compatible = "snps,dwmac-3.70a"},
  53. - { .compatible = "snps,dwmac-3.710"},
  54. - { .compatible = "snps,dwmac"},
  55. - { /* sentinel */ }
  56. -};
  57. -MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
  58. -
  59. struct platform_driver stmmac_pltfr_driver = {
  60. .probe = stmmac_pltfr_probe,
  61. .remove = stmmac_pltfr_remove,