aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/mach-at32ap/clock.c
diff options
context:
space:
mode:
authorOle Henrik Jahren <olehenja@alumni.ntnu.no>2011-03-06 14:42:39 -0500
committerHans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>2011-04-13 09:46:52 -0400
commit6e2ad51190cdb11b364377882134513f60dec6b9 (patch)
treeea112778575ab257cb9d90638deec4bd676443a1 /arch/avr32/mach-at32ap/clock.c
parent51ef85d8f9ae24475a0cb1bd772258eafec91c69 (diff)
avr32: fix deadlock when reading clock list in debugfs
When writing out /sys/kernel/debug/at32ap_clk, clock list lock is being held while clk_get() is called. clk_get() attempts to take the same lock, which results in deadlock. Introduce and call lock free version, __clk_get(), instead. Signed-off-by: Ole Henrik Jahren <olehenja@alumni.ntnu.no> Cc: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Diffstat (limited to 'arch/avr32/mach-at32ap/clock.c')
-rw-r--r--arch/avr32/mach-at32ap/clock.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/arch/avr32/mach-at32ap/clock.c b/arch/avr32/mach-at32ap/clock.c
index 442f08c5e641..86925fd6ea5b 100644
--- a/arch/avr32/mach-at32ap/clock.c
+++ b/arch/avr32/mach-at32ap/clock.c
@@ -35,22 +35,30 @@ void at32_clk_register(struct clk *clk)
35 spin_unlock(&clk_list_lock); 35 spin_unlock(&clk_list_lock);
36} 36}
37 37
38struct clk *clk_get(struct device *dev, const char *id) 38static struct clk *__clk_get(struct device *dev, const char *id)
39{ 39{
40 struct clk *clk; 40 struct clk *clk;
41 41
42 spin_lock(&clk_list_lock);
43
44 list_for_each_entry(clk, &at32_clock_list, list) { 42 list_for_each_entry(clk, &at32_clock_list, list) {
45 if (clk->dev == dev && strcmp(id, clk->name) == 0) { 43 if (clk->dev == dev && strcmp(id, clk->name) == 0) {
46 spin_unlock(&clk_list_lock);
47 return clk; 44 return clk;
48 } 45 }
49 } 46 }
50 47
51 spin_unlock(&clk_list_lock);
52 return ERR_PTR(-ENOENT); 48 return ERR_PTR(-ENOENT);
53} 49}
50
51struct clk *clk_get(struct device *dev, const char *id)
52{
53 struct clk *clk;
54
55 spin_lock(&clk_list_lock);
56 clk = __clk_get(dev, id);
57 spin_unlock(&clk_list_lock);
58
59 return clk;
60}
61
54EXPORT_SYMBOL(clk_get); 62EXPORT_SYMBOL(clk_get);
55 63
56void clk_put(struct clk *clk) 64void clk_put(struct clk *clk)
@@ -257,15 +265,15 @@ static int clk_show(struct seq_file *s, void *unused)
257 spin_lock(&clk_list_lock); 265 spin_lock(&clk_list_lock);
258 266
259 /* show clock tree as derived from the three oscillators */ 267 /* show clock tree as derived from the three oscillators */
260 clk = clk_get(NULL, "osc32k"); 268 clk = __clk_get(NULL, "osc32k");
261 dump_clock(clk, &r); 269 dump_clock(clk, &r);
262 clk_put(clk); 270 clk_put(clk);
263 271
264 clk = clk_get(NULL, "osc0"); 272 clk = __clk_get(NULL, "osc0");
265 dump_clock(clk, &r); 273 dump_clock(clk, &r);
266 clk_put(clk); 274 clk_put(clk);
267 275
268 clk = clk_get(NULL, "osc1"); 276 clk = __clk_get(NULL, "osc1");
269 dump_clock(clk, &r); 277 dump_clock(clk, &r);
270 clk_put(clk); 278 clk_put(clk);
271 279