Skip to content

Commit 57d39b9

Browse files
committed
scripts: dts: Add generation of *_PARENT_LABEL macros
This patch adds generation of `*_PARENT_LABEL` macros for nodes that have a parent with a 'label' property and also have a 'label' property themselves. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent 932a33a commit 57d39b9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

scripts/dts/extract_dts_includes.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
from extract.default import default
3030

3131

32-
def extract_bus_name(node_path, def_label):
33-
label = def_label + '_BUS_NAME'
32+
def extract_parent_label(node_path, def_label, def_label_postfix):
33+
label = def_label + '_' + def_label_postfix
3434
prop_alias = {}
3535

36-
add_compat_alias(node_path, 'BUS_NAME', label, prop_alias)
36+
add_compat_alias(node_path, def_label_postfix, label, prop_alias)
3737

3838
# Generate defines for node aliases
3939
if node_path in aliases:
4040
add_prop_aliases(
4141
node_path,
42-
lambda alias: str_to_label(alias) + '_BUS_NAME',
42+
lambda alias: str_to_label(alias) + '_' + def_label_postfix,
4343
label,
4444
prop_alias)
4545

@@ -61,16 +61,21 @@ def generate_prop_defines(node_path, prop):
6161
# Generates #defines (and .conf file values) from the prop
6262
# named 'prop' on the device tree node at 'node_path'
6363

64+
parent_path = get_parent_path(node_path)
6465
binding = get_binding(node_path)
6566
if 'parent' in binding and 'bus' in binding['parent']:
6667
# If the binding specifies a parent for the node, then include the
6768
# parent in the #define's generated for the properties
68-
parent_path = get_parent_path(node_path)
6969
def_label = 'DT_' + node_label(parent_path) + '_' \
7070
+ node_label(node_path)
7171
else:
7272
def_label = 'DT_' + node_label(node_path)
7373

74+
if prop == 'label' and 'label' in reduced[parent_path]['props']:
75+
# If both the node and its parent have the 'label' property,
76+
# generate *_PARENT_LABEL #define
77+
extract_parent_label(node_path, def_label, 'PARENT_LABEL')
78+
7479
names = prop_names(reduced[node_path], prop)
7580

7681
if prop == 'reg':
@@ -172,9 +177,10 @@ def generate_bus_defines(node_path):
172177
aliases[node_path].append(node_alias)
173178

174179
# Generate *_BUS_NAME #define
175-
extract_bus_name(
180+
extract_parent_label(
176181
node_path,
177-
'DT_' + node_label(parent_path) + '_' + node_label(node_path))
182+
'DT_' + node_label(parent_path) + '_' + node_label(node_path),
183+
'BUS_NAME')
178184

179185

180186
def prop_names(node, prop_name):

0 commit comments

Comments
 (0)