@@ -408,7 +408,8 @@ class DtbPlatdata():
re_ids = re.compile(r'struct udevice_id (.*)\[\]\s*=')
# Matches the references to the udevice_id list
- re_of_match = re.compile(r'\.of_match\s*=\s*([a-z0-9_]+),')
+ re_of_match = re.compile(
+ r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,')
# Matches the header/size information for priv
re_priv = re.compile(r'^\s*DM_PRIV\((.*)\)$')
@@ -431,7 +432,7 @@ class DtbPlatdata():
if id_m:
uclass_id = id_m.group(1)
elif id_of_match:
- compat = id_of_match.group(1)
+ compat = id_of_match.group(2)
elif '};' in line:
if uclass_id and compat:
if compat not in of_match:
@@ -1009,3 +1009,23 @@ U_BOOT_DRIVER(i2c_tegra) = {
self.assertIn(
"file.c: Unknown compatible var 'tegra_i2c_ids' (found: tegra_i2c_ids2)",
str(e.exception))
+
+ def testOfmatch(self):
+ """Test detection of of_match_ptr() member"""
+ 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,
+ .of_match = of_match_ptr(tegra_i2c_ids),
+};
+'''
+ dpd = dtb_platdata.DtbPlatdata(None, False, False)
+ dpd._parse_driver('file.c', buff)
+ self.assertIn('i2c_tegra', dpd._drivers)
+ drv = dpd._drivers['i2c_tegra']
+ self.assertEqual('i2c_tegra', drv.name)
Update the regex for the of_match member to allow of_match_ptr() so it matches both: .of_match = apl_hostbridge_ids, and .of_match = of_match_ptr(apl_hostbridge_ids), Without this, dtoc emits warnings and cannot find the drivers. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) tools/dtoc/dtb_platdata.py | 5 +++-- tools/dtoc/test_dtoc.py | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-)