Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754457Ab2KUKJY (ORCPT ); Wed, 21 Nov 2012 05:09:24 -0500 Received: from mail.free-electrons.com ([88.190.12.23]:37588 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754400Ab2KUKJV (ORCPT ); Wed, 21 Nov 2012 05:09:21 -0500 Date: Wed, 21 Nov 2012 11:09:08 +0100 From: Thomas Petazzoni To: Grant Likely Cc: Arnd Bergmann , Stephen Warren , Josh Cartwright , Stephen Warren , John Stultz , linux-kernel@vger.kernel.org, Rob Herring , linux-tegra@vger.kernel.org, Olof Johansson , Thomas Gleixner , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH V4 1/3] of: introduce for_each_matching_node_and_match() Message-ID: <20121121110908.64bc74cd@skate> In-Reply-To: References: <1353453142-4973-1-git-send-email-swarren@wwwdotorg.org> <201211210953.20552.arnd@arndb.de> Organization: Free Electrons X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1517 Lines: 35 On Wed, 21 Nov 2012 10:06:16 +0000, Grant Likely wrote: > On Wed, Nov 21, 2012 at 9:53 AM, Arnd Bergmann 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 > > > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/