kernel: add missing config symbols to 3.13
[openwrt.git] / target / linux / sunxi / patches-3.13 / 192-stmmac-use-platform-data-with-compat.patch
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
5
6 Signed-off-by: Chen-Yu Tsai <wens@csie.org>
7 ---
8  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 29 ++++++++++++++--------
9  1 file changed, 19 insertions(+), 10 deletions(-)
10
11 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
12 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
13 @@ -26,8 +26,19 @@
14  #include <linux/io.h>
15  #include <linux/of.h>
16  #include <linux/of_net.h>
17 +#include <linux/of_device.h>
18  #include "stmmac.h"
19  
20 +static const struct of_device_id stmmac_dt_ids[] = {
21 +       { .compatible = "st,spear600-gmac"},
22 +       { .compatible = "snps,dwmac-3.610"},
23 +       { .compatible = "snps,dwmac-3.70a"},
24 +       { .compatible = "snps,dwmac-3.710"},
25 +       { .compatible = "snps,dwmac"},
26 +       { /* sentinel */ }
27 +};
28 +MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
29 +
30  #ifdef CONFIG_OF
31  static int stmmac_probe_config_dt(struct platform_device *pdev,
32                                   struct plat_stmmacenet_data *plat,
33 @@ -35,10 +46,18 @@ static int stmmac_probe_config_dt(struct
34  {
35         struct device_node *np = pdev->dev.of_node;
36         struct stmmac_dma_cfg *dma_cfg;
37 +       const struct of_device_id *device;
38  
39         if (!np)
40                 return -ENODEV;
41  
42 +       device = of_match_device(stmmac_dt_ids, &pdev->dev);
43 +       if (!device)
44 +               return -ENODEV;
45 +
46 +       if (device->data)
47 +           memcpy(plat, device->data, sizeof(*plat));
48 +
49         *mac = of_get_mac_address(np);
50         plat->interface = of_get_phy_mode(np);
51  
52 @@ -257,16 +276,6 @@ static const struct dev_pm_ops stmmac_pl
53  static const struct dev_pm_ops stmmac_pltfr_pm_ops;
54  #endif /* CONFIG_PM */
55  
56 -static const struct of_device_id stmmac_dt_ids[] = {
57 -       { .compatible = "st,spear600-gmac"},
58 -       { .compatible = "snps,dwmac-3.610"},
59 -       { .compatible = "snps,dwmac-3.70a"},
60 -       { .compatible = "snps,dwmac-3.710"},
61 -       { .compatible = "snps,dwmac"},
62 -       { /* sentinel */ }
63 -};
64 -MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
65 -
66  struct platform_driver stmmac_pltfr_driver = {
67         .probe = stmmac_pltfr_probe,
68         .remove = stmmac_pltfr_remove,