Message ID | 1392135847-30791-5-git-send-email-joshc@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Dear Josh Cartwright, On Tue, 11 Feb 2014 10:24:02 -0600, Josh Cartwright wrote: > Instead of the of_find_matching_node()/of_match_node() pair, which requires two > iterations through the match table, make use of of_find_matching_node_and_match(), > which only iterates through the table once. > > While we're here, mark the of_system_controller table const. > > Signed-off-by: Josh Cartwright <joshc@codeaurora.org> > --- > arch/arm/mach-mvebu/system-controller.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
On Tue, Feb 11, 2014 at 10:24:02AM -0600, Josh Cartwright wrote: > Instead of the of_find_matching_node()/of_match_node() pair, which requires two > iterations through the match table, make use of of_find_matching_node_and_match(), > which only iterates through the table once. > > While we're here, mark the of_system_controller table const. > > Signed-off-by: Josh Cartwright <joshc@codeaurora.org> > --- > arch/arm/mach-mvebu/system-controller.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/arch/arm/mach-mvebu/system-controller.c b/arch/arm/mach-mvebu/system-controller.c > index a7fb89a..e6e300a 100644 > --- a/arch/arm/mach-mvebu/system-controller.c > +++ b/arch/arm/mach-mvebu/system-controller.c > @@ -54,7 +54,7 @@ static const struct mvebu_system_controller orion_system_controller = { > .system_soft_reset = 0x1, > }; > > -static struct of_device_id of_system_controller_table[] = { > +static const struct of_device_id of_system_controller_table[] = { > { > .compatible = "marvell,orion-system-controller", > .data = (void *) &orion_system_controller, > @@ -90,13 +90,12 @@ void mvebu_restart(enum reboot_mode mode, const char *cmd) > > static int __init mvebu_system_controller_init(void) > { > + const struct of_device_id *match; > struct device_node *np; > > - np = of_find_matching_node(NULL, of_system_controller_table); > + np = of_find_matching_node_and_match(NULL, of_system_controller_table, > + &match); > if (np) { > - const struct of_device_id *match = > - of_match_node(of_system_controller_table, np); > - BUG_ON(!match); Gregory, is it ok to remove this? It was added with the original code submission for mach-mvebu. mvebu_restart() will handle this gracefully... > system_controller_base = of_iomap(np, 0); > mvebu_sc = (struct mvebu_system_controller *)match->data; > of_node_put(np); thx, Jason.
Dear Jason Cooper, On Tue, 11 Feb 2014 11:53:14 -0500, Jason Cooper wrote: > > - np = of_find_matching_node(NULL, of_system_controller_table); > > + np = of_find_matching_node_and_match(NULL, of_system_controller_table, > > + &match); > > if (np) { > > - const struct of_device_id *match = > > - of_match_node(of_system_controller_table, np); > > > > - BUG_ON(!match); > > Gregory, is it ok to remove this? It was added with the original code > submission for mach-mvebu. mvebu_restart() will handle this > gracefully... The BUG_ON here can normally never be reached. If of_find_matching_node() returns a non-NULL result, then of_match_node() should also return a non-NULL result. Or I'm missing something :) Thomas
On 11/02/2014 18:10, Thomas Petazzoni wrote: > Dear Jason Cooper, > > On Tue, 11 Feb 2014 11:53:14 -0500, Jason Cooper wrote: > >>> - np = of_find_matching_node(NULL, of_system_controller_table); >>> + np = of_find_matching_node_and_match(NULL, of_system_controller_table, >>> + &match); >>> if (np) { >>> - const struct of_device_id *match = >>> - of_match_node(of_system_controller_table, np); >> >> >>> - BUG_ON(!match); >> >> Gregory, is it ok to remove this? It was added with the original code >> submission for mach-mvebu. mvebu_restart() will handle this >> gracefully... > > The BUG_ON here can normally never be reached. If > of_find_matching_node() returns a non-NULL result, then of_match_node() > should also return a non-NULL result. > > Or I'm missing something :) No you're almost right! The only case we can get it, would be if we were declaring something like: static struct of_device_id of_system_controller_table[] = { { .compatible = "foo,bar-controller", }, [...] instead of static struct of_device_id of_system_controller_table[] = { { .compatible = "foo,bar", .data = (void *) &bar_controller, }, [...] This test is very paranoid, so I agree to remove it. Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Thanks, Gregory > > Thomas >
On Tue, Feb 11, 2014 at 06:31:33PM +0100, Gregory CLEMENT wrote: > On 11/02/2014 18:10, Thomas Petazzoni wrote: > > Dear Jason Cooper, > > > > On Tue, 11 Feb 2014 11:53:14 -0500, Jason Cooper wrote: > > > >>> - np = of_find_matching_node(NULL, of_system_controller_table); > >>> + np = of_find_matching_node_and_match(NULL, of_system_controller_table, > >>> + &match); > >>> if (np) { > >>> - const struct of_device_id *match = > >>> - of_match_node(of_system_controller_table, np); > >> > >> > >>> - BUG_ON(!match); > >> > >> Gregory, is it ok to remove this? It was added with the original code > >> submission for mach-mvebu. mvebu_restart() will handle this > >> gracefully... > > > > The BUG_ON here can normally never be reached. If > > of_find_matching_node() returns a non-NULL result, then of_match_node() > > should also return a non-NULL result. > > > > Or I'm missing something :) > > No you're almost right! > > The only case we can get it, would be if we were declaring something like: > > static struct of_device_id of_system_controller_table[] = { > { > .compatible = "foo,bar-controller", > }, > [...] > > instead of > > static struct of_device_id of_system_controller_table[] = { > { > .compatible = "foo,bar", > .data = (void *) &bar_controller, > }, > [...] > > This test is very paranoid, so I agree to remove it. > > > Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Ok, great! Josh, do you want us to take the two mvebu patches through mvebu/arm-soc? Or would you prefer to take them? thx, Jason.
On Tue, Feb 11, 2014 at 12:34:46PM -0500, Jason Cooper wrote: > > Ok, great! Josh, do you want us to take the two mvebu patches through > mvebu/arm-soc? Or would you prefer to take them? Please, take them through the mvebu tree. Thanks, Josh
On Tue, Feb 11, 2014 at 10:24:02AM -0600, Josh Cartwright wrote: > Instead of the of_find_matching_node()/of_match_node() pair, which requires two > iterations through the match table, make use of of_find_matching_node_and_match(), > which only iterates through the table once. > > While we're here, mark the of_system_controller table const. > > Signed-off-by: Josh Cartwright <joshc@codeaurora.org> > --- > arch/arm/mach-mvebu/system-controller.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) Applied to mvebu/soc with Thomas' Reviewed-by, and Gregory's Ack. thx, Jason.
diff --git a/arch/arm/mach-mvebu/system-controller.c b/arch/arm/mach-mvebu/system-controller.c index a7fb89a..e6e300a 100644 --- a/arch/arm/mach-mvebu/system-controller.c +++ b/arch/arm/mach-mvebu/system-controller.c @@ -54,7 +54,7 @@ static const struct mvebu_system_controller orion_system_controller = { .system_soft_reset = 0x1, }; -static struct of_device_id of_system_controller_table[] = { +static const struct of_device_id of_system_controller_table[] = { { .compatible = "marvell,orion-system-controller", .data = (void *) &orion_system_controller, @@ -90,13 +90,12 @@ void mvebu_restart(enum reboot_mode mode, const char *cmd) static int __init mvebu_system_controller_init(void) { + const struct of_device_id *match; struct device_node *np; - np = of_find_matching_node(NULL, of_system_controller_table); + np = of_find_matching_node_and_match(NULL, of_system_controller_table, + &match); if (np) { - const struct of_device_id *match = - of_match_node(of_system_controller_table, np); - BUG_ON(!match); system_controller_base = of_iomap(np, 0); mvebu_sc = (struct mvebu_system_controller *)match->data; of_node_put(np);
Instead of the of_find_matching_node()/of_match_node() pair, which requires two iterations through the match table, make use of of_find_matching_node_and_match(), which only iterates through the table once. While we're here, mark the of_system_controller table const. Signed-off-by: Josh Cartwright <joshc@codeaurora.org> --- arch/arm/mach-mvebu/system-controller.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)