summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-05-05 11:31:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-05-05 11:31:34 +0200
commite63f9a85226b1520a5881da7e7fef82446deb879 (patch)
treecdc1d521e9338d24af1c0a98c6177587a771b33e /drivers/of
parent337bf5f7eb243fb909f045950e8b6f402e5a0f8e (diff)
parentb876c2b7394f9d5258e6b73f684741c88fa41f23 (diff)
downloadbarebox-e63f9a85226b1520a5881da7e7fef82446deb879.tar.gz
barebox-e63f9a85226b1520a5881da7e7fef82446deb879.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c14
-rw-r--r--drivers/of/of_net.c20
2 files changed, 10 insertions, 24 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 6632f4d9dd..c9bdd91810 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1090,19 +1090,14 @@ int of_property_write_u8_array(struct device_node *np,
size_t sz)
{
struct property *prop = of_find_property(np, propname, NULL);
- u8 *val;
if (prop)
of_delete_property(prop);
- prop = of_new_property(np, propname, NULL, sizeof(*val) * sz);
+ prop = of_new_property(np, propname, values, sizeof(*values) * sz);
if (!prop)
return -ENOMEM;
- val = prop->value;
- while (sz--)
- *val++ = *values++;
-
return 0;
}
@@ -1807,12 +1802,7 @@ struct property *of_new_property(struct device_node *node, const char *name,
struct property *prop;
prop = xzalloc(sizeof(*prop));
- prop->name = strdup(name);
- if (!prop->name) {
- free(prop);
- return NULL;
- }
-
+ prop->name = xstrdup(name);
prop->length = len;
prop->value = xzalloc(len);
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;
}