Skip to content

Commit 4201d05

Browse files
committed
scripts/dtc: Update to upstream version v1.4.5-3-gb1a60033c110
This adds the following commits from upstream: b1a60033c110 tests: Add a test for overlays syntactic sugar 737b2df39cc8 overlay: Add syntactic sugar version of overlays 497432fd2131 checks: Use proper format modifier for size_t 22a65c5331c2 dtc: Bump version to v1.4.5 c575d8059fff Add fdtoverlay to .gitignore b6a6f9490d19 fdtoverlay: Sanity check blob size 8c1eb1526d2d pylibfdt: Use Python2 explicitly ee3d26f6960b checks: add interrupts property check c1e7738988f5 checks: add gpio binding properties check b3bbac02d5e3 checks: add phandle with arg property checks fe50bd1ecc1d fdtget: Split out cell list display into a new function 62d812308d11 README: Add a note about test_tree1.dts 5bed86aee9e8 pylibfdt: Add support for fdt_subnode_offset() 46f31b65b3b3 pylibfdt: Add support for fdt_node_offset_by_phandle() a3ae43723687 pylibfdt: Add support for fdt_parent_offset() a198af80344c pylibfdt: Add support for fdt_get_phandle() b9eba92ea50f tests: Return a failure code when any tests fail 155faf6cc209 pylibfdt: Use local pylibfdt module 50e5cd07f325 pylibfdt: Add a test for use of uint32_t ab78860f09f5 pylibfdt: Add stdint include to fix uint32_t 36f511fb1113 tests: Add stacked overlay tests on fdtoverlay 1bb00655d3e5 fdt: Allow stacked overlays phandle references a33c2247ac8d Introduce fdt_setprop_placeholder() method 0016f8c2aa32 dtc: change default phandles to ePAPR style instead of both e3b9a9588a35 tests: fdtoverlay unit test 42409146f2db fdtoverlay: A tool that applies overlays aae22722fc8d manual: Document missing options 13ce6e1c2fc4 dtc: fix sprintf() format string error, again d990b8013889 Makefile: Fix build on MSYS2 and Cygwin 51f56dedf8ea Clean up shared library compile/link options 21a2bc896e3d Suppress expected error message in fdtdump test 2a42b14d0d03 dtc: check.c fix compile error a10cb3c818d3 Fix get_node_by_path string equality check 548aea2c436a fdtdump: Discourage use of fdtdump c2258841a785 fdtdump: Fix over-zealous version check 9067ee4be0e6 Fix a few whitespace and style nits e56f2b07be38 pylibfdt: Use setup.py to build the swig file 896f1c133265 pylibfdt: Use Makefile constructs to implement NO_PYTHON 90db6d9989ca pylibfdt: Allow setup.py to operate stand-alone e20d9658cd8f Add Coverity Scan support b04a2cf08862 pylibfdt: Fix code style in setup.py 1c5170d3a466 pylibfdt: Rename libfdt.swig to libfdt.i 580a9f6c2880 Add a libfdt function to write a property placeholder ab15256d8d02 pylibfdt: Use the call function to simplify the Makefile 9f2e3a3a1f19 pylibfdt: Use the correct libfdt version in the module e91c652af215 pylibfdt: Enable installation of Python module 8a892fd85d94 pylibfdt: Allow building to be disabled 741cdff85d3e .travis.yml: Add builds with and without Python library prerequisites 14c4171f4f9a pylibfdt: Use package_dir to set the package directory 89a5062ab231 pylibfdt: Use environment to pass C flags and files 4e0e0d049757 pylibfdt: Allow pkg-config to be supplied in the environment 6afd7d9688f5 Correct typo: s/pylibgfdt/pylibfdt/ Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 4322323 commit 4201d05

16 files changed

Lines changed: 1603 additions & 230 deletions

‎scripts/dtc/checks.c‎

Lines changed: 281 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
873873
while (size--)
874874
reg = (reg << 32) | fdt32_to_cpu(*(cells++));
875875

876-
snprintf(unit_addr, sizeof(unit_addr), "%llx", (unsigned long long)reg);
876+
snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg);
877877
if (!streq(unitname, unit_addr))
878878
FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
879879
node->fullpath, unit_addr);
@@ -956,6 +956,265 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
956956
WARNING(obsolete_chosen_interrupt_controller,
957957
check_obsolete_chosen_interrupt_controller, NULL);
958958

