| 241 | |
| 242 | #if defined(__arm__) || defined(__aarch64__) |
| 243 | static void dt_update_cells(const char *name, int *addr_cells_ptr, int *size_cells_ptr) |
| 244 | { |
| 245 | if (*addr_cells_ptr >= 0 && *size_cells_ptr >= 0) |
| 246 | return; |
| 247 | |
| 248 | int buffer; |
| 249 | size_t nlen = strlen(name); |
| 250 | char *prop = alloca(nlen + sizeof("/#address-cells")); |
| 251 | strcpy(prop, name); |
| 252 | |
| 253 | if (*addr_cells_ptr < 0) { |
| 254 | strcpy(prop + nlen, "/#address-cells"); |
| 255 | int fd = open(prop, O_RDONLY); |
| 256 | if (fd < 0 && errno != ENOENT) { |
| 257 | perror(prop); |
| 258 | } else if (fd >= 0) { |
| 259 | if (read(fd, &buffer, sizeof(int)) < 0) |
| 260 | perror(prop); |
| 261 | else |
| 262 | *addr_cells_ptr = ntohl(buffer); |
| 263 | close(fd); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | if (*size_cells_ptr < 0) { |
| 268 | strcpy(prop + nlen, "/#size-cells"); |
| 269 | int fd = open(prop, O_RDONLY); |
| 270 | if (fd < 0 && errno != ENOENT) { |
| 271 | perror(prop); |
| 272 | } else if (fd >= 0) { |
| 273 | if (read(fd, &buffer, sizeof(int)) < 0) |
| 274 | perror(prop); |
| 275 | else |
| 276 | *size_cells_ptr = ntohl(buffer); |
| 277 | close(fd); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | static char *dt_find_compat(const char *parent, const char *compat, int *addr_cells_ptr, |
| 283 | int *size_cells_ptr) |
no test coverage detected