drivers/periph_spi: let spi_acquire return void#15902
drivers/periph_spi: let spi_acquire return void#15902fjmolinas merged 6 commits intoRIOT-OS:masterfrom
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. |
voidf76eba8 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 |
Make all spi_acquire() implementations return `void` and add assertions to check for valid parameters, where missing.
2403f59 to
2efc50b
Compare
| 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.
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. |
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_spito match theperiph_spiAPI<foo>_init(), but afterwards never againspi_acquire()andspi_release()if and only ifNDEBUGis 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: