scripts: extract_dts_includes: Generate'_0' defines only when needed
Indexed defines were systematically generated even when there was only one element to generate. So we ended up generated a lot of _0 defines. Then we needed to generate aliases to these _0 indexed defines, in order to get useful defines. For instance: #define GPIO_LEDS_0_GPIO_FLAGS_0 4 #define GPIO_LEDS_0_GPIO_PIN_0 5 #define GPIO_LEDS_0_GPIO_FLAGS GPIO_LEDS_0_GPIO_FLAGS_0 #define GPIO_LEDS_0_GPIO_PIN GPIO_LEDS_0_GPIO_PIN_0 This commit allows to generate _0 indexed define only if a property has more than one elements to define. Aliases generation to _0 indexed defines are also removed. Note: IRQ are left untouched since this is frequent to handle multiple IRQs in a driver Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
e099f3813e
commit
081c9c3bec
18 changed files with 114 additions and 107 deletions
|
@ -144,7 +144,12 @@ def extract_reg_prop(node_address, names, defs, def_label, div, post_label):
|
|||
prop_alias = {}
|
||||
addr = 0
|
||||
size = 0
|
||||
l_idx = [str(index)]
|
||||
# Check is defined should be indexed (_0, _1)
|
||||
if index == 0 and len(props) < 3:
|
||||
# 1 element (len 2) or no element (len 0) in props
|
||||
l_idx = []
|
||||
else:
|
||||
l_idx = [str(index)]
|
||||
|
||||
try:
|
||||
name = [names.pop(0).upper()]
|
||||
|
@ -168,12 +173,6 @@ def extract_reg_prop(node_address, names, defs, def_label, div, post_label):
|
|||
if size_cells:
|
||||
prop_alias['_'.join(l_base + name + l_size)] = l_size_fqn
|
||||
|
||||
if index == 0:
|
||||
if address_cells:
|
||||
prop_alias['_'.join(l_base + l_addr)] = l_addr_fqn
|
||||
if size_cells:
|
||||
prop_alias['_'.join(l_base + l_size)] = l_size_fqn
|
||||
|
||||
# generate defs for node aliases
|
||||
if node_address in aliases:
|
||||
for i in aliases[node_address]:
|
||||
|
@ -250,36 +249,44 @@ def extract_cells(node_address, yaml, prop, names, index, prefix, defs,
|
|||
except:
|
||||
name = []
|
||||
|
||||
# Get number of cells per element of current property
|
||||
for k in reduced[cell_parent]['props'].keys():
|
||||
if k[0] == '#' and '-cells' in k:
|
||||
num_cells = reduced[cell_parent]['props'].get(k)
|
||||
|
||||
# Generate label for each field of the property element
|
||||
l_cell = [str(cell_yaml.get('cell_string', ''))]
|
||||
l_base = def_label.split('/')
|
||||
l_base += prefix
|
||||
l_idx = [str(index)]
|
||||
# Check if #define should be indexed (_0, _1, ...)
|
||||
if index == 0 and len(props) < (num_cells + 2):
|
||||
# Less than 2 elements in prop_values (ie len < num_cells + phandle + 1)
|
||||
# Indexing is not needed
|
||||
l_idx = []
|
||||
else:
|
||||
l_idx = [str(index)]
|
||||
|
||||
prop_def = {}
|
||||
prop_alias = {}
|
||||
|
||||
for k in reduced[cell_parent]['props'].keys():
|
||||
if k[0] == '#' and '-cells' in k:
|
||||
for i in range(reduced[cell_parent]['props'].get(k)):
|
||||
l_cellname = [str(cell_yaml['#cells'][i]).upper()]
|
||||
if l_cell == l_cellname:
|
||||
label = l_base + l_cell + l_idx
|
||||
else:
|
||||
label = l_base + l_cell + l_cellname + l_idx
|
||||
label_name = l_base + name + l_cellname
|
||||
prop_def['_'.join(label)] = props.pop(0)
|
||||
if len(name):
|
||||
prop_alias['_'.join(label_name)] = '_'.join(label)
|
||||
# Generate label for each field of the property element
|
||||
for i in range(num_cells):
|
||||
l_cellname = [str(cell_yaml['#cells'][i]).upper()]
|
||||
if l_cell == l_cellname:
|
||||
label = l_base + l_cell + l_idx
|
||||
else:
|
||||
label = l_base + l_cell + l_cellname + l_idx
|
||||
label_name = l_base + name + l_cellname
|
||||
prop_def['_'.join(label)] = props.pop(0)
|
||||
if len(name):
|
||||
prop_alias['_'.join(label_name)] = '_'.join(label)
|
||||
|
||||
if index == 0:
|
||||
prop_alias['_'.join(label[:-1])] = '_'.join(label)
|
||||
|
||||
# generate defs for node aliases
|
||||
if node_address in aliases:
|
||||
for i in aliases[node_address]:
|
||||
alias_label = convert_string_to_label(i)
|
||||
alias = [alias_label] + label[1:-1]
|
||||
prop_alias['_'.join(alias)] = '_'.join(label[:-1])
|
||||
# generate defs for node aliases
|
||||
if node_address in aliases:
|
||||
for i in aliases[node_address]:
|
||||
alias_label = convert_string_to_label(i)
|
||||
alias = [alias_label] + label[1:-1]
|
||||
prop_alias['_'.join(alias)] = '_'.join(label[:-1])
|
||||
|
||||
insert_defs(node_address, defs, prop_def, prop_alias)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue