fdt_wip.c (204431) | fdt_wip.c (204433) |
---|---|
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 --- 80 unchanged lines hidden (view full) --- 89 if (! prop) 90 return len; 91 92 _fdt_nop_region(prop, len + sizeof(*prop)); 93 94 return 0; 95} 96 | 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 --- 80 unchanged lines hidden (view full) --- 89 if (! prop) 90 return len; 91 92 _fdt_nop_region(prop, len + sizeof(*prop)); 93 94 return 0; 95} 96 |
97int _fdt_node_end_offset(void *fdt, int nodeoffset) | 97int _fdt_node_end_offset(void *fdt, int offset) |
98{ | 98{ |
99 int level = 0; 100 uint32_t tag; 101 int offset, nextoffset; | 99 int depth = 0; |
102 | 100 |
103 tag = fdt_next_tag(fdt, nodeoffset, &nextoffset); 104 if (tag != FDT_BEGIN_NODE) 105 return -FDT_ERR_BADOFFSET; 106 do { 107 offset = nextoffset; 108 tag = fdt_next_tag(fdt, offset, &nextoffset); | 101 while ((offset >= 0) && (depth >= 0)) 102 offset = fdt_next_node(fdt, offset, &depth); |
109 | 103 |
110 switch (tag) { 111 case FDT_END: 112 return offset; 113 114 case FDT_BEGIN_NODE: 115 level++; 116 break; 117 118 case FDT_END_NODE: 119 level--; 120 break; 121 122 case FDT_PROP: 123 case FDT_NOP: 124 break; 125 126 default: 127 return -FDT_ERR_BADSTRUCTURE; 128 } 129 } while (level >= 0); 130 131 return nextoffset; | 104 return offset; |
132} 133 134int fdt_nop_node(void *fdt, int nodeoffset) 135{ 136 int endoffset; 137 138 endoffset = _fdt_node_end_offset(fdt, nodeoffset); 139 if (endoffset < 0) 140 return endoffset; 141 142 _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0), 143 endoffset - nodeoffset); 144 return 0; 145} | 105} 106 107int fdt_nop_node(void *fdt, int nodeoffset) 108{ 109 int endoffset; 110 111 endoffset = _fdt_node_end_offset(fdt, nodeoffset); 112 if (endoffset < 0) 113 return endoffset; 114 115 _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0), 116 endoffset - nodeoffset); 117 return 0; 118} |