mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
tools: ynl-gen: use enum name from the spec
The enum name used for id-to-str table does not handle the enum-name override in the spec correctly. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
19ed9b3d7a
commit
30c9020015
@ -755,11 +755,17 @@ class EnumSet(SpecEnumSet):
|
|||||||
if 'enum-name' in yaml:
|
if 'enum-name' in yaml:
|
||||||
if yaml['enum-name']:
|
if yaml['enum-name']:
|
||||||
self.enum_name = 'enum ' + c_lower(yaml['enum-name'])
|
self.enum_name = 'enum ' + c_lower(yaml['enum-name'])
|
||||||
|
self.user_type = self.enum_name
|
||||||
else:
|
else:
|
||||||
self.enum_name = None
|
self.enum_name = None
|
||||||
else:
|
else:
|
||||||
self.enum_name = 'enum ' + self.render_name
|
self.enum_name = 'enum ' + self.render_name
|
||||||
|
|
||||||
|
if self.enum_name:
|
||||||
|
self.user_type = self.enum_name
|
||||||
|
else:
|
||||||
|
self.user_type = 'int'
|
||||||
|
|
||||||
self.value_pfx = yaml.get('name-prefix', f"{family.name}-{yaml['name']}-")
|
self.value_pfx = yaml.get('name-prefix', f"{family.name}-{yaml['name']}-")
|
||||||
|
|
||||||
super().__init__(family, yaml)
|
super().__init__(family, yaml)
|
||||||
@ -1483,8 +1489,8 @@ def put_typol(cw, struct):
|
|||||||
|
|
||||||
def _put_enum_to_str_helper(cw, render_name, map_name, arg_name, enum=None):
|
def _put_enum_to_str_helper(cw, render_name, map_name, arg_name, enum=None):
|
||||||
args = [f'int {arg_name}']
|
args = [f'int {arg_name}']
|
||||||
if enum and not ('enum-name' in enum and not enum['enum-name']):
|
if enum:
|
||||||
args = [f'enum {render_name} {arg_name}']
|
args = [enum.user_type + ' ' + arg_name]
|
||||||
cw.write_func_prot('const char *', f'{render_name}_str', args)
|
cw.write_func_prot('const char *', f'{render_name}_str', args)
|
||||||
cw.block_start()
|
cw.block_start()
|
||||||
if enum and enum.type == 'flags':
|
if enum and enum.type == 'flags':
|
||||||
@ -1522,9 +1528,7 @@ def put_op_name(family, cw):
|
|||||||
|
|
||||||
|
|
||||||
def put_enum_to_str_fwd(family, cw, enum):
|
def put_enum_to_str_fwd(family, cw, enum):
|
||||||
args = [f'enum {enum.render_name} value']
|
args = [enum.user_type + ' value']
|
||||||
if 'enum-name' in enum and not enum['enum-name']:
|
|
||||||
args = ['int value']
|
|
||||||
cw.write_func_prot('const char *', f'{enum.render_name}_str', args, suffix=';')
|
cw.write_func_prot('const char *', f'{enum.render_name}_str', args, suffix=';')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user