From: Dmitry Baryshkov <dbaryshkov@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, hskinnemoen@atmel.com,
domen.puncer@telargo.com, lethal@linux-sh.org, tony@atomide.com,
rmk+kernel@arm.linux.org.uk, paul@pwsan.com
Subject: [PATCH 2/3] Clocklib: debugfs support
Date: Wed, 26 Mar 2008 18:52:44 +0300 [thread overview]
Message-ID: <20080326155244.GA15418@doriath.ww600.siemens.net> (raw)
In-Reply-To: <20080326154913.GA15326@doriath.ww600.siemens.net>
Provide /sys/kernel/debug/clock to ease debugging.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
---
include/linux/clklib.h | 5 +++
kernel/clklib.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/include/linux/clklib.h b/include/linux/clklib.h
index 92f0a45..f9c1db4 100644
--- a/include/linux/clklib.h
+++ b/include/linux/clklib.h
@@ -30,6 +30,11 @@ struct clk {
int (*setrate) (struct clk *, unsigned long);
long (*roundrate) (struct clk *, unsigned long);
+ /*
+ * format any additional info
+ */
+ int (*format) (struct clk *, struct seq_file *);
+
void *priv;
};
diff --git a/kernel/clklib.c b/kernel/clklib.c
index b41e7c2..1c52e55 100644
--- a/kernel/clklib.c
+++ b/kernel/clklib.c
@@ -313,3 +313,73 @@ out:
return rc;
}
EXPORT_SYMBOL(clk_alloc_function);
+
+#ifdef CONFIG_DEBUG_FS
+
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+static void dump_clocks(struct seq_file *s, struct clk *parent, int nest)
+{
+ struct clk *clk;
+ int i;
+
+ list_for_each_entry(clk, &clocks, node) {
+ if (clk->parent == parent) {
+ for (i = 0; i < nest; i++)
+ seq_putc(s, ' ');
+ seq_puts(s, clk->name);
+
+ i = nest + strlen(clk->name);
+ if (i >= 16)
+ i = 15;
+ for (; i < 16; i++) {
+ seq_putc(s, ' ');
+ seq_putc(s, ' ');
+ }
+ seq_printf(s, "%c use=%d rate=%10lu Hz",
+ clk->set_parent ? '*' : ' ',
+ clk->users,
+ __clk_get_rate(clk));
+ if (clk->format)
+ clk->format(clk, s);
+ seq_putc(s, '\n');
+
+ dump_clocks(s, clk, nest + 1);
+ }
+ }
+}
+
+static int clocklib_show(struct seq_file *s, void *unused)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&clocks_lock, flags);
+
+ dump_clocks(s, NULL, 0);
+
+ spin_unlock_irqrestore(&clocks_lock, flags);
+
+ return 0;
+}
+
+static int clocklib_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, clocklib_show, NULL);
+}
+
+static struct file_operations clocklib_operations = {
+ .open = clocklib_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static int __init clocklib_debugfs_init(void)
+{
+ debugfs_create_file("clock", S_IFREG | S_IRUGO,
+ NULL, NULL, &clocklib_operations);
+ return 0;
+}
+subsys_initcall(clocklib_debugfs_init);
+
+#endif /* DEBUG_FS */
--
1.5.4.4
--
With best wishes
Dmitry
next prev parent reply other threads:[~2008-03-26 15:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-26 15:49 [PATCH 0/3] Clocklib: generic clocks framework Dmitry Baryshkov
2008-03-26 15:52 ` [PATCH 1/3] Clocklib: add generic framework for managing clocks Dmitry Baryshkov
2008-03-26 16:04 ` Haavard Skinnemoen
2008-03-26 16:14 ` Paul Mundt
2008-03-26 17:04 ` Dmitry
2008-03-26 20:09 ` Russell King
2008-03-26 16:52 ` Dmitry
2008-03-26 17:44 ` Paul Mundt
2008-03-27 9:52 ` Dmitry
2008-03-26 17:44 ` Juergen Beisert
2008-03-27 9:06 ` Haavard Skinnemoen
2008-03-27 9:18 ` Russell King
2008-03-27 9:26 ` Haavard Skinnemoen
2008-03-27 9:33 ` Russell King
2008-03-27 9:50 ` Paul Mundt
2008-03-27 9:53 ` Haavard Skinnemoen
2008-03-27 10:08 ` Dmitry
2008-03-27 10:20 ` Haavard Skinnemoen
2008-03-27 13:33 ` Dmitry
2008-03-27 9:29 ` pHilipp Zabel
2008-03-27 9:36 ` Russell King
2008-03-28 14:23 ` Pavel Machek
2008-03-29 12:36 ` Haavard Skinnemoen
2008-03-26 15:52 ` Dmitry Baryshkov [this message]
2008-03-26 15:53 ` [PATCH 3/3] Clocklib: support sa1100 sub-arch Dmitry Baryshkov
2008-03-26 16:17 ` [PATCH 4/4] Clocklib: support ARM pxa sub-arch Dmitry Baryshkov
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=20080326155244.GA15418@doriath.ww600.siemens.net \
--to=dbaryshkov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=domen.puncer@telargo.com \
--cc=hskinnemoen@atmel.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@pwsan.com \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=tony@atomide.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).