The path entry for a device tree node and its name property are usually,

but not always, identical. In particular, the path entry may contain a
unit address that the name does not. If the FDT node does have an explicit
name property, treat that as an override of the FDT path rather than
ignoring it.

MFC after:	2 weeks
This commit is contained in:
nwhitehorn 2015-01-01 22:20:19 +00:00
parent 236e47c874
commit dabb40130f

View File

@ -222,15 +222,15 @@ ofw_fdt_getproplen(ofw_t ofw, phandle_t package, const char *propname)
if (offset < 0)
return (-1);
if (strcmp(propname, "name") == 0) {
len = -1;
prop = fdt_get_property(fdtp, offset, propname, &len);
if (prop == NULL && strcmp(propname, "name") == 0) {
/* Emulate the 'name' property */
fdt_get_name(fdtp, offset, &len);
return (len + 1);
}
len = -1;
prop = fdt_get_property(fdtp, offset, propname, &len);
return (len);
}
@ -247,7 +247,9 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const char *propname, void *buf,
if (offset < 0)
return (-1);
if (strcmp(propname, "name") == 0) {
prop = fdt_getprop(fdtp, offset, propname, &len);
if (prop == NULL && strcmp(propname, "name") == 0) {
/* Emulate the 'name' property */
name = fdt_get_name(fdtp, offset, &len);
strncpy(buf, name, buflen);
@ -256,7 +258,6 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const char *propname, void *buf,
return (len + 1);
}
prop = fdt_getprop(fdtp, offset, propname, &len);
if (prop == NULL)
return (-1);