summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_src_scan.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-04 12:19:49 -0600
committerSimon Glass <sjg@chromium.org>2021-07-21 10:27:34 -0600
commit43ba4926702ca0c6d896b8d318b4c596979d2f32 (patch)
tree8e67bec3f0f6bbcca698c2931f31f4314da6db72 /tools/dtoc/test_src_scan.py
parent86ff01e890a72fb2b8cefab542d4b9123fe83036 (diff)
dtoc: Detect drivers which do not parse correctly
At present if a driver is missing a uclass or compatible stirng, this is silently ignored. This makes sense in most cases, particularly for the compatible string, since it is not required except when the driver is used with of-platdata. But it is also not very helpful. When there is some sort of problem with a driver, the missing compatible string (for example) may be the cause. Add a warning in this case, showing it only for drivers which are used by the build. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
Diffstat (limited to 'tools/dtoc/test_src_scan.py')
-rw-r--r--tools/dtoc/test_src_scan.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py
index 62500e80fe7..f03cf8ed7c7 100644
--- a/tools/dtoc/test_src_scan.py
+++ b/tools/dtoc/test_src_scan.py
@@ -581,3 +581,41 @@ rockchip_rk3288_grf: WARNING: the driver rockchip_rk3288_grf was not found in th
''',
stdout.getvalue())
self.assertIn('tegra_i2c_ids', stdout.getvalue())
+
+ def scan_uclass_warning(self):
+ """Test a missing .uclass in the driver"""
+ buff = '''
+static const struct udevice_id tegra_i2c_ids[] = {
+ { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 },
+ { }
+};
+
+U_BOOT_DRIVER(i2c_tegra) = {
+ .name = "i2c_tegra",
+ .of_match = tegra_i2c_ids,
+};
+'''
+ scan = src_scan.Scanner(None, None)
+ scan._parse_driver('file.c', buff)
+ self.assertEqual(
+ {'i2c_tegra': {'Missing .uclass in file.c'}},
+ scan._warnings)
+
+ def scan_compat_warning(self):
+ """Test a missing .compatible in the driver"""
+ buff = '''
+static const struct udevice_id tegra_i2c_ids[] = {
+ { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 },
+ { }
+};
+
+U_BOOT_DRIVER(i2c_tegra) = {
+ .name = "i2c_tegra",
+ .id = UCLASS_I2C,
+};
+'''
+ scan = src_scan.Scanner(None, None)
+ scan._parse_driver('file.c', buff)
+ self.assertEqual(
+ {'i2c_tegra': {'Missing .compatible in file.c'}},
+ scan._warnings)