1 From 34722924d416c3521de2bc8d10dfcd07a55135ea Mon Sep 17 00:00:00 2001
2 From: Chen-Yu Tsai <wens@csie.org>
3 Date: Sat, 7 Dec 2013 01:29:36 +0800
4 Subject: [PATCH] net: stmmac: Use platform data tied with compatible strings
6 Signed-off-by: Chen-Yu Tsai <wens@csie.org>
8 .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 29 ++++++++++++++--------
9 1 file changed, 19 insertions(+), 10 deletions(-)
11 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
12 index 74c7aef..df3fd1c 100644
13 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
14 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
18 #include <linux/of_net.h>
19 +#include <linux/of_device.h>
22 +static const struct of_device_id stmmac_dt_ids[] = {
23 + { .compatible = "st,spear600-gmac"},
24 + { .compatible = "snps,dwmac-3.610"},
25 + { .compatible = "snps,dwmac-3.70a"},
26 + { .compatible = "snps,dwmac-3.710"},
27 + { .compatible = "snps,dwmac"},
30 +MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
33 static int stmmac_probe_config_dt(struct platform_device *pdev,
34 struct plat_stmmacenet_data *plat,
35 @@ -35,10 +46,18 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
37 struct device_node *np = pdev->dev.of_node;
38 struct stmmac_dma_cfg *dma_cfg;
39 + const struct of_device_id *device;
44 + device = of_match_device(stmmac_dt_ids, &pdev->dev);
49 + memcpy(plat, device->data, sizeof(*plat));
51 *mac = of_get_mac_address(np);
52 plat->interface = of_get_phy_mode(np);
54 @@ -257,16 +276,6 @@ int stmmac_pltfr_restore(struct device *dev)
55 static const struct dev_pm_ops stmmac_pltfr_pm_ops;
56 #endif /* CONFIG_PM */
58 -static const struct of_device_id stmmac_dt_ids[] = {
59 - { .compatible = "st,spear600-gmac"},
60 - { .compatible = "snps,dwmac-3.610"},
61 - { .compatible = "snps,dwmac-3.70a"},
62 - { .compatible = "snps,dwmac-3.710"},
63 - { .compatible = "snps,dwmac"},
66 -MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
68 struct platform_driver stmmac_pltfr_driver = {
69 .probe = stmmac_pltfr_probe,
70 .remove = stmmac_pltfr_remove,