diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-03-01 19:36:40 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-03-03 09:22:39 +0100 |
commit | 7cf93538e087a792cb476008a757ab7c1c23b68c (patch) | |
tree | f6ee05b371614dbaf22eb935eee4ba41ce68b1a3 /tools | |
parent | Merge tag 'ieee802154-for-net-2023-03-02' of git://git.kernel.org/pub/scm/lin... (diff) | |
download | linux-7cf93538e087a792cb476008a757ab7c1c23b68c.tar.xz linux-7cf93538e087a792cb476008a757ab7c1c23b68c.zip |
tools: ynl: fully inherit attrs in subsets
To avoid having to repeat the entire definition of an attribute
(including the value) use the Attr object from the original set.
In fact this is already the documented expectation.
Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/net/ynl/lib/nlspec.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index 71da568e2c28..dff31dad36c5 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -95,15 +95,22 @@ class SpecAttrSet(SpecElement): self.attrs = collections.OrderedDict() self.attrs_by_val = collections.OrderedDict() - val = 0 - for elem in self.yaml['attributes']: - if 'value' in elem: - val = elem['value'] + if self.subset_of is None: + val = 0 + for elem in self.yaml['attributes']: + if 'value' in elem: + val = elem['value'] - attr = self.new_attr(elem, val) - self.attrs[attr.name] = attr - self.attrs_by_val[attr.value] = attr - val += 1 + attr = self.new_attr(elem, val) + self.attrs[attr.name] = attr + self.attrs_by_val[attr.value] = attr + val += 1 + else: + real_set = family.attr_sets[self.subset_of] + for elem in self.yaml['attributes']: + attr = real_set[elem['name']] + self.attrs[attr.name] = attr + self.attrs_by_val[attr.value] = attr def new_attr(self, elem, value): return SpecAttr(self.family, self, elem, value) |