-
Notifications
You must be signed in to change notification settings - Fork 207
chore: Minor QSPI code deduplication #2095
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
base: master
Are you sure you want to change the base?
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.
The diff stat on this is +136 −93
i.e. a net increase of code. That's a hard sell for code deduplication.
A good bit of that is coming from the added and/or copied comments, but that's absolutely true. My thinking was that getting rid of superfluous/"not functionality wise critical" error conversions would make the code a bit less "noisy", and perhaps also improve generated code quality / icache usage. I didn't check the output though; I'll take a look at that to see if this actually has other upsides than just personal code esthetics :) The changes in the STM32 QSPI driver code I do think pulls its own weight, regardless. |
cc981a4
to
c92a2eb
Compare
After deeper analysis, the helper methods were a total dud. The STM32 QSPI driver changes are less clear but a possible dud as well. Here're the numbers up front:
In total, that's a 20 byte increase in assembly size. Binary size of cosmo-a auxflash increases by a whopping 2868 bytes. This is a loss in total, but perhaps it is acceptable given the actually negative number of code lines? Applying Final side note: |
c92a2eb
to
3403c68
Compare
3403c68
to
54bd5be
Compare
@labbott Would you be willing to re-review this? I removed the EDIT: I checked; adding the The I additionally moved the |
sys_recv_notification(self.interrupt); | ||
} | ||
self.reg.cr.modify(|_, w| { | ||
w.tcie().clear_bit().teie().clear_bit().toie().clear_bit() |
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.
note: So here the code previously cleared just TCIE, TEIE, and TOIE. Now the Ok-path goes into disable_all_interrupts
, clearing one more register which then causes a 4 byte increase in code size.
I would've actually thought the compiler could combine the error and success paths here but that doesn't seem to be the case; the 4 byte increase suggests that the Ok-path is independent of the Err-path, even though they both do the same thing.
Since this caught my eye in #2089 and was merged in #2071, I thought I'd put my hands where my mouth is and do the few deduplications that I thought might be considered useful or "pretty".
Adjacent code error?
In
drv/auxflash-api/src/lib.rs:191
the call toself.get_blob_by_tag(tag)
seems to be invalid; that function takes two parameters,(slot, tag)
. I wonder if this is dead code or what's going on with that?