diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-12 12:08:04 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-12 12:12:50 +0200 |
commit | bd3b279d0d5bc3aa8593066d302ca025aed81de0 (patch) | |
tree | 57953636c5032f9d05a9372cad1c6ec6392e938a /drivers | |
parent | f2cca54b7a9ae82012c96ecc907518957de1536e (diff) | |
download | barebox-bd3b279d0d5bc3aa8593066d302ca025aed81de0.tar.gz barebox-bd3b279d0d5bc3aa8593066d302ca025aed81de0.tar.xz |
of: of_net: use a loop
iterate over the different property names rather than having
the same code three times.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/of_net.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index 086573fc1a..9b54e44674 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c @@ -77,19 +77,15 @@ EXPORT_SYMBOL_GPL(of_get_phy_mode); */ const void *of_get_mac_address(struct device_node *np) { - struct property *pp; + const void *p; + int len, i; + const char *str[] = { "mac-address", "local-mac-address", "address" }; - pp = of_find_property(np, "mac-address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; - - pp = of_find_property(np, "local-mac-address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; - - pp = of_find_property(np, "address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; + for (i = 0; i < ARRAY_SIZE(str); i++) { + p = of_get_property(np, str[i], &len); + if (p && (len == 6) && is_valid_ether_addr(p)) + return p; + } return NULL; } |