[PATCH] devicetree: pull evaluation of of_address_to_resource() out of loop in of_dev_lookup()

From: Lothar WaÃmann
Date: Tue Apr 03 2012 - 08:48:34 EST


The result of_address_to_resource(np, 0, &res) is independent from the
for (; lookup->compatible != NULL; lookup++) {
}
loop evaluation. Evaluate it once before entering the loop.

Also add a space between 'for' keyword and parens.

Signed-off-by: Lothar WaÃmann <LW@xxxxxxxxxxxxxxxxxxx>
---
drivers/of/platform.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 343ad29..528405f 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -314,11 +314,12 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l
if (!lookup)
return NULL;

- for(; lookup->compatible != NULL; lookup++) {
+ if (of_address_to_resource(np, 0, &res))
+ return NULL;
+
+ for (; lookup->compatible != NULL; lookup++) {
if (!of_device_is_compatible(np, lookup->compatible))
continue;
- if (of_address_to_resource(np, 0, &res))
- continue;
if (res.start != lookup->phys_addr)
continue;
pr_debug("%s: devname=%s\n", np->full_name, lookup->name);
--
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/