| 232 | } |
| 233 | |
| 234 | const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) |
| 235 | { |
| 236 | const struct fdt_node_header *nh = fdt_offset_ptr_(fdt, nodeoffset); |
| 237 | const char *nameptr; |
| 238 | int err; |
| 239 | |
| 240 | if (((err = fdt_check_header(fdt)) != 0) |
| 241 | || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) |
| 242 | goto fail; |
| 243 | |
| 244 | nameptr = nh->name; |
| 245 | |
| 246 | if (fdt_version(fdt) < 0x10) { |
| 247 | /* |
| 248 | * For old FDT versions, match the naming conventions of V16: |
| 249 | * give only the leaf name (after all /). The actual tree |
| 250 | * contents are loosely checked. |
| 251 | */ |
| 252 | const char *leaf; |
| 253 | leaf = strrchr(nameptr, '/'); |
| 254 | if (leaf == NULL) { |
| 255 | err = -FDT_ERR_BADSTRUCTURE; |
| 256 | goto fail; |
| 257 | } |
| 258 | nameptr = leaf+1; |
| 259 | } |
| 260 | |
| 261 | if (len) |
| 262 | *len = strlen(nameptr); |
| 263 | |
| 264 | return nameptr; |
| 265 | |
| 266 | fail: |
| 267 | if (len) |
| 268 | *len = err; |
| 269 | return NULL; |
| 270 | } |
| 271 | |
| 272 | int fdt_first_property_offset(const void *fdt, int nodeoffset) |
| 273 | { |
no test coverage detected