Number of size cells for this node
"""
parent = node.parent
+ if parent and not parent.props:
+ raise ValueError("Parent node '%s' has no properties - do you need u-boot,dm-spl or similar?" %
+ parent.path)
num_addr, num_size = 2, 2
if parent:
addr_prop = parent.props.get('#address-cells')
reg.value = [reg.value]
if len(reg.value) % total:
raise ValueError(
- "Node '%s' reg property has %d cells "
+ "Node '%s' (parent '%s') reg property has %d cells "
'which is not a multiple of na + ns = %d + %d)' %
- (node.name, len(reg.value), num_addr, num_size))
+ (node.name, node.parent.name, len(reg.value), num_addr,
+ num_size))
reg.num_addr = num_addr
reg.num_size = num_size
if num_addr > 1 or num_size > 1:
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2017 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ i2c@0 {
+ pmic@9 {
+ compatible = "sandbox,pmic";
+ u-boot,dm-pre-reloc;
+ reg = <9>;
+ low-power;
+ };
+ };
+};
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2017 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ i2c@0 {
+ compatible = "sandbox,i2c";
+ u-boot,dm-pre-reloc;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pmic@9 {
+ compatible = "sandbox,pmic";
+ u-boot,dm-pre-reloc;
+ reg = <9>;
+ low-power;
+
+ gpio {
+ compatible = "sandbox,gpio";
+ };
+ };
+ };
+};
with self.assertRaises(ValueError) as exc:
self.run_test(['struct'], dtb_file, output)
self.assertIn(
- "Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)",
+ "Node 'spl-test' (parent '/') reg property has 3 cells which is not a multiple of na + ns = 1 + 1)",
str(exc.exception))
def test_add_prop(self):
self.assertEqual(
'Warning: Cannot find header file for struct dm_test_uc_priv',
stdout.getvalue().strip())
+
+ def test_missing_props(self):
+ """Test detection of a parent node with no properties"""
+ dtb_file = get_dtb_file('dtoc_test_noprops.dts', capture_stderr=True)
+ output = tools.GetOutputFilename('output')
+ with self.assertRaises(ValueError) as exc:
+ self.run_test(['struct'], dtb_file, output)
+ self.assertIn("Parent node '/i2c@0' has no properties - do you need",
+ str(exc.exception))
+
+ def test_single_reg(self):
+ """Test detection of a parent node with no properties"""
+ dtb_file = get_dtb_file('dtoc_test_single_reg.dts')
+ output = tools.GetOutputFilename('output')
+ self.run_test(['struct'], dtb_file, output)