From 866e9c118b51cffb74c299e40097890d4eaa2e61 Mon Sep 17 00:00:00 2001 From: Humberto Silva Naves Date: Mon, 14 Jul 2014 07:04:03 +0200 Subject: [PATCH] clk: added extra features to DebugFS representation of the clock tree. --- drivers/clk/Kconfig | 8 ++++++++ drivers/clk/clk.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 675749f811ba..a4125f364bb9 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -33,6 +33,14 @@ config COMMON_CLK_DEBUG clk_flags, clk_prepare_count, clk_enable_count & clk_notifier_count. +config COMMON_CLK_DEBUG_EXTRA + bool "Extra features for the clock tree DebugFS" + depends on COMMON_CLK_DEBUG + ---help--- + Adds one write-one file named change_rate to each + directory, allowing the function clk_set_rate to + be called. + config COMMON_CLK_WM831X tristate "Clock driver for WM831x/2x PMICs" depends on MFD_WM831X diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 77fcd069c64a..3808d87f37b8 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -226,6 +226,16 @@ static const struct file_operations clk_dump_fops = { .release = single_release, }; +#if CONFIG_COMMON_CLK_DEBUG_EXTRA +static int debugfs_clk_set_rate(void *data, u64 val) +{ + struct clk *clk = (struct clk *) data; + return clk_set_rate(clk, (u32) val); +} + +DEFINE_SIMPLE_ATTRIBUTE(fops_clk_rate_wo, NULL, debugfs_clk_set_rate, "%llu\n"); +#endif /* CONFIG_COMMON_CLK_DEBUG_EXTRA */ + /* caller must hold prepare_lock */ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry) { @@ -248,6 +258,12 @@ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry) if (!d) goto err_out; +#if CONFIG_COMMON_CLK_DEBUG_EXTRA + d = debugfs_create_file("change_rate", S_IWUGO, clk->dentry, clk, &fops_clk_rate_wo); + if (!d) + goto err_out; +#endif + d = debugfs_create_x32("clk_flags", S_IRUGO, clk->dentry, (u32 *)&clk->flags); if (!d)