Skip to content

Commit 583ef88

Browse files
claudiubezneasre
authored andcommitted
power: reset: at91-reset: devm_kzalloc() for at91_reset data structure
Allocate at91_reset data on probe and set it as platform data. Signed-off-by: Claudiu Beznea <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 55f8e6f commit 583ef88

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/power/reset/at91-reset.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ struct at91_reset {
5656
struct notifier_block nb;
5757
};
5858

59-
static struct at91_reset *reset;
60-
6159
/*
6260
* unless the SDRAM is cleanly shutdown before we hit the
6361
* reset register it can be left driving the data bus and
@@ -66,6 +64,8 @@ static struct at91_reset *reset;
6664
static int at91sam9260_restart(struct notifier_block *this, unsigned long mode,
6765
void *cmd)
6866
{
67+
struct at91_reset *reset = container_of(this, struct at91_reset, nb);
68+
6969
asm volatile(
7070
/* Align to cache lines */
7171
".balign 32\n\t"
@@ -93,6 +93,8 @@ static int at91sam9260_restart(struct notifier_block *this, unsigned long mode,
9393
static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode,
9494
void *cmd)
9595
{
96+
struct at91_reset *reset = container_of(this, struct at91_reset, nb);
97+
9698
asm volatile(
9799
/*
98100
* Test wether we have a second RAM controller to care
@@ -137,6 +139,8 @@ static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode,
137139
static int sama5d3_restart(struct notifier_block *this, unsigned long mode,
138140
void *cmd)
139141
{
142+
struct at91_reset *reset = container_of(this, struct at91_reset, nb);
143+
140144
writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST),
141145
reset->rstc_base);
142146

@@ -146,6 +150,8 @@ static int sama5d3_restart(struct notifier_block *this, unsigned long mode,
146150
static int samx7_restart(struct notifier_block *this, unsigned long mode,
147151
void *cmd)
148152
{
153+
struct at91_reset *reset = container_of(this, struct at91_reset, nb);
154+
149155
writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PROCRST),
150156
reset->rstc_base);
151157

@@ -210,6 +216,7 @@ MODULE_DEVICE_TABLE(of, at91_reset_of_match);
210216
static int __init at91_reset_probe(struct platform_device *pdev)
211217
{
212218
const struct of_device_id *match;
219+
struct at91_reset *reset;
213220
struct device_node *np;
214221
int ret, idx = 0;
215222

@@ -250,6 +257,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
250257
return ret;
251258
}
252259

260+
platform_set_drvdata(pdev, reset);
261+
253262
ret = register_restart_handler(&reset->nb);
254263
if (ret) {
255264
clk_disable_unprepare(reset->sclk);
@@ -263,6 +272,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
263272

264273
static int __exit at91_reset_remove(struct platform_device *pdev)
265274
{
275+
struct at91_reset *reset = platform_get_drvdata(pdev);
276+
266277
unregister_restart_handler(&reset->nb);
267278
clk_disable_unprepare(reset->sclk);
268279

0 commit comments

Comments
 (0)