From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 3/4] clk: introduce the common clock framework
Date: Mon, 5 Mar 2012 08:38:36 +0100 [thread overview]
Message-ID: <20120305073836.GU3852@pengutronix.de> (raw)
In-Reply-To: <CAJOA=zP8d8wm==7=svOzh03Ft-1_LV71q0mA6Pncrh5vQSWGEA@mail.gmail.com>
On Sun, Mar 04, 2012 at 04:12:21PM -0800, Turquette, Mike wrote:
> >>
> >> I believe this patch already does what you suggest, but I might be
> >> missing your point.
> >
> > In include/linux/clk-private.h you expose struct clk outside the core.
> > This has to be done to make static initializers possible. There is a big
> > warning in this file that it must not be included from files implementing
> > struct clk_ops. You can simply avoid this warning by declaring struct clk
> > with only a single member:
> >
> > include/linux/clk.h:
> >
> > struct clk {
> > ? ? ? ?struct clk_internal *internal;
> > };
> >
> > This way everybody knows struct clk (thus can embed it in their static
> > initializers), but doesn't know anything about the internal members. Now
> > in drivers/clk/clk.c you declare struct clk_internal exactly like struct
> > clk was declared before:
> >
> > struct clk_internal {
> > ? ? ? ?const char ? ? ? ? ? ? ?*name;
> > ? ? ? ?const struct clk_ops ? ?*ops;
> > ? ? ? ?struct clk_hw ? ? ? ? ? *hw;
> > ? ? ? ?struct clk ? ? ? ? ? ? ?*parent;
> > ? ? ? ?char ? ? ? ? ? ? ? ? ? ?**parent_names;
> > ? ? ? ?struct clk ? ? ? ? ? ? ?**parents;
> > ? ? ? ?u8 ? ? ? ? ? ? ? ? ? ? ?num_parents;
> > ? ? ? ?unsigned long ? ? ? ? ? rate;
> > ? ? ? ?unsigned long ? ? ? ? ? flags;
> > ? ? ? ?unsigned int ? ? ? ? ? ?enable_count;
> > ? ? ? ?unsigned int ? ? ? ? ? ?prepare_count;
> > ? ? ? ?struct hlist_head ? ? ? children;
> > ? ? ? ?struct hlist_node ? ? ? child_node;
> > ? ? ? ?unsigned int ? ? ? ? ? ?notifier_count;
> > #ifdef CONFIG_COMMON_CLK_DEBUG
> > ? ? ? ?struct dentry ? ? ? ? ? *dentry;
> > #endif
> > };
> >
> > An instance of struct clk_internal will be allocated in
> > __clk_init/clk_register. Now the private data stays completely inside
> > the core and noone can abuse it.
>
> Hi Sascha,
>
> I see the disconnect here. For OMAP (and possibly other platforms) at
> least some clock data is necessary during early boot, before the
> regular allocation methods are available (timers for instance).
We had this problem on i.MX aswell. It turned out that the timer clock
is the only clock that is needed so early. We solved this by moving the
clock init to the system timer init function.
> Due
> to this my idea of static initialization was to take care of
> everything that would normally require an allocator, which includes
> the internals of struct clk; thus exposing struct clk is useful here
> as you can still use the clock framework during very early boot. Your
> method above doesn't satisfy this requirement. I'm not sure what the
> purpose would be of statically allocating your version of struct clk,
> which will ultimately need to allocate memory for the clock internals
> anyways. Can you elaborate the benefit of this approach over just
> using the clk_foo_register functions?
As said the benefit is that you do not have to expose the internal
layout of struct clk outside the clock framework. Note that in the
file you referenced here:
http://git.linaro.org/gitweb?p=people/mturquette/linux.git;a=blob;f=arch/arm/mach-omap2/clock44xx_data.c;h=7f833a7b2dca84a52c2bd1e7c8d9cfe560771258;hb=v3.3-rc5-clkv5-omap#l205
You violate what you have in a comment above clk-private.h:
/* __clk_init is only exposed via clk-private.h and is intended for use with
* very large numbers of clocks that need to be statically initialized. It is
* a layering violation to include clk-private.h from any code which implements
* a clock's .ops; as such any statically initialized clock data MUST be in
* separate C file from the logic that implements it's operations.
*/
Well, the file is work in progress, you probably fix this before sending
it out, but I bet people will include clk-private.h and nobody else
notices it.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2012-03-05 7:38 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-03 8:28 [PATCH v5 0/4] common clk framework Mike Turquette
2012-03-03 8:28 ` [PATCH v5 1/4] Documentation: common clk API Mike Turquette
2012-03-03 8:28 ` [PATCH v5 2/4] clk: Kconfig: add entry for HAVE_CLK_PREPARE Mike Turquette
2012-03-05 2:04 ` Richard Zhao
2012-03-05 19:46 ` Turquette, Mike
2012-03-03 8:29 ` [PATCH v5 3/4] clk: introduce the common clock framework Mike Turquette
2012-03-03 13:31 ` Sascha Hauer
2012-03-03 17:14 ` Turquette, Mike
2012-03-04 11:52 ` Sascha Hauer
2012-03-05 0:12 ` Turquette, Mike
2012-03-05 7:38 ` Sascha Hauer [this message]
2012-03-05 20:03 ` Turquette, Mike
2012-03-06 19:00 ` Sascha Hauer
2012-03-07 21:20 ` Turquette, Mike
2012-03-08 6:27 ` Andrew Lunn
2012-03-08 23:25 ` Sascha Hauer
2012-03-09 7:57 ` Andrew Lunn
2012-03-09 18:25 ` Turquette, Mike
2012-03-19 7:01 ` Shawn Guo
2012-03-19 11:22 ` Sascha Hauer
2012-03-09 18:18 ` Turquette, Mike
2012-03-09 0:51 ` Thomas Gleixner
2012-03-17 3:23 ` Saravana Kannan
2012-03-19 5:38 ` Shawn Guo
2012-03-19 7:42 ` Shawn Guo
2012-03-05 9:22 ` Richard Zhao
2012-03-14 2:03 ` Turquette, Mike
2012-03-13 11:24 ` Sascha Hauer
2012-03-13 23:43 ` Turquette, Mike
2012-03-14 8:48 ` Sascha Hauer
2012-03-14 20:47 ` Turquette, Mike
2012-03-14 21:28 ` Thomas Gleixner
2012-03-14 22:13 ` Turquette, Mike
2012-03-14 22:18 ` Thomas Gleixner
2012-03-03 8:29 ` [PATCH v5 4/4] clk: basic clock hardware types Mike Turquette
2012-03-04 14:26 ` Andrew Lunn
2012-03-04 14:35 ` Andrew Lunn
2012-03-05 0:15 ` Turquette, Mike
2012-03-04 17:42 ` Andrew Lunn
2012-03-05 0:30 ` Turquette, Mike
2012-03-05 8:48 ` Andrew Lunn
2012-03-05 9:29 ` Sascha Hauer
2012-03-05 10:17 ` Andrew Lunn
2012-03-09 23:38 ` Turquette, Mike
2012-03-04 20:33 ` [PATCH] clk: Fix compile errors in DEFINE_CLK_GATE Andrew Lunn
2012-03-05 0:31 ` Turquette, Mike
2012-03-07 21:20 ` [PATCH v5 4/4] clk: basic clock hardware types Sascha Hauer
2012-03-09 22:50 ` Turquette, Mike
2012-03-09 2:34 ` [PATCH v5 0/4] common clk framework Richard Zhao
2012-03-09 9:19 ` Sascha Hauer
2012-03-09 18:35 ` 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=20120305073836.GU3852@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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 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).