From mboxrd@z Thu Jan 1 00:00:00 1970 From: kgene.kim@samsung.com (Kukjin Kim) Date: Mon, 22 Nov 2010 11:22:49 +0900 Subject: [PATCH] ARM: SAMSUNG: Add support for clock debugging through debug-fs interface In-Reply-To: <1289904860-30951-1-git-send-email-amit.daniel@samsung.com> References: <1289904860-30951-1-git-send-email-amit.daniel@samsung.com> Message-ID: <015a01cb89ec$2ae4dc80$80ae9580$%kim@samsung.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org amit.daniel at samsung.com wrote: > Maybe missed set name in your e-mail client. > From: Amit Daniel Kachhap > > This patch adds support for clock information exposed to debug-fs > interface. > > Signed-off-by: Amit Daniel Kachhap > --- > arch/arm/plat-samsung/clock.c | 92 > ++++++++++++++++++++++++++++ > arch/arm/plat-samsung/include/plat/clock.h | 3 + > 2 files changed, 95 insertions(+), 0 deletions(-) > Please add Ben Dooks in Cc next time. > diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c > index e8d20b0..0ba209d 100644 > --- a/arch/arm/plat-samsung/clock.c > +++ b/arch/arm/plat-samsung/clock.c > @@ -39,6 +39,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -447,3 +448,94 @@ int __init s3c24xx_register_baseclocks(unsigned long > xtal) > return 0; > } > > +#if defined(CONFIG_DEBUG_FS) > +/* > + * debugfs support to trace clock tree hierarchy and attributes > + */ One line comment format/style is "/* ... */" > +static struct dentry *clk_debugfs_root; > + > +static int clk_debugfs_register_one(struct clk *c) > +{ > + int err; > + struct dentry *d, *child, *child_tmp; > + struct clk *pa = c->parent; > + char s[255]; > + char *p = s; > + > + p += sprintf(p, "%s", c->name); > +#ifdef CONFIG_PLAT_SAMSUNG > + /*Append id field with name also*/ > + if (c->id >= 0) > + p += sprintf(p, ":%d", c->id); Not more used p...so just sprint(p,...); > +#endif Actually this file(plat-samsung/clock.c) already depends on CONFIG_PLAT_SAMSUNG. > + > + d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root); > + if (!d) > + return -ENOMEM; > + > + c->dent = d; > + > + d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usage); > + if (!d) { > + err = -ENOMEM; > + goto err_out; > + } > + d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate); > + if (!d) { > + err = -ENOMEM; > + goto err_out; > + } > + return 0; > + Could you please show demo sample on board? > +err_out: > + d = c->dent; > + list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child) > + debugfs_remove(child); > + debugfs_remove(c->dent); > + return err; > +} > + > +static int clk_debugfs_register(struct clk *c) > +{ > + int err; > + struct clk *pa = c->parent; > + > + if (pa && !pa->dent) { > + err = clk_debugfs_register(pa); > + if (err) > + return err; > + } > + > + if (!c->dent) { > + err = clk_debugfs_register_one(c); > + if (err) > + return err; > + } > + return 0; > +} > + > +static int __init clk_debugfs_init(void) > +{ > + struct clk *c; > + struct dentry *d; > + int err; > + > + d = debugfs_create_dir("clock", NULL); > + if (!d) > + return -ENOMEM; > + clk_debugfs_root = d; > + > + list_for_each_entry(c, &clocks, list) { > + err = clk_debugfs_register(c); > + if (err) > + goto err_out; > + } > + return 0; > +err_out: > + debugfs_remove_recursive(clk_debugfs_root); > + return err; > +} > +late_initcall(clk_debugfs_init); > + > +#endif /* defined(CONFIG_DEBUG_FS) */ > + > diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat- > samsung/include/plat/clock.h > index 0fbcd0e..f6180ab 100644 > --- a/arch/arm/plat-samsung/include/plat/clock.h > +++ b/arch/arm/plat-samsung/include/plat/clock.h > @@ -47,6 +47,9 @@ struct clk { > > struct clk_ops *ops; > int (*enable)(struct clk *, int enable); > +#if defined(CONFIG_DEBUG_FS) > + struct dentry *dent; /* For visible tree hierarchy */ > +#endif > }; > > /* other clocks which may be registered by board support */ > -- I think, you just copied this from omap. Of course, there is small changes... I mean, would be better, if you could add more useful debug-fs i/f for Samsung SoCs' clock. Thanks. Best regards, Kgene. -- Kukjin Kim , Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.