-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
better handle missing I2C muxes #1425
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, this diff is way smaller than I was expecting. So the key is just permitting a single error condition on the enable_segment
path?
drv/stm32xx-i2c-server/src/main.rs
Outdated
// | ||
all_muxes(controller, port, muxes, |mux| { | ||
mux.driver.enable_segment(mux, controller, None, ctrl) | ||
match mux.driver.enable_segment(mux, controller, None, ctrl) { | ||
Err(code) if code == ResponseCode::MuxMissing => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Err(code) if code == ResponseCode::MuxMissing => { | |
Err(ResponseCode::MuxMissing) => { |
drv/stm32xx-i2c-server/src/main.rs
Outdated
ringbuf_entry!(Trace::MuxMissing(mux.address)); | ||
Ok(()) | ||
} | ||
Err(code) => Err(code), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these lines are equivalent to other => other
, fwiw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯🤯🤯 HOW LONG HAS THAT BEEN THERE?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a really useful pattern (ha!) that I basically assumed (for terrible reasons?) didn't/wouldn't work.
Yeah -- the other paths actually handle themselves, it turns out. When we treat a missing mux as implying that all of its segments are in fact disabled, everything else just... works. |
Draft commit comment: