kernel: bgmac: move other bgmac patches to generic
[oweals/openwrt.git] / target / linux / brcm47xx / patches-3.10 / 262-MIPS-BCM47XX-use-init-const-in-board-detect.patch
1 --- a/arch/mips/bcm47xx/board.c
2 +++ b/arch/mips/bcm47xx/board.c
3 @@ -26,27 +26,36 @@ struct bcm47xx_board_type_list3 {
4         const char *value3;
5  };
6  
7 +struct bcm47xx_board_store {
8 +       enum bcm47xx_board board;
9 +       char name[BCM47XX_BOARD_MAX_NAME];
10 +};
11 +
12  /* model_name */
13 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_model_name[] = {
14 +static const
15 +struct bcm47xx_board_type_list1 bcm47xx_board_list_model_name[] __initconst = {
16         {{BCM47XX_BOARD_DLINK_DIR130, "D-Link DIR-130"}, "DIR-130"},
17         {{BCM47XX_BOARD_DLINK_DIR330, "D-Link DIR-330"}, "DIR-330"},
18         { {0}, 0},
19  };
20  
21  /* model_no */
22 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_model_no[] = {
23 +static const
24 +struct bcm47xx_board_type_list1 bcm47xx_board_list_model_no[] __initconst = {
25         {{BCM47XX_BOARD_ASUS_WL700GE, "Asus WL700"}, "WL700"},
26         { {0}, 0},
27  };
28  
29  /* machine_name */
30 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_machine_name[] = {
31 +static const
32 +struct bcm47xx_board_type_list1 bcm47xx_board_list_machine_name[] __initconst = {
33         {{BCM47XX_BOARD_LINKSYS_WRTSL54GS, "Linksys WRTSL54GS"}, "WRTSL54GS"},
34         { {0}, 0},
35  };
36  
37  /* hardware_version */
38 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_hardware_version[] = {
39 +static const
40 +struct bcm47xx_board_type_list1 bcm47xx_board_list_hardware_version[] __initconst = {
41         {{BCM47XX_BOARD_ASUS_RTN16, "Asus RT-N16"}, "RT-N16-"},
42         {{BCM47XX_BOARD_ASUS_WL320GE, "Asus WL320GE"}, "WL320G-"},
43         {{BCM47XX_BOARD_ASUS_WL330GE, "Asus WL330GE"}, "WL330GE-"},
44 @@ -61,7 +70,8 @@ static const struct bcm47xx_board_type_l
45  };
46  
47  /* productid */
48 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] = {
49 +static const
50 +struct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] __initconst = {
51         {{BCM47XX_BOARD_ASUS_RTAC66U, "Asus RT-AC66U"}, "RT-AC66U"},
52         {{BCM47XX_BOARD_ASUS_RTN10, "Asus RT-N10"}, "RT-N10"},
53         {{BCM47XX_BOARD_ASUS_RTN10D, "Asus RT-N10D"}, "RT-N10D"},
54 @@ -81,7 +91,8 @@ static const struct bcm47xx_board_type_l
55  };
56  
57  /* ModelId */
58 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_ModelId[] = {
59 +static const
60 +struct bcm47xx_board_type_list1 bcm47xx_board_list_ModelId[] __initconst = {
61         {{BCM47XX_BOARD_DELL_TM2300, "Dell WX-5565"}, "WX-5565"},
62         {{BCM47XX_BOARD_MOTOROLA_WE800G, "Motorola WE800G"}, "WE800G"},
63         {{BCM47XX_BOARD_MOTOROLA_WR850GP, "Motorola WR850GP"}, "WR850GP"},
64 @@ -90,7 +101,8 @@ static const struct bcm47xx_board_type_l
65  };
66  
67  /* melco_id or buf1falo_id */
68 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_melco_id[] = {
69 +static const
70 +struct bcm47xx_board_type_list1 bcm47xx_board_list_melco_id[] __initconst = {
71         {{BCM47XX_BOARD_BUFFALO_WBR2_G54, "Buffalo WBR2-G54"}, "29bb0332"},
72         {{BCM47XX_BOARD_BUFFALO_WHR2_A54G54, "Buffalo WHR2-A54G54"}, "290441dd"},
73         {{BCM47XX_BOARD_BUFFALO_WHR_G125, "Buffalo WHR-G125"}, "32093"},
74 @@ -104,7 +116,8 @@ static const struct bcm47xx_board_type_l
75  };
76  
77  /* boot_hw_model, boot_hw_ver */
78 -static const struct bcm47xx_board_type_list2 bcm47xx_board_list_boot_hw[] = {
79 +static const
80 +struct bcm47xx_board_type_list2 bcm47xx_board_list_boot_hw[] __initconst = {
81         /* like WRT160N v3.0 */
82         {{BCM47XX_BOARD_CISCO_M10V1, "Cisco M10"}, "M10", "1.0"},
83         /* like WRT310N v2.0 */
84 @@ -134,7 +147,8 @@ static const struct bcm47xx_board_type_l
85  };
86  
87  /* board_id */
88 -static const struct bcm47xx_board_type_list1 bcm47xx_board_list_board_id[] = {
89 +static const
90 +struct bcm47xx_board_type_list1 bcm47xx_board_list_board_id[] __initconst = {
91         {{BCM47XX_BOARD_NETGEAR_WGR614V8, "Netgear WGR614 V8"}, "U12H072T00_NETGEAR"},
92         {{BCM47XX_BOARD_NETGEAR_WGR614V9, "Netgear WGR614 V9"}, "U12H094T00_NETGEAR"},
93         {{BCM47XX_BOARD_NETGEAR_WNDR3300, "Netgear WNDR3300"}, "U12H093T00_NETGEAR"},
94 @@ -155,24 +169,22 @@ static const struct bcm47xx_board_type_l
95  };
96  
97  /* boardtype, boardnum, boardrev */
98 -static const struct bcm47xx_board_type_list3 bcm47xx_board_list_board[] = {
99 +static const
100 +struct bcm47xx_board_type_list3 bcm47xx_board_list_board[] __initconst = {
101         {{BCM47XX_BOARD_HUAWEI_E970, "Huawei E970"}, "0x048e", "0x5347", "0x11"},
102         {{BCM47XX_BOARD_PHICOMM_M1, "Phicomm M1"}, "0x0590", "80", "0x1104"},
103         {{BCM47XX_BOARD_ZTE_H218N, "ZTE H218N"}, "0x053d", "1234", "0x1305"},
104         { {0}, 0},
105  };
106  
107 -static const struct bcm47xx_board_type bcm47xx_board_unknown[] = {
108 +static const
109 +struct bcm47xx_board_type bcm47xx_board_unknown[] __initconst = {
110         {BCM47XX_BOARD_UNKNOWN, "Unknown Board"},
111  };
112  
113 -static const struct bcm47xx_board_type bcm47xx_board_no[] = {
114 -       {BCM47XX_BOARD_NO, "No Board"},
115 -};
116 -
117 -static const struct bcm47xx_board_type *bcm47xx_board = bcm47xx_board_no;
118 +static struct bcm47xx_board_store bcm47xx_board = {BCM47XX_BOARD_NO, "Unknown Board"};
119  
120 -static const struct bcm47xx_board_type *bcm47xx_board_get_nvram(void)
121 +static __init const struct bcm47xx_board_type *bcm47xx_board_get_nvram(void)
122  {
123         char buf1[30];
124         char buf2[30];
125 @@ -261,12 +273,13 @@ static const struct bcm47xx_board_type *
126         return bcm47xx_board_unknown;
127  }
128  
129 -static void bcm47xx_board_detect(void)
130 +void __init bcm47xx_board_detect(void)
131  {
132         int err;
133         char buf[10];
134 +       const struct bcm47xx_board_type *board_detected;
135  
136 -       if (bcm47xx_board != bcm47xx_board_no)
137 +       if (bcm47xx_board.board != BCM47XX_BOARD_NO)
138                 return;
139  
140         /* check if the nvram is available */
141 @@ -277,20 +290,20 @@ static void bcm47xx_board_detect(void)
142                 return;
143         }
144  
145 -       bcm47xx_board = bcm47xx_board_get_nvram();
146 -       pr_debug("Found board: \"%s\"\n", bcm47xx_board->name);
147 +       board_detected = bcm47xx_board_get_nvram();
148 +       bcm47xx_board.board = board_detected->board;
149 +       strncpy(bcm47xx_board.name, board_detected->name, BCM47XX_BOARD_MAX_NAME);
150 +       bcm47xx_board.name[BCM47XX_BOARD_MAX_NAME - 1] = 0;
151  }
152  
153  enum bcm47xx_board bcm47xx_board_get(void)
154  {
155 -       bcm47xx_board_detect();
156 -       return bcm47xx_board->board;
157 +       return bcm47xx_board.board;
158  }
159  EXPORT_SYMBOL(bcm47xx_board_get);
160  
161  const char *bcm47xx_board_get_name(void)
162  {
163 -       bcm47xx_board_detect();
164 -       return bcm47xx_board->name;
165 +       return bcm47xx_board.name;
166  }
167  EXPORT_SYMBOL(bcm47xx_board_get_name);
168 --- a/arch/mips/bcm47xx/setup.c
169 +++ b/arch/mips/bcm47xx/setup.c
170 @@ -252,6 +252,7 @@ void __init plat_mem_setup(void)
171         _machine_restart = bcm47xx_machine_restart;
172         _machine_halt = bcm47xx_machine_halt;
173         pm_power_off = bcm47xx_machine_halt;
174 +       bcm47xx_board_detect();
175  }
176  
177  static int __init bcm47xx_register_bus_complete(void)
178 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
179 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
180 @@ -101,6 +101,9 @@ enum bcm47xx_board {
181         BCM47XX_BOARD_NO,
182  };
183  
184 +#define BCM47XX_BOARD_MAX_NAME 30
185 +
186 +void bcm47xx_board_detect(void);
187  enum bcm47xx_board bcm47xx_board_get(void);
188  const char *bcm47xx_board_get_name(void);
189