diff options
author | Simon Glass <sjg@chromium.org> | 2021-02-03 06:01:11 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-03-22 19:23:27 +1300 |
commit | 50aae3e62d57931afcafec7eb973f222cb3131c7 (patch) | |
tree | 3134e1b2b7911642191b5bb3f2d8b318853a004d /tools/dtoc/src_scan.py | |
parent | 337d6972f5f5294971db52809f83c0454cb4e7ba (diff) |
dtoc: Support processing the root node
The device for the root node is normally bound by driver model on init.
With devices being instantiated at build time, we must handle the root
device also.
Add support for processing the root node, which may not have a compatible
string.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/src_scan.py')
-rw-r--r-- | tools/dtoc/src_scan.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py index 8619206a8d4..114212cfe2d 100644 --- a/tools/dtoc/src_scan.py +++ b/tools/dtoc/src_scan.py @@ -33,6 +33,8 @@ def conv_name_to_c(name): new = new.replace('-', '_') new = new.replace(',', '_') new = new.replace('.', '_') + if new == '/': + return 'root' return new def get_compat_name(node): @@ -250,7 +252,10 @@ class Scanner: In case of no match found, the return will be the same as get_compat_name() """ - compat_list_c = get_compat_name(node) + if not node.parent: + compat_list_c = ['root_driver'] + else: + compat_list_c = get_compat_name(node) for compat_c in compat_list_c: if not compat_c in self._drivers.keys(): @@ -509,21 +514,23 @@ class Scanner: elif m_hdr: driver.headers.append(m_hdr.group(1)) elif '};' in line: - if driver.uclass_id and compat: - if compat not in of_match: - raise ValueError( - "%s: Unknown compatible var '%s' (found: %s)" % - (fname, compat, ','.join(of_match.keys()))) - driver.compat = of_match[compat] - - # This needs to be deterministic, since a driver may - # have multiple compatible strings pointing to it. - # We record the one earliest in the alphabet so it - # will produce the same result on all machines. - for compat_id in of_match[compat]: - old = self._compat_to_driver.get(compat_id) - if not old or driver.name < old.name: - self._compat_to_driver[compat_id] = driver + is_root = driver.name == 'root_driver' + if driver.uclass_id and (compat or is_root): + if not is_root: + if compat not in of_match: + raise ValueError( + "%s: Unknown compatible var '%s' (found: %s)" % + (fname, compat, ','.join(of_match.keys()))) + driver.compat = of_match[compat] + + # This needs to be deterministic, since a driver may + # have multiple compatible strings pointing to it. + # We record the one earliest in the alphabet so it + # will produce the same result on all machines. + for compat_id in of_match[compat]: + old = self._compat_to_driver.get(compat_id) + if not old or driver.name < old.name: + self._compat_to_driver[compat_id] = driver drivers[driver.name] = driver else: # The driver does not have a uclass or compat string. |