fdt_sw.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) fdt_sw.c (4201d057ea91c3d6efd2db65219bc91fae413bc2)
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

--- 206 unchanged lines hidden (view full) ---

215 if (fdt_totalsize(fdt) + offset < struct_top)
216 return 0; /* no more room :( */
217
218 memcpy(strtab + offset, s, len);
219 fdt_set_size_dt_strings(fdt, strtabsize + len);
220 return offset;
221}
222
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

--- 206 unchanged lines hidden (view full) ---

215 if (fdt_totalsize(fdt) + offset < struct_top)
216 return 0; /* no more room :( */
217
218 memcpy(strtab + offset, s, len);
219 fdt_set_size_dt_strings(fdt, strtabsize + len);
220 return offset;
221}
222
223int fdt_property(void *fdt, const char *name, const void *val, int len)
223int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)
224{
225 struct fdt_property *prop;
226 int nameoff;
227
228 FDT_SW_CHECK_HEADER(fdt);
229
230 nameoff = _fdt_find_add_string(fdt, name);
231 if (nameoff == 0)
232 return -FDT_ERR_NOSPACE;
233
234 prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
235 if (! prop)
236 return -FDT_ERR_NOSPACE;
237
238 prop->tag = cpu_to_fdt32(FDT_PROP);
239 prop->nameoff = cpu_to_fdt32(nameoff);
240 prop->len = cpu_to_fdt32(len);
224{
225 struct fdt_property *prop;
226 int nameoff;
227
228 FDT_SW_CHECK_HEADER(fdt);
229
230 nameoff = _fdt_find_add_string(fdt, name);
231 if (nameoff == 0)
232 return -FDT_ERR_NOSPACE;
233
234 prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
235 if (! prop)
236 return -FDT_ERR_NOSPACE;
237
238 prop->tag = cpu_to_fdt32(FDT_PROP);
239 prop->nameoff = cpu_to_fdt32(nameoff);
240 prop->len = cpu_to_fdt32(len);
241 memcpy(prop->data, val, len);
241 *valp = prop->data;
242 return 0;
243}
244
242 return 0;
243}
244
245int fdt_property(void *fdt, const char *name, const void *val, int len)
246{
247 void *ptr;
248 int ret;
249
250 ret = fdt_property_placeholder(fdt, name, len, &ptr);
251 if (ret)
252 return ret;
253 memcpy(ptr, val, len);
254 return 0;
255}
256
245int fdt_finish(void *fdt)
246{
247 char *p = (char *)fdt;
248 fdt32_t *end;
249 int oldstroffset, newstroffset;
250 uint32_t tag;
251 int offset, nextoffset;
252

--- 36 unchanged lines hidden ---
257int fdt_finish(void *fdt)
258{
259 char *p = (char *)fdt;
260 fdt32_t *end;
261 int oldstroffset, newstroffset;
262 uint32_t tag;
263 int offset, nextoffset;
264

--- 36 unchanged lines hidden ---