fdt_ro.c (238742) | fdt_ro.c (261215) |
---|---|
1/* 2 * libfdt - Flat Device Tree manipulation 3 * Copyright (C) 2006 David Gibson, IBM Corporation. 4 * 5 * libfdt is dual licensed: you can use it either under the terms of 6 * the GPL, or the BSD license, at your option. 7 * 8 * a) This library is free software; you can redistribute it and/or --- 308 unchanged lines hidden (view full) --- 317const void *fdt_getprop(const void *fdt, int nodeoffset, 318 const char *name, int *lenp) 319{ 320 return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp); 321} 322 323uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) 324{ | 1/* 2 * libfdt - Flat Device Tree manipulation 3 * Copyright (C) 2006 David Gibson, IBM Corporation. 4 * 5 * libfdt is dual licensed: you can use it either under the terms of 6 * the GPL, or the BSD license, at your option. 7 * 8 * a) This library is free software; you can redistribute it and/or --- 308 unchanged lines hidden (view full) --- 317const void *fdt_getprop(const void *fdt, int nodeoffset, 318 const char *name, int *lenp) 319{ 320 return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp); 321} 322 323uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) 324{ |
325 const uint32_t *php; | 325 const fdt32_t *php; |
326 int len; 327 328 /* FIXME: This is a bit sub-optimal, since we potentially scan 329 * over all the properties twice. */ 330 php = fdt_getprop(fdt, nodeoffset, "phandle", &len); 331 if (!php || (len != sizeof(*php))) { 332 php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len); 333 if (!php || (len != sizeof(*php))) --- 176 unchanged lines hidden (view full) --- 510 offset = fdt_next_node(fdt, offset, NULL)) { 511 if (fdt_get_phandle(fdt, offset) == phandle) 512 return offset; 513 } 514 515 return offset; /* error from fdt_next_node() */ 516} 517 | 326 int len; 327 328 /* FIXME: This is a bit sub-optimal, since we potentially scan 329 * over all the properties twice. */ 330 php = fdt_getprop(fdt, nodeoffset, "phandle", &len); 331 if (!php || (len != sizeof(*php))) { 332 php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len); 333 if (!php || (len != sizeof(*php))) --- 176 unchanged lines hidden (view full) --- 510 offset = fdt_next_node(fdt, offset, NULL)) { 511 if (fdt_get_phandle(fdt, offset) == phandle) 512 return offset; 513 } 514 515 return offset; /* error from fdt_next_node() */ 516} 517 |
518static int _fdt_stringlist_contains(const char *strlist, int listlen, 519 const char *str) | 518int fdt_stringlist_contains(const char *strlist, int listlen, const char *str) |
520{ 521 int len = strlen(str); 522 const char *p; 523 524 while (listlen >= len) { 525 if (memcmp(str, strlist, len+1) == 0) 526 return 1; 527 p = memchr(strlist, '\0', listlen); --- 9 unchanged lines hidden (view full) --- 537 const char *compatible) 538{ 539 const void *prop; 540 int len; 541 542 prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); 543 if (!prop) 544 return len; | 519{ 520 int len = strlen(str); 521 const char *p; 522 523 while (listlen >= len) { 524 if (memcmp(str, strlist, len+1) == 0) 525 return 1; 526 p = memchr(strlist, '\0', listlen); --- 9 unchanged lines hidden (view full) --- 536 const char *compatible) 537{ 538 const void *prop; 539 int len; 540 541 prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); 542 if (!prop) 543 return len; |
545 if (_fdt_stringlist_contains(prop, len, compatible)) | 544 if (fdt_stringlist_contains(prop, len, compatible)) |
546 return 0; 547 else 548 return 1; 549} 550 551int fdt_node_offset_by_compatible(const void *fdt, int startoffset, 552 const char *compatible) 553{ --- 21 unchanged lines hidden --- | 545 return 0; 546 else 547 return 1; 548} 549 550int fdt_node_offset_by_compatible(const void *fdt, int startoffset, 551 const char *compatible) 552{ --- 21 unchanged lines hidden --- |