Coverage Report

Created: 2026-03-11 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/u-boot/scripts/dtc/libfdt/fdt_wip.c
Line
Count
Source
1
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
2
/*
3
 * libfdt - Flat Device Tree manipulation
4
 * Copyright (C) 2006 David Gibson, IBM Corporation.
5
 */
6
#include "libfdt_env.h"
7
8
#include <fdt.h>
9
#include <libfdt.h>
10
11
#include "libfdt_internal.h"
12
13
int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
14
          const char *name, int namelen,
15
          uint32_t idx, const void *val,
16
          int len)
17
0
{
18
0
  void *propval;
19
0
  int proplen;
20
21
0
  propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
22
0
          &proplen);
23
0
  if (!propval)
24
0
    return proplen;
25
26
0
  if ((unsigned)proplen < (len + idx))
27
0
    return -FDT_ERR_NOSPACE;
28
29
0
  memcpy((char *)propval + idx, val, len);
30
0
  return 0;
31
0
}
32
33
int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
34
      const void *val, int len)
35
0
{
36
0
  const void *propval;
37
0
  int proplen;
38
39
0
  propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
40
0
  if (!propval)
41
0
    return proplen;
42
43
0
  if (proplen != len)
44
0
    return -FDT_ERR_NOSPACE;
45
46
0
  return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
47
0
               strlen(name), 0,
48
0
               val, len);
49
0
}
50
51
static void fdt_nop_region_(void *start, int len)
52
0
{
53
0
  fdt32_t *p;
54
55
0
  for (p = start; (char *)p < ((char *)start + len); p++)
56
0
    *p = cpu_to_fdt32(FDT_NOP);
57
0
}
58
59
int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
60
0
{
61
0
  struct fdt_property *prop;
62
0
  int len;
63
64
0
  prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
65
0
  if (!prop)
66
0
    return len;
67
68
0
  fdt_nop_region_(prop, len + sizeof(*prop));
69
70
0
  return 0;
71
0
}
72
73
int fdt_node_end_offset_(void *fdt, int offset)
74
0
{
75
0
  int depth = 0;
76
77
0
  while ((offset >= 0) && (depth >= 0))
78
0
    offset = fdt_next_node(fdt, offset, &depth);
79
80
0
  return offset;
81
0
}
82
83
int fdt_nop_node(void *fdt, int nodeoffset)
84
0
{
85
0
  int endoffset;
86
87
0
  endoffset = fdt_node_end_offset_(fdt, nodeoffset);
88
0
  if (endoffset < 0)
89
0
    return endoffset;
90
91
0
  fdt_nop_region_(fdt_offset_ptr_w(fdt, nodeoffset, 0),
92
0
      endoffset - nodeoffset);
93
0
  return 0;
94
0
}