MCPcopy Create free account
hub / github.com/coreboot/coreboot / dt_update_cells

Function dt_update_cells

util/cbmem/devmem_drv.c:243–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241
242#if defined(__arm__) || defined(__aarch64__)
243static 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
282static char *dt_find_compat(const char *parent, const char *compat, int *addr_cells_ptr,
283 int *size_cells_ptr)

Callers 1

dt_find_compatFunction · 0.85

Calls 4

strlenFunction · 0.85
perrorFunction · 0.85
readFunction · 0.85
strcpyFunction · 0.50

Tested by

no test coverage detected