This is similar to existing attr-cnt-name in the attributes
to allow changing the name of the 'count' enum entry.
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
Documentation/netlink/genetlink-legacy.yaml | 3 +++
tools/net/ynl/ynl-gen-c.py | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 8db0e22fa72c..83f874ae7198 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -119,6 +119,9 @@ additionalProperties: False
type: string
# End genetlink-c
# Start genetlink-legacy
+ attr-cnt-name:
+ description: Name of the render-max counter enum entry.
+ type: string
members:
description: List of struct members. Only scalars and strings members allowed.
type: array
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index c48b69071111..210972b4796a 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -798,6 +798,7 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
self.user_type = 'int'
self.value_pfx = yaml.get('name-prefix', f"{family.ident_name}-{yaml['name']}-")
+ self.attr_cnt_name = yaml.get('attr-cnt-name', None)
super().__init__(family, yaml)
@@ -2468,9 +2469,12 @@ _C_KW = {
max_val = f' = {enum.get_mask()},'
cw.p(max_name + max_val)
else:
+ cnt_name = enum.attr_cnt_name
max_name = c_upper(name_pfx + 'max')
- cw.p('__' + max_name + ',')
- cw.p(max_name + ' = (__' + max_name + ' - 1)')
+ if not cnt_name:
+ cnt_name = '__' + c_upper(name_pfx + 'max')
+ cw.p(cnt_name + ',')
+ cw.p(max_name + ' = (' + cnt_name + ' - 1)')
cw.block_end(line=';')
cw.nl()
elif const['type'] == 'const':
--
2.47.0