@@ -56,7 +56,7 @@ struct at91_reset {
56
56
struct notifier_block nb ;
57
57
};
58
58
59
- static struct at91_reset reset ;
59
+ static struct at91_reset * reset ;
60
60
61
61
/*
62
62
* unless the SDRAM is cleanly shutdown before we hit the
@@ -81,8 +81,8 @@ static int at91sam9260_restart(struct notifier_block *this, unsigned long mode,
81
81
82
82
"b .\n\t"
83
83
:
84
- : "r" (reset . ramc_base [0 ]),
85
- "r" (reset . rstc_base ),
84
+ : "r" (reset -> ramc_base [0 ]),
85
+ "r" (reset -> rstc_base ),
86
86
"r" (1 ),
87
87
"r" cpu_to_le32 (AT91_SDRAMC_LPCB_POWER_DOWN ),
88
88
"r" cpu_to_le32 (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST ));
@@ -123,9 +123,9 @@ static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode,
123
123
124
124
" b .\n\t"
125
125
:
126
- : "r" (reset . ramc_base [0 ]),
127
- "r" (reset . ramc_base [1 ]),
128
- "r" (reset . rstc_base ),
126
+ : "r" (reset -> ramc_base [0 ]),
127
+ "r" (reset -> ramc_base [1 ]),
128
+ "r" (reset -> rstc_base ),
129
129
"r" (1 ),
130
130
"r" cpu_to_le32 (AT91_DDRSDRC_LPCB_POWER_DOWN ),
131
131
"r" cpu_to_le32 (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST )
@@ -138,7 +138,7 @@ static int sama5d3_restart(struct notifier_block *this, unsigned long mode,
138
138
void * cmd )
139
139
{
140
140
writel (cpu_to_le32 (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST ),
141
- reset . rstc_base );
141
+ reset -> rstc_base );
142
142
143
143
return NOTIFY_DONE ;
144
144
}
@@ -147,15 +147,15 @@ static int samx7_restart(struct notifier_block *this, unsigned long mode,
147
147
void * cmd )
148
148
{
149
149
writel (cpu_to_le32 (AT91_RSTC_KEY | AT91_RSTC_PROCRST ),
150
- reset . rstc_base );
150
+ reset -> rstc_base );
151
151
152
152
return NOTIFY_DONE ;
153
153
}
154
154
155
155
static void __init at91_reset_status (struct platform_device * pdev )
156
156
{
157
157
const char * reason ;
158
- u32 reg = readl (reset . rstc_base + AT91_RSTC_SR );
158
+ u32 reg = readl (reset -> rstc_base + AT91_RSTC_SR );
159
159
160
160
switch ((reg & AT91_RSTC_RSTTYP ) >> 8 ) {
161
161
case RESET_TYPE_GENERAL :
@@ -212,17 +212,21 @@ static int __init at91_reset_probe(struct platform_device *pdev)
212
212
struct device_node * np ;
213
213
int ret , idx = 0 ;
214
214
215
- reset .rstc_base = of_iomap (pdev -> dev .of_node , 0 );
216
- if (!reset .rstc_base ) {
215
+ reset = devm_kzalloc (& pdev -> dev , sizeof (* reset ), GFP_KERNEL );
216
+ if (!reset )
217
+ return - ENOMEM ;
218
+
219
+ reset -> rstc_base = of_iomap (pdev -> dev .of_node , 0 );
220
+ if (!reset -> rstc_base ) {
217
221
dev_err (& pdev -> dev , "Could not map reset controller address\n" );
218
222
return - ENODEV ;
219
223
}
220
224
221
225
if (!of_device_is_compatible (pdev -> dev .of_node , "atmel,sama5d3-rstc" )) {
222
226
/* we need to shutdown the ddr controller, so get ramc base */
223
227
for_each_matching_node (np , at91_ramc_of_match ) {
224
- reset . ramc_base [idx ] = of_iomap (np , 0 );
225
- if (!reset . ramc_base [idx ]) {
228
+ reset -> ramc_base [idx ] = of_iomap (np , 0 );
229
+ if (!reset -> ramc_base [idx ]) {
226
230
dev_err (& pdev -> dev , "Could not map ram controller address\n" );
227
231
of_node_put (np );
228
232
return - ENODEV ;
@@ -232,22 +236,22 @@ static int __init at91_reset_probe(struct platform_device *pdev)
232
236
}
233
237
234
238
match = of_match_node (at91_reset_of_match , pdev -> dev .of_node );
235
- reset . nb .notifier_call = match -> data ;
236
- reset . nb .priority = 192 ;
239
+ reset -> nb .notifier_call = match -> data ;
240
+ reset -> nb .priority = 192 ;
237
241
238
- reset . sclk = devm_clk_get (& pdev -> dev , NULL );
239
- if (IS_ERR (reset . sclk ))
240
- return PTR_ERR (reset . sclk );
242
+ reset -> sclk = devm_clk_get (& pdev -> dev , NULL );
243
+ if (IS_ERR (reset -> sclk ))
244
+ return PTR_ERR (reset -> sclk );
241
245
242
- ret = clk_prepare_enable (reset . sclk );
246
+ ret = clk_prepare_enable (reset -> sclk );
243
247
if (ret ) {
244
248
dev_err (& pdev -> dev , "Could not enable slow clock\n" );
245
249
return ret ;
246
250
}
247
251
248
- ret = register_restart_handler (& reset . nb );
252
+ ret = register_restart_handler (& reset -> nb );
249
253
if (ret ) {
250
- clk_disable_unprepare (reset . sclk );
254
+ clk_disable_unprepare (reset -> sclk );
251
255
return ret ;
252
256
}
253
257
@@ -258,8 +262,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
258
262
259
263
static int __exit at91_reset_remove (struct platform_device * pdev )
260
264
{
261
- unregister_restart_handler (& reset . nb );
262
- clk_disable_unprepare (reset . sclk );
265
+ unregister_restart_handler (& reset -> nb );
266
+ clk_disable_unprepare (reset -> sclk );
263
267
264
268
return 0 ;
265
269
}
0 commit comments