Skip to content

Commit b7967b7

Browse files
claudiubezneasre
authored andcommitted
power: reset: at91-reset: convert reset in pointer to struct at91_reset
Convert reset in pointer to struct at91_reset. Signed-off-by: Claudiu Beznea <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 1e3c4af commit b7967b7

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

drivers/power/reset/at91-reset.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct at91_reset {
5656
struct notifier_block nb;
5757
};
5858

59-
static struct at91_reset reset;
59+
static struct at91_reset *reset;
6060

6161
/*
6262
* 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,
8181

8282
"b .\n\t"
8383
:
84-
: "r" (reset.ramc_base[0]),
85-
"r" (reset.rstc_base),
84+
: "r" (reset->ramc_base[0]),
85+
"r" (reset->rstc_base),
8686
"r" (1),
8787
"r" cpu_to_le32(AT91_SDRAMC_LPCB_POWER_DOWN),
8888
"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,
123123

124124
" b .\n\t"
125125
:
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),
129129
"r" (1),
130130
"r" cpu_to_le32(AT91_DDRSDRC_LPCB_POWER_DOWN),
131131
"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,
138138
void *cmd)
139139
{
140140
writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST),
141-
reset.rstc_base);
141+
reset->rstc_base);
142142

143143
return NOTIFY_DONE;
144144
}
@@ -147,15 +147,15 @@ static int samx7_restart(struct notifier_block *this, unsigned long mode,
147147
void *cmd)
148148
{
149149
writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PROCRST),
150-
reset.rstc_base);
150+
reset->rstc_base);
151151

152152
return NOTIFY_DONE;
153153
}
154154

155155
static void __init at91_reset_status(struct platform_device *pdev)
156156
{
157157
const char *reason;
158-
u32 reg = readl(reset.rstc_base + AT91_RSTC_SR);
158+
u32 reg = readl(reset->rstc_base + AT91_RSTC_SR);
159159

160160
switch ((reg & AT91_RSTC_RSTTYP) >> 8) {
161161
case RESET_TYPE_GENERAL:
@@ -212,17 +212,21 @@ static int __init at91_reset_probe(struct platform_device *pdev)
212212
struct device_node *np;
213213
int ret, idx = 0;
214214

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) {
217221
dev_err(&pdev->dev, "Could not map reset controller address\n");
218222
return -ENODEV;
219223
}
220224

221225
if (!of_device_is_compatible(pdev->dev.of_node, "atmel,sama5d3-rstc")) {
222226
/* we need to shutdown the ddr controller, so get ramc base */
223227
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]) {
226230
dev_err(&pdev->dev, "Could not map ram controller address\n");
227231
of_node_put(np);
228232
return -ENODEV;
@@ -232,22 +236,22 @@ static int __init at91_reset_probe(struct platform_device *pdev)
232236
}
233237

234238
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;
237241

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);
241245

242-
ret = clk_prepare_enable(reset.sclk);
246+
ret = clk_prepare_enable(reset->sclk);
243247
if (ret) {
244248
dev_err(&pdev->dev, "Could not enable slow clock\n");
245249
return ret;
246250
}
247251

248-
ret = register_restart_handler(&reset.nb);
252+
ret = register_restart_handler(&reset->nb);
249253
if (ret) {
250-
clk_disable_unprepare(reset.sclk);
254+
clk_disable_unprepare(reset->sclk);
251255
return ret;
252256
}
253257

@@ -258,8 +262,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
258262

259263
static int __exit at91_reset_remove(struct platform_device *pdev)
260264
{
261-
unregister_restart_handler(&reset.nb);
262-
clk_disable_unprepare(reset.sclk);
265+
unregister_restart_handler(&reset->nb);
266+
clk_disable_unprepare(reset->sclk);
263267

264268
return 0;
265269
}

0 commit comments

Comments
 (0)