From: Ole Henrik Jahren <olehenja@alumni.ntnu.no>
To: kernel@avr32linux.org
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] avr32: fix deadlock when reading clock list in debugfs
Date: Sun, 12 Sep 2010 18:26:28 +0200 [thread overview]
Message-ID: <20100912162628.GA15423@siv> (raw)
From: Ole Henrik Jahren <olehenja@alumni.ntnu.no>
clk_show() already has clk_list_lock. Make a version of clk_get(),
clk_get_locked(), that does not attempt to take the lock a second time.
Signed-off-by: Ole Henrik Jahren <olehenja@alumni.ntnu.no>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
---
arch/avr32/mach-at32ap/clock.c | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/arch/avr32/mach-at32ap/clock.c b/arch/avr32/mach-at32ap/clock.c
index 442f08c..3951993 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)
spin_unlock(&clk_list_lock);
}
-struct clk *clk_get(struct device *dev, const char *id)
+static struct clk *__clk_get(struct device *dev, const char *id, int locked)
{
struct clk *clk;
- spin_lock(&clk_list_lock);
+ if (!locked)
+ spin_lock(&clk_list_lock);
list_for_each_entry(clk, &at32_clock_list, list) {
if (clk->dev == dev && strcmp(id, clk->name) == 0) {
- spin_unlock(&clk_list_lock);
+ if (!locked)
+ spin_unlock(&clk_list_lock);
return clk;
}
}
- spin_unlock(&clk_list_lock);
+ if (!locked)
+ spin_unlock(&clk_list_lock);
return ERR_PTR(-ENOENT);
}
+
+struct clk *clk_get(struct device *dev, const char *id)
+{
+ return __clk_get(dev, id, 0);
+}
EXPORT_SYMBOL(clk_get);
void clk_put(struct clk *clk)
@@ -227,6 +235,11 @@ dump_clock(struct clk *parent, struct clkinf *r)
r->nest = nest;
}
+static struct clk *clk_get_locked(struct device *dev, const char *id)
+{
+ return __clk_get(dev, id, 1);
+}
+
static int clk_show(struct seq_file *s, void *unused)
{
struct clkinf r;
@@ -257,15 +270,15 @@ static int clk_show(struct seq_file *s, void *unused)
spin_lock(&clk_list_lock);
/* show clock tree as derived from the three oscillators */
- clk = clk_get(NULL, "osc32k");
+ clk = clk_get_locked(NULL, "osc32k");
dump_clock(clk, &r);
clk_put(clk);
- clk = clk_get(NULL, "osc0");
+ clk = clk_get_locked(NULL, "osc0");
dump_clock(clk, &r);
clk_put(clk);
- clk = clk_get(NULL, "osc1");
+ clk = clk_get_locked(NULL, "osc1");
dump_clock(clk, &r);
clk_put(clk);
--
1.7.2.2
next reply other threads:[~2010-09-12 16:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-12 16:26 Ole Henrik Jahren [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-03-06 19:42 [PATCH] avr32: fix deadlock when reading clock list in debugfs Ole Henrik Jahren
2011-04-13 13:17 ` Hans-Christian Egtvedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100912162628.GA15423@siv \
--to=olehenja@alumni.ntnu.no \
--cc=hskinnemoen@atmel.com \
--cc=kernel@avr32linux.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.