clkdev: add debugfs support
PATCH 1/1 clkdev: add debugfs support
create a file in /sys/kernel/debug/clkdev
with the list of lookup with the con_id, dev_id and the clock rate
as this
dev_id con_id rate (null) clk32k 32768 Hz (null) main 16367660 Hz (null) plla 199919178 Hz (null) mck 99959589 Hz at91_mci.0 mci_clk 99959589 Hz at91_mci.1 mci_clk 99959589 Hz atmel_spi.0 spi_clk 99959589 Hz
--- drivers/clk/clkdev.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)
drivers/clk/clkdev.c +40 -0
@@ -19,6 +19,8 @@#include <linux/mutex.h> #include <linux/clk.h> #include <linux/clkdev.h> +#include <linux/debugfs.h> +#include <linux/seq_file.h> static LIST_HEAD (clocks);static DEFINE_MUTEX (clocks_mutex);
@@ -174,3 +176,41 @@ void clkdev_drop(struct clk_lookup *cl)kfree (cl); }EXPORT_SYMBOL (clkdev_drop); + +#ifdef CONFIG_DEBUG_FS +static int clkdev_clk_show (struct seq_file *s,void *unused) +{ +struct clk_lookup *p; + +seq_printf (s,"%-20s %-20s rate\n" ,"dev_id" ,"con_id" ); + +list_for_each_entry (p, &clocks, node) { + +seq_printf (s,"%-20s %-20s %9ld Hz\n" , + p->dev_id, p->con_id,clk_get_rate (p->clk)); + } +return 0 ; +} + +static int clkdev_clk_open (struct inode *inode,struct file *file) +{ +return single_open (file, clkdev_clk_show,NULL ); +} + +static const struct file_operations clkdev_clk_operations = { + .open = clkdev_clk_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int __init clkdev_clk_debugfs_init (void ) +{ +/* /sys/kernel/debug/clkdev */ + (void )debugfs_create_file ("clkdev" ,S_IFREG |S_IRUGO ,NULL ,NULL , + &clkdev_clk_operations); + +return 0 ; +} +postcore_initcall (clkdev_clk_debugfs_init); +#endif
Signature · 1 line
1.7.4.1
PATCH 1/1 clkdev: add debugfs support
Hello Jean-Christophe,
Quoted 39 lines · Jean-Christophe PLAGNIOL-VILLARD
create a file in
/sys/kernel/debug/clkdevwith the list of lookup with the
con_id,dev_idand the clock rateas this
dev_id con_id rate (null) clk32k 32768 Hz (null) main 16367660 Hz (null) plla 199919178 Hz (null) mck 99959589 Hz at91_mci.0 mci_clk 99959589 Hz at91_mci.1 mci_clk 99959589 Hz atmel_spi.0 spi_clk 99959589 HzSigned-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/clk/clkdev.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)drivers/clk/clkdev.c +4
-0@@ -19,6 +19,8 @@#include <linux/mutex.h> #include <linux/clk.h> #include <linux/clkdev.h> +#include <linux/debugfs.h> +#include <linux/seq_file.h> static LIST_HEAD (clocks);static DEFINE_MUTEX (clocks_mutex);@@ -174,3 +176,41 @@ void clkdev_drop(struct clk_lookup *cl)kfree (cl); }EXPORT_SYMBOL (clkdev_drop); + +#ifdef CONFIG_DEBUG_FS
drivers/clk/clkdev.c void clkdev_drop(struct clk_lookup *cl) · line 190
Quoted 10 lines
drivers/clk/clkdev.c +10
-0+static int clkdev_clk_show (struct seq_file *s,void *unused) +{ +struct clk_lookup *p; + +seq_printf (s,"%-20s %-20s rate\n" ,"dev_id" ,"con_id" ); + +list_for_each_entry (p, &clocks, node) { + +seq_printf (s,"%-20s %-20s %9ld Hz\n" , + p->dev_id, p->con_id,clk_get_rate (p->clk));
s/%9ld/%9lu/ ?
According to include/linux/clk.h, the result of clk_get_rate is "only valid once the clock source has been enabled". So it would be nice to find out (and tell) if a clock is on or not.
Quoted 11 lines
drivers/clk/clkdev.c +11
-0+ } +return 0 ; +} + +static int clkdev_clk_open (struct inode *inode,struct file *file) +{ +return single_open (file, clkdev_clk_show,NULL ); +} + +static const struct file_operations clkdev_clk_operations = { + .open = clkdev_clk_open,
drivers/clk/clkdev.c void clkdev_drop(struct clk_lookup *cl) · line 211
Quoted 10 lines
drivers/clk/clkdev.c +10
-0+ .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int __init clkdev_clk_debugfs_init (void ) +{ +/* /sys/kernel/debug/clkdev */ + (void )debugfs_create_file ("clkdev" ,S_IFREG |S_IRUGO ,NULL ,NULL , + &clkdev_clk_operations);
I'd be a bit more conservative here and would only allow S_IRUSR.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 clkdev: add debugfs support
Hi Uwe,
Quoted 45 lines · Uwe Kleine-K?nig
Hello Jean-Christophe,
Quoted 42 lines · Jean-Christophe PLAGNIOL-VILLARD
create a file in
/sys/kernel/debug/clkdevwith the list of lookup with the
con_id,dev_idand the clock rateas this
dev_id con_id rate (null) clk32k 32768 Hz (null) main 16367660 Hz (null) plla 199919178 Hz (null) mck 99959589 Hz at91_mci.0 mci_clk 99959589 Hz at91_mci.1 mci_clk 99959589 Hz atmel_spi.0 spi_clk 99959589 HzSigned-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/clk/clkdev.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)drivers/clk/clkdev.c +7
-0@@ -19,6 +19,8 @@#include <linux/mutex.h> #include <linux/clk.h> #include <linux/clkdev.h> +#include <linux/debugfs.h> +#include <linux/seq_file.h> static LIST_HEAD (clocks);static DEFINE_MUTEX (clocks_mutex);@@ -174,3 +176,41 @@ void clkdev_drop(struct clk_lookup *cl)kfree (cl); }EXPORT_SYMBOL (clkdev_drop); + +#ifdef CONFIG_DEBUG_FS +static int clkdev_clk_show (struct seq_file *s,void *unused) +{ +struct clk_lookup *p;
Quoted 8 lines
drivers/clk/clkdev.c void clkdev_drop(struct clk_lookup *cl) · line 190
Quoted 7 lines
drivers/clk/clkdev.c +7
-0+ +seq_printf (s,"%-20s %-20s rate\n" ,"dev_id" ,"con_id" ); + +list_for_each_entry (p, &clocks, node) { + +seq_printf (s,"%-20s %-20s %9ld Hz\n" , + p->dev_id, p->con_id,clk_get_rate (p->clk));s/%9ld/%9lu/ ?
yeah
Quoted 4 lines
According to
include/linux/clk.h, the result ofclk_get_rateis "only valid once the clock source has been enabled". So it would be nice to find out (and tell) if a clock is on or not.
it was my idea also at the begenning as we do on at91 but the current clk api does not allow it
if we want it we need to update the clk API and implement it
Quoted 15 lines
Quoted 15 lines
drivers/clk/clkdev.c +14
-0+ } +return 0 ; +} + +static int clkdev_clk_open (struct inode *inode,struct file *file) +{ +return single_open (file, clkdev_clk_show,NULL ); +} + +static const struct file_operations clkdev_clk_operations = { + .open = clkdev_clk_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release,
Quoted 8 lines
drivers/clk/clkdev.c void clkdev_drop(struct clk_lookup *cl) · line 211
Quoted 7 lines
drivers/clk/clkdev.c +7
-0+}; + +static int __init clkdev_clk_debugfs_init (void ) +{ +/* /sys/kernel/debug/clkdev */ + (void )debugfs_create_file ("clkdev" ,S_IFREG |S_IRUGO ,NULL ,NULL , + &clkdev_clk_operations);I'd be a bit more conservative here and would only allow
S_IRUSR.
ok will take a look
Best Regards,
J.