[riot-notifications] [RIOT-OS/RIOT] cpu: fix returns of i2c_acquire and i2c_release (#10856)
notifications at github.com
Thu Jan 24 09:55:12 CET 2019
The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.
### Contribution description
This PR replaces `asserts` with `if` statements in `periph/i2c` for all CPUs to return proper error codes according to the API spec. The rational behind this is that (theoretically) one could write a driver and simply link against RIOT without recompiling the `periph/i2c`, hence `asserts` will not work but according to the API specs `acquire` and `release` should return `-1` on error, which in this case mostly means: wrong device
### Testing procedure
run `tests/periph_i2c` (or any drivers requiring I2C) for different boards to match all CPUs, it should still work.
### Issues/PRs references
Examples: Fixes #1234. See also #5678. Depends on PR #9876.
Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* cpu/atmega: fix return of i2c_acquire/release
* cpu/efm32: fix return of i2c_acquire/release
* cpu/kinetis: fix return of i2c_acquire/release
* cpu/nrf51: fix return of i2c_acquire/release
* cpu/nrf52: fix return of i2c_acquire/release
* cpu/sam0: fix return of i2c_acquire/release
* cpu/stm32: fix return of i2c_acquire/release
-- File Changes --
M cpu/atmega_common/periph/i2c.c (18)
M cpu/efm32/periph/i2c.c (27)
M cpu/kinetis/periph/i2c.c (25)
M cpu/nrf51/periph/i2c.c (18)
M cpu/nrf52/periph/i2c.c (25)
M cpu/sam0_common/periph/i2c.c (16)
M cpu/stm32_common/periph/i2c_1.c (25)
M cpu/stm32_common/periph/i2c_2.c (35)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications