mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 20:54:10 +08:00
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: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d4813b11d6
commit
dddc9f53da
@ -268,7 +268,8 @@ class TypeScalar(Type):
|
||||
else:
|
||||
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'])}"
|
||||
else:
|
||||
self.type_name = '__' + self.type
|
||||
@ -652,7 +653,14 @@ class EnumEntry(SpecEnumEntry):
|
||||
class EnumSet(SpecEnumSet):
|
||||
def __init__(self, family, yaml):
|
||||
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']}-")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user