Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: ynl-gen: rename basic presence from 'bit' to 'present'

Internal change to the code gen. Rename how we indicate a type
has a single bit presence from using a 'bit' string to 'present'.
This is a noop in terms of generated code but will make next
breaking change easier.

Reviewed-by: David Wei <dw@davidwei.uk>
Link: https://patch.msgid.link/20250505165208.248049-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+6 -6
+6 -6
tools/net/ynl/pyynl/ynl_gen_c.py
··· 142 142 return self.is_recursive() and not ri.op 143 143 144 144 def presence_type(self): 145 - return 'bit' 145 + return 'present' 146 146 147 147 def presence_member(self, space, type_filter): 148 148 if self.presence_type() != type_filter: 149 149 return 150 150 151 - if self.presence_type() == 'bit': 151 + if self.presence_type() == 'present': 152 152 pfx = '__' if space == 'user' else '' 153 153 return f"{pfx}u32 {self.c_name}:1;" 154 154 ··· 217 217 cw.p(f'[{self.enum_name}] = {"{"} .name = "{self.name}", {typol}{"}"},') 218 218 219 219 def _attr_put_line(self, ri, var, line): 220 - if self.presence_type() == 'bit': 220 + if self.presence_type() == 'present': 221 221 ri.cw.p(f"if ({var}->_present.{self.c_name})") 222 222 elif self.presence_type() == 'len': 223 223 ri.cw.p(f"if ({var}->_present.{self.c_name}_len)") ··· 250 250 if not self.is_multi_val(): 251 251 ri.cw.p("if (ynl_attr_validate(yarg, attr))") 252 252 ri.cw.p("return YNL_PARSE_CB_ERROR;") 253 - if self.presence_type() == 'bit': 253 + if self.presence_type() == 'present': 254 254 ri.cw.p(f"{var}->_present.{self.c_name} = 1;") 255 255 256 256 if init_lines: ··· 281 281 presence = f"{var}->{'.'.join(ref[:i] + [''])}_present.{ref[i]}" 282 282 # Every layer below last is a nest, so we know it uses bit presence 283 283 # last layer is "self" and may be a complex type 284 - if i == len(ref) - 1 and self.presence_type() != 'bit': 284 + if i == len(ref) - 1 and self.presence_type() != 'present': 285 285 continue 286 286 code.append(presence + ' = 1;') 287 287 ref_path = '.'.join(ref[:-1]) ··· 2188 2188 2189 2189 meta_started = False 2190 2190 for _, attr in struct.member_list(): 2191 - for type_filter in ['len', 'bit']: 2191 + for type_filter in ['len', 'present']: 2192 2192 line = attr.presence_member(ri.ku_space, type_filter) 2193 2193 if line: 2194 2194 if not meta_started: