-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers/periph_spi: let spi_acquire return void #15902
Conversation
Let's see if the CI finds any implementations / users that I missed. Beware: While the WIP label is still present, I will squash without further notice ;-) I'll drop the WIP label once the CI is green. |
void
f76eba8
to
a8401a6
Compare
0645dc9
to
64e2878
Compare
The remaining failed build is an CI hiccup, so this is no longer WIP. |
Cherry-picked review fixes that address @hugueslarrive's review in #15904 into this PR as well |
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.
LGTM.
Please squash !
Make all spi_acquire() implementations return `void` and add assertions to check for valid parameters, where missing.
2403f59
to
2efc50b
Compare
@@ -78,10 +78,11 @@ void spi_init_pins(spi_t bus) | |||
#endif | |||
} | |||
|
|||
int spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk) | |||
void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk) | |||
{ | |||
(void)bus; |
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 that if an argument is used by an assert()
only, it will be unused once the assert is disabled via NDEBUG
. The reason is that assert()
is (as required by the C standard) implement as a preprocessor macro.
Go! |
Thanks! |
Remove duplicated includes introduced in #15902
Shouldn't we do the same for Lines 234 to 242 in 97758b8
assert . This was already the topic of a discussion in issue #10673, but after we removed the return value of spi_acquire , there is no argument to keep it for i2c_acquire .
|
I totally agree! |
Ok, I will try to provide a PR in next weeks. |
It wasn't handled particularly well anyway here. [15902]: RIOT-OS/RIOT#15902
Contribution description
int spi_acquire(...)
tovoid spi_acquire(...)
assert()
s to verify parameters, this actually increases error checking compared to before, where both SPI implementations and user mostly didn't care about errorssoft_spi
to match theperiph_spi
API<foo>_init()
, but afterwards never againspi_acquire()
andspi_release()
if and only ifNDEBUG
is not defined.assert()
ions are disabled anyway, we won't trigger them no matter how hard we try :-)Testing procedure
This should be mostly unscary. However, without
assert()
ions enabled, timing behavior changes a bit during initilization, as a useless pair ofspi_acquire()
andspi_release()
is simply dropped.Issues/PRs references
Depends on and includes: