Commit dddc9f53 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

tools: ynl-gen: don't generate enum types if unnamed

If attr set or enum has empty enum name we need to use u32 or int
as function arguments and struct members.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d4813b11
...@@ -268,7 +268,8 @@ class TypeScalar(Type): ...@@ -268,7 +268,8 @@ class TypeScalar(Type):
else: else:
self.is_bitfield = False self.is_bitfield = False
if 'enum' in self.attr and not self.is_bitfield: maybe_enum = not self.is_bitfield and 'enum' in self.attr
if maybe_enum and self.family.consts[self.attr['enum']].enum_name:
self.type_name = f"enum {self.family.name}_{c_lower(self.attr['enum'])}" self.type_name = f"enum {self.family.name}_{c_lower(self.attr['enum'])}"
else: else:
self.type_name = '__' + self.type self.type_name = '__' + self.type
...@@ -652,7 +653,14 @@ class EnumEntry(SpecEnumEntry): ...@@ -652,7 +653,14 @@ class EnumEntry(SpecEnumEntry):
class EnumSet(SpecEnumSet): class EnumSet(SpecEnumSet):
def __init__(self, family, yaml): def __init__(self, family, yaml):
self.render_name = c_lower(family.name + '-' + yaml['name']) self.render_name = c_lower(family.name + '-' + yaml['name'])
self.enum_name = 'enum ' + self.render_name
if 'enum-name' in yaml:
if yaml['enum-name']:
self.enum_name = 'enum ' + c_lower(yaml['enum-name'])
else:
self.enum_name = None
else:
self.enum_name = 'enum ' + self.render_name
self.value_pfx = yaml.get('name-prefix', f"{family.name}-{yaml['name']}-") self.value_pfx = yaml.get('name-prefix', f"{family.name}-{yaml['name']}-")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment