Refactor find_reg_for_field()
This commit is contained in:
parent
c985c031d4
commit
37536695e1
@ -121,27 +121,21 @@ fn find_reg_for_field<'c>(
|
|||||||
reg_regex: &str,
|
reg_regex: &str,
|
||||||
field_name: &str,
|
field_name: &str,
|
||||||
) -> Option<(&'c str, &'c str)> {
|
) -> Option<(&'c str, &'c str)> {
|
||||||
rcc.fieldsets.iter().find_map(|(name, fieldset)| {
|
let reg_regex = Regex::new(reg_regex).unwrap();
|
||||||
|
|
||||||
|
for (name, fieldset) in &rcc.fieldsets {
|
||||||
// Workaround for some families that prefix register aliases with C1_, which does
|
// Workaround for some families that prefix register aliases with C1_, which does
|
||||||
// not help matching for clock name.
|
// not help matching for clock name.
|
||||||
if name.starts_with("C1") || name.starts_with("C2") {
|
if !name.starts_with("C1") && !name.starts_with("C2") && reg_regex.is_match(name) {
|
||||||
None
|
for field in &fieldset.fields {
|
||||||
} else if Regex::new(reg_regex).unwrap().is_match(name) {
|
|
||||||
fieldset
|
|
||||||
.fields
|
|
||||||
.iter()
|
|
||||||
.find_map(|field| {
|
|
||||||
if field_name == field.name {
|
if field_name == field.name {
|
||||||
return Some(field.name.as_str());
|
return Some((name.as_str(), field.name.as_str()));
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.map(|n| (name.as_str(), n))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_peripheral_counts(out: &mut String, data: &BTreeMap<String, u8>) {
|
fn make_peripheral_counts(out: &mut String, data: &BTreeMap<String, u8>) {
|
||||||
|
Loading…
Reference in New Issue
Block a user