All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Josh Cartwright <josh.cartwright@gmail.com>,
	Stephen Warren <swarren@nvidia.com>,
	John Stultz <johnstul@us.ibm.com>,
	linux-kernel@vger.kernel.org,
	Rob Herring <rob.herring@calxeda.com>,
	linux-tegra@vger.kernel.org, Olof Johansson <olof@lixom.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V4 1/3] of: introduce for_each_matching_node_and_match()
Date: Wed, 21 Nov 2012 11:09:08 +0100	[thread overview]
Message-ID: <20121121110908.64bc74cd@skate> (raw)
In-Reply-To: <CACxGe6u5UBqVPrBqwn9rhjuBx4uCuuHKU=FcvSp0GJ2G8ogSNQ@mail.gmail.com>


On Wed, 21 Nov 2012 10:06:16 +0000, Grant Likely wrote:
> On Wed, Nov 21, 2012 at 9:53 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Tuesday 20 November 2012, Stephen Warren wrote:
> >> However, this results in iterating over table twice; the second time
> >> inside of_match_node(). The implementation of for_each_matching_node()
> >> already found the match, so this is redundant. Invent new function
> >> of_find_matching_node_and_match() and macro
> >> for_each_matching_node_and_match() to remove the double iteration,
> >> thus transforming the above code to:
> >>
> >>     for_each_matching_node_and_match(np, table, &match)
> >>
> >> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> >
> > This look useful, but I wonder if the interface would make more sense if you
> > make the last argument to the macro a normal pointer, rather than a
> > pointer-to-pointer. You can take the reference as part of the macro.
> 
> To me that makes for harder to understand code. It *looks* like an
> argument to a normal function call, but it gets changed by the caller.

Agreed. Too much magic is too much.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

WARNING: multiple messages have this Message-ID (diff)
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V4 1/3] of: introduce for_each_matching_node_and_match()
Date: Wed, 21 Nov 2012 11:09:08 +0100	[thread overview]
Message-ID: <20121121110908.64bc74cd@skate> (raw)
In-Reply-To: <CACxGe6u5UBqVPrBqwn9rhjuBx4uCuuHKU=FcvSp0GJ2G8ogSNQ@mail.gmail.com>


On Wed, 21 Nov 2012 10:06:16 +0000, Grant Likely wrote:
> On Wed, Nov 21, 2012 at 9:53 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Tuesday 20 November 2012, Stephen Warren wrote:
> >> However, this results in iterating over table twice; the second time
> >> inside of_match_node(). The implementation of for_each_matching_node()
> >> already found the match, so this is redundant. Invent new function
> >> of_find_matching_node_and_match() and macro
> >> for_each_matching_node_and_match() to remove the double iteration,
> >> thus transforming the above code to:
> >>
> >>     for_each_matching_node_and_match(np, table, &match)
> >>
> >> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> >
> > This look useful, but I wonder if the interface would make more sense if you
> > make the last argument to the macro a normal pointer, rather than a
> > pointer-to-pointer. You can take the reference as part of the macro.
> 
> To me that makes for harder to understand code. It *looks* like an
> argument to a normal function call, but it gets changed by the caller.

Agreed. Too much magic is too much.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

  reply	other threads:[~2012-11-21 10:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-20 23:12 [PATCH V4 1/3] of: introduce for_each_matching_node_and_match() Stephen Warren
2012-11-20 23:12 ` Stephen Warren
2012-11-20 23:12 ` Stephen Warren
     [not found] ` <1353453142-4973-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-11-20 23:12   ` [PATCH V4 2/3] clocksource: add common of_clksrc_init() function Stephen Warren
2012-11-20 23:12     ` Stephen Warren
2012-11-20 23:12     ` Stephen Warren
     [not found]     ` <1353453142-4973-2-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-01-02 18:16       ` Stephen Warren
2013-01-02 18:16         ` Stephen Warren
2013-01-02 18:16         ` Stephen Warren
2012-11-20 23:12   ` [PATCH V4 3/3] ARM: tegra: move timer.c to drivers/clocksource/ Stephen Warren
2012-11-20 23:12     ` Stephen Warren
2012-11-20 23:12     ` Stephen Warren
     [not found]     ` <1353453142-4973-3-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-01-02 18:21       ` Stephen Warren
2013-01-02 18:21         ` Stephen Warren
2013-01-02 18:21         ` Stephen Warren
2012-11-20 23:52   ` [PATCH V4 1/3] of: introduce for_each_matching_node_and_match() Rob Herring
2012-11-20 23:52     ` Rob Herring
2012-11-20 23:52     ` Rob Herring
2012-11-21  9:53   ` Arnd Bergmann
2012-11-21  9:53     ` Arnd Bergmann
2012-11-21  9:53     ` Arnd Bergmann
     [not found]     ` <201211210953.20552.arnd-r2nGTMty4D4@public.gmane.org>
2012-11-21 10:06       ` Grant Likely
2012-11-21 10:06         ` Grant Likely
2012-11-21 10:06         ` Grant Likely
2012-11-21 10:09         ` Thomas Petazzoni [this message]
2012-11-21 10:09           ` Thomas Petazzoni

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=20121121110908.64bc74cd@skate \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=arnd@arndb.de \
    --cc=grant.likely@secretlab.ca \
    --cc=johnstul@us.ibm.com \
    --cc=josh.cartwright@gmail.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=rob.herring@calxeda.com \
    --cc=swarren@nvidia.com \
    --cc=swarren@wwwdotorg.org \
    --cc=tglx@linutronix.de \
    /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.