959+
struct provider {
960+
const char *prop_name;
961+
const char *cell_name;
962+
bool optional;
963+
};
964+
965+
static void check_property_phandle_args(struct check *c,
966+
struct dt_info *dti,
967+
struct node *node,
968+
struct property *prop,
969+
const struct provider *provider)
970+
{
971+
struct node *root = dti->dt;
972+
int cell, cellsize = 0;
973+
974+
if (prop->val.len % sizeof(cell_t)) {
975+
FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
976+
prop->name, prop->val.len, sizeof(cell_t), node->fullpath);
977+
return;
978+
}
979+
980+
for (cell = 0; cell < prop->val.len / sizeof(cell_t); cell += cellsize + 1) {
981+
struct node *provider_node;
982+
struct property *cellprop;
983+
int phandle;
984+
985+
phandle = propval_cell_n(prop, cell);
986+
/*
987+
* Some bindings use a cell value 0 or -1 to skip over optional
988+
* entries when each index position has a specific definition.
989+
*/
990+
if (phandle == 0 || phandle == -1) {
991+
cellsize = 0;
992+
continue;
993+
}
994+
995+
/* If we have markers, verify the current cell is a phandle */
996+
if (prop->val.markers) {
997+
struct marker *m = prop->val.markers;
998+
for_each_marker_of_type(m, REF_PHANDLE) {
999+
if (m->offset == (cell * sizeof(cell_t)))
1000+
break;
1001+
}
1002+
if (!m)
1003+
FAIL(c, dti, "Property '%s', cell %d is not a phandle reference in %s",
1004+
prop->name, cell, node->fullpath);
1005+
}
1006+
1007+
provider_node = get_node_by_phandle(root, phandle);
1008+
if (!provider_node) {
1009+
FAIL(c, dti, "Could not get phandle node for %s:%s(cell %d)",
1010+
node->fullpath, prop->name, cell);
1011+
break;
1012+
}
1013+
1014+
cellprop = get_property(provider_node, provider->cell_name);
1015+
if (cellprop) {
1016+
cellsize = propval_cell(cellprop);
1017+
} else if (provider->optional) {
1018+
cellsize = 0;
1019+
} else {
1020+
FAIL(c, dti, "Missing property '%s' in node %s or bad phandle (referred from %s:%s[%d])",
1021+
provider->cell_name,
1022+
provider_node->fullpath,
1023+
node->fullpath, prop->name, cell);
1024+
break;
1025+
}
1026+
1027+
if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) {
1028+
FAIL(c, dti, "%s property size (%d) too small for cell size %d in %s",
1029+
prop->name, prop->val.len, cellsize, node->fullpath);
1030+
}
1031+
}
1032+
}
1033+
1034+
static void check_provider_cells_property(struct check *c,
1035+
struct dt_info *dti,
1036+
struct node *node)
1037+
{
1038+
struct provider *provider = c->data;
1039+
struct property *prop;
1040+
1041+
prop = get_property(node, provider->prop_name);
1042+
if (!prop)
1043+
return;
1044+
1045+
check_property_phandle_args(c, dti, node, prop, provider);
1046+
}
1047+
#define WARNING_PROPERTY_PHANDLE_CELLS(nm, propname, cells_name, ...) \
1048+
static struct provider nm##_provider = { (propname), (cells_name), __VA_ARGS__ }; \
1049+
WARNING(nm##_property, check_provider_cells_property, &nm##_provider, &phandle_references);
1050+
1051+
WARNING_PROPERTY_PHANDLE_CELLS(clocks, "clocks", "#clock-cells");
1052+
WARNING_PROPERTY_PHANDLE_CELLS(cooling_device, "cooling-device", "#cooling-cells");
1053+
WARNING_PROPERTY_PHANDLE_CELLS(dmas, "dmas", "#dma-cells");
1054+
WARNING_PROPERTY_PHANDLE_CELLS(hwlocks, "hwlocks", "#hwlock-cells");
1055+
WARNING_PROPERTY_PHANDLE_CELLS(interrupts_extended, "interrupts-extended", "#interrupt-cells");
1056+
WARNING_PROPERTY_PHANDLE_CELLS(io_channels, "io-channels", "#io-channel-cells");
1057+
WARNING_PROPERTY_PHANDLE_CELLS(iommus, "iommus", "#iommu-cells");
1058+
WARNING_PROPERTY_PHANDLE_CELLS(mboxes, "mboxes", "#mbox-cells");
1059+
WARNING_PROPERTY_PHANDLE_CELLS(msi_parent, "msi-parent", "#msi-cells", true);
1060+
WARNING_PROPERTY_PHANDLE_CELLS(mux_controls, "mux-controls", "#mux-control-cells");
1061+
WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells");
1062+
WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");
1063+
WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");
1064+
WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
1065+
WARNING_PROPERTY_PHANDLE_CELLS(sound_dais, "sound-dais", "#sound-dai-cells");
1066+
WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
1067+
1068+
static bool prop_is_gpio(struct property *prop)
1069+
{
1070+
char *str;
1071+
1072+
/*
1073+
* *-gpios and *-gpio can appear in property names,
1074+
* so skip over any false matches (only one known ATM)
1075+
*/
1076+
if (strstr(prop->name, "nr-gpio"))
1077+
return false;
1078+
1079+
str = strrchr(prop->name, '-');
1080+
if (str)
1081+
str++;
1082+
else
1083+
str = prop->name;
1084+
if (!(streq(str, "gpios") || streq(str, "gpio")))
1085+
return false;
1086+
1087+
return true;
1088+
}
1089+
1090+
static void check_gpios_property(struct check *c,
1091+
struct dt_info *dti,
1092+
struct node *node)
1093+
{
1094+
struct property *prop;
1095+
1096+
/* Skip GPIO hog nodes which have 'gpios' property */
1097+
if (get_property(node, "gpio-hog"))
1098+
return;
1099+
1100+
for_each_property(node, prop) {
1101+
struct provider provider;
1102+
1103+
if (!prop_is_gpio(prop))
1104+
continue;
1105+
1106+
provider.prop_name = prop->name;
1107+
provider.cell_name = "#gpio-cells";
1108+
provider.optional = false;
1109+
check_property_phandle_args(c, dti, node, prop, &provider);
1110+
}
1111+
1112+
}
1113+
WARNING(gpios_property, check_gpios_property, NULL, &phandle_references);
1114+
1115+
static void check_deprecated_gpio_property(struct check *c,
1116+
struct dt_info *dti,
1117+
struct node *node)
1118+
{
1119+
struct property *prop;
1120+
1121+
for_each_property(node, prop) {
1122+
char *str;
1123+
1124+
if (!prop_is_gpio(prop))
1125+
continue;
1126+
1127+
str = strstr(prop->name, "gpio");
1128+
if (!streq(str, "gpio"))
1129+
continue;
1130+
1131+
FAIL(c, dti, "'[*-]gpio' is deprecated, use '[*-]gpios' instead for %s:%s",
1132+
node->fullpath, prop->name);
1133+
}
1134+
1135+
}
1136+
CHECK(deprecated_gpio_property, check_deprecated_gpio_property, NULL);
1137+
1138+
static bool node_is_interrupt_provider(struct node *node)
1139+
{
1140+
struct property *prop;
1141+
1142+
prop = get_property(node, "interrupt-controller");
1143+
if (prop)
1144+
return true;
1145+
1146+
prop = get_property(node, "interrupt-map");
1147+
if (prop)
1148+
return true;
1149+
1150+
return false;
1151+
}
1152+
static void check_interrupts_property(struct check *c,
1153+
struct dt_info *dti,
1154+
struct node *node)
1155+
{
1156+
struct node *root = dti->dt;
1157+
struct node *irq_node = NULL, *parent = node;
1158+
struct property *irq_prop, *prop = NULL;
1159+
int irq_cells, phandle;
1160+
1161+
irq_prop = get_property(node, "interrupts");
1162+
if (!irq_prop)
1163+
return;
1164+
1165+
if (irq_prop->val.len % sizeof(cell_t))
1166+
FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
1167+
irq_prop->name, irq_prop->val.len, sizeof(cell_t),
1168+
node->fullpath);
1169+
1170+
while (parent && !prop) {
1171+
if (parent != node && node_is_interrupt_provider(parent)) {
1172+
irq_node = parent;
1173+
break;
1174+
}
1175+
1176+
prop = get_property(parent, "interrupt-parent");
1177+
if (prop) {
1178+
phandle = propval_cell(prop);
1179+
irq_node = get_node_by_phandle(root, phandle);
1180+
if (!irq_node) {
1181+
FAIL(c, dti, "Bad interrupt-parent phandle for %s",
1182+
node->fullpath);
1183+
return;
1184+
}
1185+
if (!node_is_interrupt_provider(irq_node))
1186+
FAIL(c, dti,
1187+
"Missing interrupt-controller or interrupt-map property in %s",
1188+
irq_node->fullpath);
1189+
1190+
break;
1191+
}
1192+
1193+
parent = parent->parent;
1194+
}
1195+
1196+
if (!irq_node) {
1197+
FAIL(c, dti, "Missing interrupt-parent for %s", node->fullpath);
1198+
return;
1199+
}
1200+
1201+
prop = get_property(irq_node, "#interrupt-cells");
1202+
if (!prop) {
1203+
FAIL(c, dti, "Missing #interrupt-cells in interrupt-parent %s",
1204+
irq_node->fullpath);
1205+
return;
1206+
}
1207+
1208+
irq_cells = propval_cell(prop);
1209+
if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) {
1210+
FAIL(c, dti,
1211+
"interrupts size is (%d), expected multiple of %d in %s",
1212+
irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)),
1213+
node->fullpath);
1214+
}
1215+
}
1216+
WARNING(interrupts_property, check_interrupts_property, &phandle_references);
1217+
9591218
static struct check *check_table[] = {
9601219
&duplicate_node_names, &duplicate_property_names,
9611220
&node_name_chars, &node_name_format, &property_name_chars,
@@ -987,6 +1246,27 @@ static struct check *check_table[] = {
9871246
&avoid_default_addr_size,
9881247
&obsolete_chosen_interrupt_controller,
9891248

1249+
&clocks_property,
1250+
&cooling_device_property,
1251+
&dmas_property,
1252+
&hwlocks_property,
1253+
&interrupts_extended_property,
1254+
&io_channels_property,
1255+
&iommus_property,
1256+
&mboxes_property,
1257+
&msi_parent_property,
1258+
&mux_controls_property,
1259+
&phys_property,
1260+
&power_domains_property,
1261+
&pwms_property,
1262+
&resets_property,
1263+
&sound_dais_property,
1264+
&thermal_sensors_property,
1265+
1266+
&deprecated_gpio_property,
1267+
&gpios_property,
1268+
&interrupts_property,
1269+
9901270
&always_fail,
9911271
};
9921272

‎scripts/dtc/dtc-lexer.lex.c_shipped‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ static int yy_get_next_buffer (void)
13971397
{
13981398
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
13991399
char *source = (yytext_ptr);
1400-
yy_size_t number_to_move, i;
1400+
int number_to_move, i;
14011401
int ret_val;
14021402

14031403
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@@ -1426,7 +1426,7 @@ static int yy_get_next_buffer (void)
14261426
/* Try to read more data. */
14271427

14281428
/* First move last chars to start of buffer. */
1429-
number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1429+
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
14301430

14311431
for ( i = 0; i < number_to_move; ++i )
14321432
*(dest++) = *(source++);
@@ -1508,7 +1508,7 @@ static int yy_get_next_buffer (void)
15081508
else
15091509
ret_val = EOB_ACT_CONTINUE_SCAN;
15101510

1511-
if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1511+
if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
15121512
/* Extend the array by 50%, plus the number we really need. */
15131513
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
15141514
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
@@ -1987,10 +1987,10 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
19871987
YY_BUFFER_STATE b;
19881988
char *buf;
19891989
yy_size_t n;
1990-
yy_size_t i;
1990+
int i;
19911991

19921992
/* Get memory for full buffer, including space for trailing EOB's. */
1993-
n = (yy_size_t) _yybytes_len + 2;
1993+
n = (yy_size_t) (_yybytes_len + 2);
19941994
buf = (char *) yyalloc(n );
19951995
if ( ! buf )
19961996
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );

0 commit comments

Comments
 (0)