From: viresh.kumar@st.com (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 1/8] CLKDEV: Add helper routines to allocate and add clkdevs for given struct clk *
Date: Thu, 26 Apr 2012 15:58:57 +0530 [thread overview]
Message-ID: <4F992369.2020308@st.com> (raw)
In-Reply-To: <20120426074746.GD24211@n2100.arm.linux.org.uk>
On 4/26/2012 1:17 PM, Russell King - ARM Linux wrote:
> This still causes additional warnings. Having managed to get the build
> for various platforms down to zero warnings, we now have:
>
> drivers/clk/clkdev.c: In function 'clkdev_alloc':
> drivers/clk/clkdev.c:209: warning: 'ap' may be used uninitialized in this function
> drivers/clk/clkdev.c: In function 'clk_register_clkdev':
> drivers/clk/clkdev.c:251: warning: 'ap' may be used uninitialized in this function
My compiler hasn't thrown any warnings :(
Please apply following patch. This should compile without errors.
From: Russell King <rmk+kernel@arm.linux.org.uk>
Date: Mon, 16 Apr 2012 10:43:17 +0530
Subject: [PATCH V4] CLKDEV: Add helper routines to allocate and add clkdevs for
given struct clk *
With common clock framework, clks are allocated at runtime. Some of them require
clkdevs to be allocated and added in global clkdev list.
This patch introduces helper routines to:
- allocate and add single clkdev for a single clk structure.
- add multiple clkdevs for a single clk structure.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
V3->V4:
- Move code that filled dev_id to clkdev_alloc_valist macro.
drivers/clk/clkdev.c | 75 +++++++++++++++++++++++++++++++++++++++++------
include/linux/clkdev.h | 3 ++
2 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index d4a5993..c890214 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -166,8 +166,8 @@ struct clk_lookup_alloc {
char con_id[MAX_CON_ID];
};
-struct clk_lookup * __init_refok
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
+static struct clk_lookup_alloc * __init_refok
+__clkdev_alloc_set_conid(struct clk *clk, const char *con_id)
{
struct clk_lookup_alloc *cla;
@@ -181,16 +181,40 @@ clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
cla->cl.con_id = cla->con_id;
}
- if (dev_fmt) {
- va_list ap;
+ return cla;
+}
- va_start(ap, dev_fmt);
- vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
- cla->cl.dev_id = cla->dev_id;
- va_end(ap);
- }
+#define clkdev_alloc_valist(_cl, _clk, _con_id, _dev_fmt) \
+ do { \
+ struct clk_lookup_alloc *_cla; \
+ \
+ _cla = __clkdev_alloc_set_conid(_clk, _con_id); \
+ if (!_cla) { \
+ _cl = NULL; \
+ break; \
+ } \
+ \
+ _cl = &_cla->cl; \
+ \
+ if (_dev_fmt) { \
+ va_list _ap; \
+ \
+ va_start(_ap, _dev_fmt); \
+ vscnprintf(_cla->dev_id, sizeof(_cla->dev_id), \
+ _dev_fmt, _ap); \
+ _cl->dev_id = _cla->dev_id; \
+ va_end(_ap); \
+ } \
+ } while (0);
+
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
+{
+ struct clk_lookup *cl;
- return &cla->cl;
+ clkdev_alloc_valist(cl, clk, con_id, dev_fmt);
+
+ return cl;
}
EXPORT_SYMBOL(clkdev_alloc);
@@ -223,3 +247,34 @@ void clkdev_drop(struct clk_lookup *cl)
kfree(cl);
}
EXPORT_SYMBOL(clkdev_drop);
+
+int clk_register_clkdev(struct clk *clk, const char *con_id,
+ const char *dev_fmt, ...)
+{
+ struct clk_lookup *cl;
+
+ clkdev_alloc_valist(cl, clk, con_id, dev_fmt);
+
+ if (!cl)
+ return -ENOMEM;
+
+ clkdev_add(cl);
+ return 0;
+}
+EXPORT_SYMBOL(clk_register_clkdev);
+
+int clk_register_clkdevs(struct clk *clk, struct clk_lookup *cl, size_t num)
+{
+ unsigned i;
+
+ if (!clk)
+ return -ENOMEM;
+
+ for (i = 0; i < num; i++, cl++) {
+ cl->clk = clk;
+ clkdev_add(cl);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(clk_register_clkdevs);
diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h
index d9a4fd0..01d8ff6 100644
--- a/include/linux/clkdev.h
+++ b/include/linux/clkdev.h
@@ -39,5 +39,8 @@ void clkdev_drop(struct clk_lookup *cl);
void clkdev_add_table(struct clk_lookup *, size_t);
int clk_add_alias(const char *, const char *, char *, struct device *);
+int clk_register_clkdev(struct clk *clk, const char *con_id,
+ const char *dev_fmt, ...);
+int clk_register_clkdevs(struct clk *clk, struct clk_lookup *cl, size_t num);
#endif
--
1.7.9
--
viresh
next prev parent reply other threads:[~2012-04-26 10:28 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-24 6:50 [PATCH V3 0/8] SPEAr: Move to common clock framework Viresh Kumar
2012-04-24 6:50 ` [PATCH V3 1/8] CLKDEV: Add helper routines to allocate and add clkdevs for given struct clk * Viresh Kumar
2012-04-26 7:47 ` Russell King - ARM Linux
2012-04-26 10:28 ` Viresh Kumar [this message]
2012-04-28 9:52 ` Russell King - ARM Linux
2012-04-28 11:01 ` Sascha Hauer
2012-04-28 11:06 ` Russell King - ARM Linux
2012-05-01 8:45 ` Viresh Kumar
2012-05-01 12:31 ` Shawn Guo
2012-05-02 9:54 ` Russell King - ARM Linux
2012-05-02 13:59 ` Shawn Guo
2012-05-02 14:13 ` Russell King - ARM Linux
2012-04-30 8:08 ` Viresh Kumar
2012-04-24 6:50 ` [PATCH V3 2/8] clk: add a fixed factor clock Viresh Kumar
2012-04-27 4:43 ` Viresh Kumar
2012-05-02 9:48 ` Sascha Hauer
2012-05-02 11:56 ` Viresh Kumar
2012-05-02 22:41 ` Mike Turquette
2012-05-02 22:44 ` Mike Turquette
2012-05-02 23:31 ` Russell King - ARM Linux
2012-05-03 5:32 ` Viresh Kumar
2012-05-03 6:37 ` Sascha Hauer
2012-05-03 9:48 ` Viresh Kumar
2012-04-24 6:50 ` [PATCH V3 3/8] SPEAr: clk: Add VCO-PLL Synthesizer clock Viresh Kumar
2012-04-27 4:44 ` Viresh Kumar
2012-05-03 5:47 ` Viresh Kumar
2012-05-03 9:49 ` Viresh Kumar
2012-04-24 6:50 ` [PATCH V3 4/8] SPEAr: clk: Add Auxiliary " Viresh Kumar
2012-04-27 4:45 ` Viresh Kumar
2012-05-03 5:47 ` Viresh Kumar
2012-05-03 9:50 ` Viresh Kumar
2012-04-24 6:50 ` [PATCH V3 5/8] SPEAr: clk: Add Fractional " Viresh Kumar
2012-04-27 4:45 ` Viresh Kumar
2012-05-03 5:46 ` Viresh Kumar
2012-05-03 9:51 ` Viresh Kumar
2012-04-24 6:50 ` [PATCH V3 6/8] SPEAr: clk: Add General Purpose Timer " Viresh Kumar
2012-04-27 4:46 ` Viresh Kumar
2012-05-03 5:43 ` Viresh Kumar
2012-05-03 9:51 ` Viresh Kumar
2012-04-24 6:50 ` [PATCH V3 7/8] SPEAr: Call clk_prepare() before calling clk_enable Viresh Kumar
2012-04-27 4:42 ` [PATCH V3 0/8] SPEAr: Move to common clock framework Viresh Kumar
2012-04-27 17:50 ` Turquette, Mike
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=4F992369.2020308@st.com \
--to=viresh.kumar@st.com \
--cc=linux-arm-kernel@lists.infradead.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.