diff --git a/src/nouveau/headers/struct_parser.py b/src/nouveau/headers/struct_parser.py index d34baa4510a..06e3da18411 100644 --- a/src/nouveau/headers/struct_parser.py +++ b/src/nouveau/headers/struct_parser.py @@ -25,6 +25,7 @@ TEMPLATE_RS = Template("""\ use std::ops::Range; % for s in structs: +pub const ${s.name}_MAX_BIT: usize = ${s.max_bit}; % for f in s.fields: % if f.stride: #[inline] @@ -85,9 +86,11 @@ class Struct(object): def __init__(self, name): self.name = name self.fields = [] + self.max_bit = 0 def add_field(self, name, lo, hi, stride=0): self.fields.append(Field(name, lo, hi, stride)) + self.max_bit = max(self.max_bit, hi) DRF_RE = re.compile(r'(?P[0-9]+):(?P[0-9]+)') FIELD_NAME_RE = re.compile(r'_?(?P[0-9]+)?_?(?P.*)')