1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2017 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
10 #include <fdt_support.h>
13 #include <linux/libfdt.h>
14 #include <dm/of_access.h>
15 #include <dm/of_addr.h>
16 #include <dm/ofnode.h>
17 #include <linux/err.h>
18 #include <linux/ioport.h>
19 #include <asm/global_data.h>
21 int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)
23 return ofnode_read_u32_index(node, propname, 0, outp);
26 u32 ofnode_read_u32_default(ofnode node, const char *propname, u32 def)
28 assert(ofnode_valid(node));
29 ofnode_read_u32_index(node, propname, 0, &def);
34 int ofnode_read_u32_index(ofnode node, const char *propname, int index,
40 assert(ofnode_valid(node));
41 debug("%s: %s: ", __func__, propname);
43 if (ofnode_is_np(node))
44 return of_read_u32_index(ofnode_to_np(node), propname, index,
47 cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
50 debug("(not found)\n");
54 if (len < (sizeof(int) * (index + 1))) {
55 debug("(not large enough)\n");
59 *outp = fdt32_to_cpu(cell[index]);
60 debug("%#x (%d)\n", *outp, *outp);
65 u32 ofnode_read_u32_index_default(ofnode node, const char *propname, int index,
68 assert(ofnode_valid(node));
69 ofnode_read_u32_index(node, propname, index, &def);
74 int ofnode_read_s32_default(ofnode node, const char *propname, s32 def)
76 assert(ofnode_valid(node));
77 ofnode_read_u32(node, propname, (u32 *)&def);
82 int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)
84 const unaligned_fdt64_t *cell;
87 assert(ofnode_valid(node));
88 debug("%s: %s: ", __func__, propname);
90 if (ofnode_is_np(node))
91 return of_read_u64(ofnode_to_np(node), propname, outp);
93 cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
95 if (!cell || len < sizeof(*cell)) {
96 debug("(not found)\n");
99 *outp = fdt64_to_cpu(cell[0]);
100 debug("%#llx (%lld)\n", (unsigned long long)*outp,
101 (unsigned long long)*outp);
106 u64 ofnode_read_u64_default(ofnode node, const char *propname, u64 def)
108 assert(ofnode_valid(node));
109 ofnode_read_u64(node, propname, &def);
114 bool ofnode_read_bool(ofnode node, const char *propname)
118 assert(ofnode_valid(node));
119 debug("%s: %s: ", __func__, propname);
121 prop = ofnode_get_property(node, propname, NULL);
123 debug("%s\n", prop ? "true" : "false");
125 return prop ? true : false;
128 const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep)
130 const char *val = NULL;
133 assert(ofnode_valid(node));
134 debug("%s: %s: ", __func__, propname);
136 if (ofnode_is_np(node)) {
137 struct property *prop = of_find_property(
138 ofnode_to_np(node), propname, &len);
145 val = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
149 debug("<not found>\n");
151 *sizep = -FDT_ERR_NOTFOUND;
160 const char *ofnode_read_string(ofnode node, const char *propname)
165 str = ofnode_read_prop(node, propname, &len);
169 if (strnlen(str, len) >= len) {
170 debug("<invalid>\n");
178 int ofnode_read_size(ofnode node, const char *propname)
182 if (!ofnode_read_prop(node, propname, &len))
188 ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
192 assert(ofnode_valid(node));
193 debug("%s: %s: ", __func__, subnode_name);
195 if (ofnode_is_np(node)) {
196 const struct device_node *np = ofnode_to_np(node);
198 for (np = np->child; np; np = np->sibling) {
199 if (!strcmp(subnode_name, np->name))
202 subnode = np_to_ofnode(np);
204 int ooffset = fdt_subnode_offset(gd->fdt_blob,
205 ofnode_to_offset(node), subnode_name);
206 subnode = offset_to_ofnode(ooffset);
208 debug("%s\n", ofnode_valid(subnode) ?
209 ofnode_get_name(subnode) : "<none>");
214 int ofnode_read_u32_array(ofnode node, const char *propname,
215 u32 *out_values, size_t sz)
217 assert(ofnode_valid(node));
218 debug("%s: %s: ", __func__, propname);
220 if (ofnode_is_np(node)) {
221 return of_read_u32_array(ofnode_to_np(node), propname,
224 return fdtdec_get_int_array(gd->fdt_blob,
225 ofnode_to_offset(node), propname,
230 #if !CONFIG_IS_ENABLED(DM_INLINE_OFNODE)
231 bool ofnode_is_enabled(ofnode node)
233 if (ofnode_is_np(node)) {
234 return of_device_is_available(ofnode_to_np(node));
236 return fdtdec_get_is_enabled(gd->fdt_blob,
237 ofnode_to_offset(node));
241 ofnode ofnode_first_subnode(ofnode node)
243 assert(ofnode_valid(node));
244 if (ofnode_is_np(node))
245 return np_to_ofnode(node.np->child);
247 return offset_to_ofnode(
248 fdt_first_subnode(gd->fdt_blob, ofnode_to_offset(node)));
251 ofnode ofnode_next_subnode(ofnode node)
253 assert(ofnode_valid(node));
254 if (ofnode_is_np(node))
255 return np_to_ofnode(node.np->sibling);
257 return offset_to_ofnode(
258 fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node)));
260 #endif /* !DM_INLINE_OFNODE */
262 ofnode ofnode_get_parent(ofnode node)
266 assert(ofnode_valid(node));
267 if (ofnode_is_np(node))
268 parent = np_to_ofnode(of_get_parent(ofnode_to_np(node)));
270 parent.of_offset = fdt_parent_offset(gd->fdt_blob,
271 ofnode_to_offset(node));
276 const char *ofnode_get_name(ofnode node)
278 if (!ofnode_valid(node)) {
279 debug("%s node not valid\n", __func__);
283 if (ofnode_is_np(node))
284 return strrchr(node.np->full_name, '/') + 1;
286 return fdt_get_name(gd->fdt_blob, ofnode_to_offset(node), NULL);
289 ofnode ofnode_get_by_phandle(uint phandle)
293 if (of_live_active())
294 node = np_to_ofnode(of_find_node_by_phandle(phandle));
296 node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob,
302 fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
306 *size = FDT_SIZE_T_NONE;
308 if (ofnode_is_np(node)) {
309 const __be32 *prop_val;
313 prop_val = of_get_address(ofnode_to_np(node), index, &size64,
316 return FDT_ADDR_T_NONE;
320 ns = of_n_size_cells(ofnode_to_np(node));
322 if (IS_ENABLED(CONFIG_OF_TRANSLATE) &&
323 (ns > 0 || gd_size_cells_0())) {
324 return of_translate_address(ofnode_to_np(node), prop_val);
326 na = of_n_addr_cells(ofnode_to_np(node));
327 return of_read_number(prop_val, na);
330 na = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
331 ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
332 return fdtdec_get_addr_size_fixed(gd->fdt_blob,
333 ofnode_to_offset(node), "reg",
334 index, na, ns, size, true);
337 return FDT_ADDR_T_NONE;
340 fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
344 return ofnode_get_addr_size_index(node, index, &size);
347 fdt_addr_t ofnode_get_addr(ofnode node)
349 return ofnode_get_addr_index(node, 0);
352 fdt_size_t ofnode_get_size(ofnode node)
356 ofnode_get_addr_size_index(node, 0, &size);
361 int ofnode_stringlist_search(ofnode node, const char *property,
364 if (ofnode_is_np(node)) {
365 return of_property_match_string(ofnode_to_np(node),
370 ret = fdt_stringlist_search(gd->fdt_blob,
371 ofnode_to_offset(node), property,
373 if (ret == -FDT_ERR_NOTFOUND)
382 int ofnode_read_string_index(ofnode node, const char *property, int index,
385 if (ofnode_is_np(node)) {
386 return of_property_read_string_index(ofnode_to_np(node),
387 property, index, outp);
391 *outp = fdt_stringlist_get(gd->fdt_blob, ofnode_to_offset(node),
392 property, index, &len);
399 int ofnode_read_string_count(ofnode node, const char *property)
401 if (ofnode_is_np(node)) {
402 return of_property_count_strings(ofnode_to_np(node), property);
404 return fdt_stringlist_count(gd->fdt_blob,
405 ofnode_to_offset(node), property);
409 static void ofnode_from_fdtdec_phandle_args(struct fdtdec_phandle_args *in,
410 struct ofnode_phandle_args *out)
412 assert(OF_MAX_PHANDLE_ARGS == MAX_PHANDLE_ARGS);
413 out->node = offset_to_ofnode(in->node);
414 out->args_count = in->args_count;
415 memcpy(out->args, in->args, sizeof(out->args));
418 static void ofnode_from_of_phandle_args(struct of_phandle_args *in,
419 struct ofnode_phandle_args *out)
421 assert(OF_MAX_PHANDLE_ARGS == MAX_PHANDLE_ARGS);
422 out->node = np_to_ofnode(in->np);
423 out->args_count = in->args_count;
424 memcpy(out->args, in->args, sizeof(out->args));
427 int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
428 const char *cells_name, int cell_count,
430 struct ofnode_phandle_args *out_args)
432 if (ofnode_is_np(node)) {
433 struct of_phandle_args args;
436 ret = of_parse_phandle_with_args(ofnode_to_np(node),
437 list_name, cells_name,
442 ofnode_from_of_phandle_args(&args, out_args);
444 struct fdtdec_phandle_args args;
447 ret = fdtdec_parse_phandle_with_args(gd->fdt_blob,
448 ofnode_to_offset(node),
449 list_name, cells_name,
450 cell_count, index, &args);
453 ofnode_from_fdtdec_phandle_args(&args, out_args);
459 int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
460 const char *cells_name, int cell_count)
462 if (ofnode_is_np(node))
463 return of_count_phandle_with_args(ofnode_to_np(node),
464 list_name, cells_name, cell_count);
466 return fdtdec_parse_phandle_with_args(gd->fdt_blob,
467 ofnode_to_offset(node), list_name, cells_name,
468 cell_count, -1, NULL);
471 ofnode ofnode_path(const char *path)
473 if (of_live_active())
474 return np_to_ofnode(of_find_node_by_path(path));
476 return offset_to_ofnode(fdt_path_offset(gd->fdt_blob, path));
479 const void *ofnode_read_chosen_prop(const char *propname, int *sizep)
483 chosen_node = ofnode_path("/chosen");
485 return ofnode_read_prop(chosen_node, propname, sizep);
488 const char *ofnode_read_chosen_string(const char *propname)
490 return ofnode_read_chosen_prop(propname, NULL);
493 ofnode ofnode_get_chosen_node(const char *name)
497 prop = ofnode_read_chosen_prop(name, NULL);
499 return ofnode_null();
501 return ofnode_path(prop);
504 const void *ofnode_read_aliases_prop(const char *propname, int *sizep)
508 node = ofnode_path("/aliases");
510 return ofnode_read_prop(node, propname, sizep);
513 ofnode ofnode_get_aliases_node(const char *name)
517 prop = ofnode_read_aliases_prop(name, NULL);
519 return ofnode_null();
521 debug("%s: node_path: %s\n", __func__, prop);
523 return ofnode_path(prop);
526 int ofnode_get_child_count(ofnode parent)
531 ofnode_for_each_subnode(child, parent)
537 static int decode_timing_property(ofnode node, const char *name,
538 struct timing_entry *result)
542 length = ofnode_read_size(node, name);
544 debug("%s: could not find property %s\n",
545 ofnode_get_name(node), name);
549 if (length == sizeof(u32)) {
550 result->typ = ofnode_read_u32_default(node, name, 0);
551 result->min = result->typ;
552 result->max = result->typ;
554 ret = ofnode_read_u32_array(node, name, &result->min, 3);
560 int ofnode_decode_display_timing(ofnode parent, int index,
561 struct display_timing *dt)
564 ofnode timings, node;
568 timings = ofnode_find_subnode(parent, "display-timings");
569 if (!ofnode_valid(timings))
573 ofnode_for_each_subnode(node, timings) {
578 if (!ofnode_valid(node))
581 memset(dt, 0, sizeof(*dt));
583 ret |= decode_timing_property(node, "hback-porch", &dt->hback_porch);
584 ret |= decode_timing_property(node, "hfront-porch", &dt->hfront_porch);
585 ret |= decode_timing_property(node, "hactive", &dt->hactive);
586 ret |= decode_timing_property(node, "hsync-len", &dt->hsync_len);
587 ret |= decode_timing_property(node, "vback-porch", &dt->vback_porch);
588 ret |= decode_timing_property(node, "vfront-porch", &dt->vfront_porch);
589 ret |= decode_timing_property(node, "vactive", &dt->vactive);
590 ret |= decode_timing_property(node, "vsync-len", &dt->vsync_len);
591 ret |= decode_timing_property(node, "clock-frequency", &dt->pixelclock);
594 val = ofnode_read_u32_default(node, "vsync-active", -1);
596 dt->flags |= val ? DISPLAY_FLAGS_VSYNC_HIGH :
597 DISPLAY_FLAGS_VSYNC_LOW;
599 val = ofnode_read_u32_default(node, "hsync-active", -1);
601 dt->flags |= val ? DISPLAY_FLAGS_HSYNC_HIGH :
602 DISPLAY_FLAGS_HSYNC_LOW;
604 val = ofnode_read_u32_default(node, "de-active", -1);
606 dt->flags |= val ? DISPLAY_FLAGS_DE_HIGH :
607 DISPLAY_FLAGS_DE_LOW;
609 val = ofnode_read_u32_default(node, "pixelclk-active", -1);
611 dt->flags |= val ? DISPLAY_FLAGS_PIXDATA_POSEDGE :
612 DISPLAY_FLAGS_PIXDATA_NEGEDGE;
615 if (ofnode_read_bool(node, "interlaced"))
616 dt->flags |= DISPLAY_FLAGS_INTERLACED;
617 if (ofnode_read_bool(node, "doublescan"))
618 dt->flags |= DISPLAY_FLAGS_DOUBLESCAN;
619 if (ofnode_read_bool(node, "doubleclk"))
620 dt->flags |= DISPLAY_FLAGS_DOUBLECLK;
625 const void *ofnode_get_property(ofnode node, const char *propname, int *lenp)
627 if (ofnode_is_np(node))
628 return of_get_property(ofnode_to_np(node), propname, lenp);
630 return fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
634 int ofnode_get_first_property(ofnode node, struct ofprop *prop)
638 if (ofnode_is_np(node)) {
639 prop->prop = of_get_first_property(ofnode_to_np(prop->node));
641 return -FDT_ERR_NOTFOUND;
644 fdt_first_property_offset(gd->fdt_blob,
645 ofnode_to_offset(prop->node));
646 if (prop->offset < 0)
653 int ofnode_get_next_property(struct ofprop *prop)
655 if (ofnode_is_np(prop->node)) {
656 prop->prop = of_get_next_property(ofnode_to_np(prop->node),
659 return -FDT_ERR_NOTFOUND;
661 prop->offset = fdt_next_property_offset(gd->fdt_blob,
663 if (prop->offset < 0)
670 const void *ofnode_get_property_by_prop(const struct ofprop *prop,
671 const char **propname, int *lenp)
673 if (ofnode_is_np(prop->node))
674 return of_get_property_by_prop(ofnode_to_np(prop->node),
675 prop->prop, propname, lenp);
677 return fdt_getprop_by_offset(gd->fdt_blob,
682 bool ofnode_is_available(ofnode node)
684 if (ofnode_is_np(node))
685 return of_device_is_available(ofnode_to_np(node));
687 return fdtdec_get_is_enabled(gd->fdt_blob,
688 ofnode_to_offset(node));
691 fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,
694 if (ofnode_is_np(node)) {
697 const struct device_node *np = ofnode_to_np(node);
698 const __be32 *prop = of_get_property(np, property, &psize);
701 return FDT_ADDR_T_NONE;
702 na = of_n_addr_cells(np);
703 ns = of_n_size_cells(np);
704 *sizep = of_read_number(prop + na, ns);
706 if (CONFIG_IS_ENABLED(OF_TRANSLATE) &&
707 (ns > 0 || gd_size_cells_0())) {
708 return of_translate_address(np, prop);
711 return of_read_number(prop, na);
713 return fdtdec_get_addr_size(gd->fdt_blob,
714 ofnode_to_offset(node), property,
719 const uint8_t *ofnode_read_u8_array_ptr(ofnode node, const char *propname,
722 if (ofnode_is_np(node)) {
723 const struct device_node *np = ofnode_to_np(node);
725 const __be32 *prop = of_get_property(np, propname, &psize);
727 if (!prop || sz != psize)
729 return (uint8_t *)prop;
732 return fdtdec_locate_byte_array(gd->fdt_blob,
733 ofnode_to_offset(node), propname, sz);
737 int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
738 const char *propname, struct fdt_pci_addr *addr)
744 debug("%s: %s: ", __func__, propname);
747 * If we follow the pci bus bindings strictly, we should check
748 * the value of the node's parent node's #address-cells and
749 * #size-cells. They need to be 3 and 2 accordingly. However,
750 * for simplicity we skip the check here.
752 cell = ofnode_get_property(node, propname, &len);
756 if ((len % FDT_PCI_REG_SIZE) == 0) {
757 int num = len / FDT_PCI_REG_SIZE;
760 for (i = 0; i < num; i++) {
761 debug("pci address #%d: %08lx %08lx %08lx\n", i,
762 (ulong)fdt32_to_cpu(cell[0]),
763 (ulong)fdt32_to_cpu(cell[1]),
764 (ulong)fdt32_to_cpu(cell[2]));
765 if ((fdt32_to_cpu(*cell) & type) == type) {
766 addr->phys_hi = fdt32_to_cpu(cell[0]);
767 addr->phys_mid = fdt32_to_cpu(cell[1]);
768 addr->phys_lo = fdt32_to_cpu(cell[2]);
772 cell += (FDT_PCI_ADDR_CELLS +
787 debug("(not found)\n");
791 int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device)
793 const char *list, *end;
796 list = ofnode_get_property(node, "compatible", &len);
803 if (len >= strlen("pciVVVV,DDDD")) {
804 char *s = strstr(list, "pci");
807 * check if the string is something like pciVVVV,DDDD.RR
808 * or just pciVVVV,DDDD
810 if (s && s[7] == ',' &&
811 (s[12] == '.' || s[12] == 0)) {
813 *vendor = simple_strtol(s, NULL, 16);
816 *device = simple_strtol(s, NULL, 16);
827 int ofnode_read_addr_cells(ofnode node)
829 if (ofnode_is_np(node)) {
830 return of_n_addr_cells(ofnode_to_np(node));
832 int parent = fdt_parent_offset(gd->fdt_blob,
833 ofnode_to_offset(node));
835 return fdt_address_cells(gd->fdt_blob, parent);
839 int ofnode_read_size_cells(ofnode node)
841 if (ofnode_is_np(node)) {
842 return of_n_size_cells(ofnode_to_np(node));
844 int parent = fdt_parent_offset(gd->fdt_blob,
845 ofnode_to_offset(node));
847 return fdt_size_cells(gd->fdt_blob, parent);
851 int ofnode_read_simple_addr_cells(ofnode node)
853 if (ofnode_is_np(node))
854 return of_simple_addr_cells(ofnode_to_np(node));
856 return fdt_address_cells(gd->fdt_blob, ofnode_to_offset(node));
859 int ofnode_read_simple_size_cells(ofnode node)
861 if (ofnode_is_np(node))
862 return of_simple_size_cells(ofnode_to_np(node));
864 return fdt_size_cells(gd->fdt_blob, ofnode_to_offset(node));
867 bool ofnode_pre_reloc(ofnode node)
869 #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_TPL_BUILD)
870 /* for SPL and TPL the remaining nodes after the fdtgrep 1st pass
871 * had property dm-pre-reloc or u-boot,dm-spl/tpl.
872 * They are removed in final dtb (fdtgrep 2nd pass)
876 if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
878 if (ofnode_read_bool(node, "u-boot,dm-pre-proper"))
882 * In regular builds individual spl and tpl handling both
883 * count as handled pre-relocation for later second init.
885 if (ofnode_read_bool(node, "u-boot,dm-spl") ||
886 ofnode_read_bool(node, "u-boot,dm-tpl"))
893 int ofnode_read_resource(ofnode node, uint index, struct resource *res)
895 if (ofnode_is_np(node)) {
896 return of_address_to_resource(ofnode_to_np(node), index, res);
898 struct fdt_resource fres;
901 ret = fdt_get_resource(gd->fdt_blob, ofnode_to_offset(node),
902 "reg", index, &fres);
905 memset(res, '\0', sizeof(*res));
906 res->start = fres.start;
913 int ofnode_read_resource_byname(ofnode node, const char *name,
914 struct resource *res)
918 index = ofnode_stringlist_search(node, "reg-names", name);
922 return ofnode_read_resource(node, index, res);
925 u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr)
927 if (ofnode_is_np(node))
928 return of_translate_address(ofnode_to_np(node), in_addr);
930 return fdt_translate_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
933 u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr)
935 if (ofnode_is_np(node))
936 return of_translate_dma_address(ofnode_to_np(node), in_addr);
938 return fdt_translate_dma_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
941 int ofnode_get_dma_range(ofnode node, phys_addr_t *cpu, dma_addr_t *bus, u64 *size)
943 if (ofnode_is_np(node))
944 return of_get_dma_range(ofnode_to_np(node), cpu, bus, size);
946 return fdt_get_dma_range(gd->fdt_blob, ofnode_to_offset(node),
950 int ofnode_device_is_compatible(ofnode node, const char *compat)
952 if (ofnode_is_np(node))
953 return of_device_is_compatible(ofnode_to_np(node), compat,
956 return !fdt_node_check_compatible(gd->fdt_blob,
957 ofnode_to_offset(node),
961 ofnode ofnode_by_compatible(ofnode from, const char *compat)
963 if (of_live_active()) {
964 return np_to_ofnode(of_find_compatible_node(
965 (struct device_node *)ofnode_to_np(from), NULL,
968 return offset_to_ofnode(fdt_node_offset_by_compatible(
969 gd->fdt_blob, ofnode_to_offset(from), compat));
973 ofnode ofnode_by_prop_value(ofnode from, const char *propname,
974 const void *propval, int proplen)
976 if (of_live_active()) {
977 return np_to_ofnode(of_find_node_by_prop_value(
978 (struct device_node *)ofnode_to_np(from), propname,
981 return offset_to_ofnode(fdt_node_offset_by_prop_value(
982 gd->fdt_blob, ofnode_to_offset(from),
983 propname, propval, proplen));
987 int ofnode_write_prop(ofnode node, const char *propname, int len,
990 const struct device_node *np = ofnode_to_np(node);
992 struct property *pp_last = NULL;
993 struct property *new;
995 if (!of_live_active())
1001 for (pp = np->properties; pp; pp = pp->next) {
1002 if (strcmp(pp->name, propname) == 0) {
1003 /* Property exists -> change value */
1004 pp->value = (void *)value;
1014 /* Property does not exist -> append new property */
1015 new = malloc(sizeof(struct property));
1019 new->name = strdup(propname);
1025 new->value = (void *)value;
1029 pp_last->next = new;
1034 int ofnode_write_string(ofnode node, const char *propname, const char *value)
1036 if (!of_live_active())
1039 assert(ofnode_valid(node));
1041 debug("%s: %s = %s", __func__, propname, value);
1043 return ofnode_write_prop(node, propname, strlen(value) + 1, value);
1046 int ofnode_set_enabled(ofnode node, bool value)
1048 if (!of_live_active())
1051 assert(ofnode_valid(node));
1054 return ofnode_write_string(node, "status", "okay");
1056 return ofnode_write_string(node, "status", "disabled");