All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Cartwright <josh.cartwright@gmail.com>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: John Stultz <johnstul@us.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Stephen Warren <swarren@nvidia.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	Olof Johansson <olof@lixom.net>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V3 1/2] clocksource: add common of_clksrc_init() function
Date: Tue, 20 Nov 2012 14:10:26 -0600	[thread overview]
Message-ID: <20121120201026.GF6280@kryptos> (raw)
In-Reply-To: <1353439206-1654-1-git-send-email-swarren@wwwdotorg.org>

On Tue, Nov 20, 2012 at 12:20:05PM -0700, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> It is desirable to move all clocksource drivers to drivers/clocksource,
> yet each requires its own initialization function. We'd rather not
> pollute <linux/> with a header for each function. Instead, create a
> single of_clksrc_init() function which will determine which clocksource
> driver to initialize based on device tree.
> 
> Inspired by a similar patch for drivers/irqchip by Thomas Petazzoni.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> v3: Use a linker section to replace manually maintained table.
> v2: New patch.
> 
[..]
> --- /dev/null
> +++ b/drivers/clocksource/clksrc-of.c
> @@ -0,0 +1,41 @@
> +/*
> + * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/of.h>
> +
> +extern struct of_device_id *__start_clksrc_of_match_tables[];
> +extern struct of_device_id *__stop_clksrc_of_match_tables[];
> +
> +void __init clocksource_of_init(void)
> +{
> +	struct of_device_id **table;
> +	struct of_device_id **stop;
> +	struct device_node *np;
> +	const struct of_device_id *match;
> +	void (*init_func)(void);
> +
> +	table = __start_clksrc_of_match_tables;
> +	stop = __stop_clksrc_of_match_tables;
> +
> +	for ( ; table < stop; table++) {
> +		for_each_matching_node(np, *table) {
> +			match = of_match_node(*table, np);
> +			init_func = match->data;
> +			init_func();

Hmm.  Am I crazy, or does this for_each_matching_node()/of_match_node()
pattern end up walking the match table twice, unnecessarily?

I'm wondering if we can come up with a for_each_matching_node_id() macro
that also provides a pointer to the matching of_device_id...

   Josh

WARNING: multiple messages have this Message-ID (diff)
From: josh.cartwright@gmail.com (Josh Cartwright)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 1/2] clocksource: add common of_clksrc_init() function
Date: Tue, 20 Nov 2012 14:10:26 -0600	[thread overview]
Message-ID: <20121120201026.GF6280@kryptos> (raw)
In-Reply-To: <1353439206-1654-1-git-send-email-swarren@wwwdotorg.org>

On Tue, Nov 20, 2012 at 12:20:05PM -0700, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> It is desirable to move all clocksource drivers to drivers/clocksource,
> yet each requires its own initialization function. We'd rather not
> pollute <linux/> with a header for each function. Instead, create a
> single of_clksrc_init() function which will determine which clocksource
> driver to initialize based on device tree.
> 
> Inspired by a similar patch for drivers/irqchip by Thomas Petazzoni.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> v3: Use a linker section to replace manually maintained table.
> v2: New patch.
> 
[..]
> --- /dev/null
> +++ b/drivers/clocksource/clksrc-of.c
> @@ -0,0 +1,41 @@
> +/*
> + * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/of.h>
> +
> +extern struct of_device_id *__start_clksrc_of_match_tables[];
> +extern struct of_device_id *__stop_clksrc_of_match_tables[];
> +
> +void __init clocksource_of_init(void)
> +{
> +	struct of_device_id **table;
> +	struct of_device_id **stop;
> +	struct device_node *np;
> +	const struct of_device_id *match;
> +	void (*init_func)(void);
> +
> +	table = __start_clksrc_of_match_tables;
> +	stop = __stop_clksrc_of_match_tables;
> +
> +	for ( ; table < stop; table++) {
> +		for_each_matching_node(np, *table) {
> +			match = of_match_node(*table, np);
> +			init_func = match->data;
> +			init_func();

Hmm.  Am I crazy, or does this for_each_matching_node()/of_match_node()
pattern end up walking the match table twice, unnecessarily?

I'm wondering if we can come up with a for_each_matching_node_id() macro
that also provides a pointer to the matching of_device_id...

   Josh

  parent reply	other threads:[~2012-11-20 20:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-20 19:20 [PATCH V3 1/2] clocksource: add common of_clksrc_init() function Stephen Warren
2012-11-20 19:20 ` Stephen Warren
2012-11-20 19:20 ` Stephen Warren
     [not found] ` <1353439206-1654-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-11-20 19:20   ` [PATCH V3 2/2] ARM: tegra: move timer.c to drivers/clocksource/ Stephen Warren
2012-11-20 19:20     ` Stephen Warren
2012-11-20 19:20     ` Stephen Warren
2012-11-20 19:31   ` [PATCH V3 1/2] clocksource: add common of_clksrc_init() function Thomas Petazzoni
2012-11-20 19:31     ` Thomas Petazzoni
2012-11-20 19:31     ` Thomas Petazzoni
2012-11-20 19:45     ` Stephen Warren
2012-11-20 19:45       ` Stephen Warren
2012-11-20 19:45       ` Stephen Warren
2012-11-20 20:10 ` Josh Cartwright [this message]
2012-11-20 20:10   ` Josh Cartwright
2012-11-20 20:38   ` Stephen Warren
2012-11-20 20:38     ` Stephen Warren
2012-11-20 20:38     ` Stephen Warren

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=20121120201026.GF6280@kryptos \
    --to=josh.cartwright@gmail.com \
    --cc=arnd@arndb.de \
    --cc=johnstul@us.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=swarren@nvidia.com \
    --cc=swarren@wwwdotorg.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.petazzoni@free-electrons.com \
    /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.