Skip to content

Commit f95a230

Browse files
ulfalizergalak
authored andcommitted
scripts/dts: Clean up/fix extract/interrupts.py a bit
- Fix broken code that was meant to turn the 'interrupts'/'interrupts-extended' value into a list if it wasn't. list(123) will error out instead of creating [123]. - Remove weird .split('/') on macro name - Rename 'props' to 'vals'. It's the value of a single property. - Get rid of a bare 'except:' - Rename l_fqn to full_name. Accidentally stumbled upon 'fqn' probably standing for "fully qualified name", but it's not obvious. Signed-off-by: Ulf Magnusson <[email protected]>
1 parent 3b64e71 commit f95a230

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

scripts/dts/extract/interrupts.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,25 @@ class DTInterrupts(DTDirective):
2222
# compatible definition.
2323
#
2424
def extract(self, node_path, prop, names, def_label):
25-
node = reduced[node_path]
26-
27-
try:
28-
props = list(node['props'].get(prop))
29-
except:
30-
props = [node['props'].get(prop)]
25+
vals = reduced[node_path]['props'][prop]
26+
if not isinstance(vals, list):
27+
vals = [vals]
3128

3229
irq_parent = parent_irq_node(node_path)
3330
if not irq_parent:
3431
err(node_path + " has no interrupt-parent")
3532

36-
l_base = def_label.split('/')
33+
l_base = [def_label]
3734
index = 0
3835

39-
while props:
36+
while vals:
4037
prop_def = {}
4138
prop_alias = {}
4239
l_idx = [str(index)]
4340

44-
try:
41+
if names:
4542
name = [str_to_label(names.pop(0))]
46-
except:
43+
else:
4744
name = []
4845

4946
cell_yaml = get_binding(irq_parent)
@@ -54,26 +51,26 @@ def extract(self, node_path, prop, names, def_label):
5451
if l_cell_name == l_cell_prefix:
5552
l_cell_name = []
5653

57-
l_fqn = '_'.join(l_base + l_cell_prefix + l_idx + l_cell_name)
58-
prop_def[l_fqn] = props.pop(0)
54+
full_name = '_'.join(l_base + l_cell_prefix + l_idx + l_cell_name)
55+
prop_def[full_name] = vals.pop(0)
5956
add_compat_alias(node_path,
60-
'_'.join(l_cell_prefix + l_idx + l_cell_name),
61-
l_fqn, prop_alias)
57+
'_'.join(l_cell_prefix + l_idx + l_cell_name),
58+
full_name, prop_alias)
6259

63-
if len(name):
60+
if name:
6461
alias_list = l_base + l_cell_prefix + name + l_cell_name
65-
prop_alias['_'.join(alias_list)] = l_fqn
62+
prop_alias['_'.join(alias_list)] = full_name
6663
add_compat_alias(node_path,
67-
'_'.join(l_cell_prefix + name + l_cell_name),
68-
l_fqn, prop_alias)
64+
'_'.join(l_cell_prefix + name + l_cell_name),
65+
full_name, prop_alias)
6966

7067
if node_path in aliases:
7168
add_prop_aliases(
7269
node_path,
7370
lambda alias:
7471
'_'.join([str_to_label(alias)] +
7572
l_cell_prefix + name + l_cell_name),
76-
l_fqn,
73+
full_name,
7774
prop_alias)
7875

7976
index += 1

0 commit comments

Comments
 (0)