drivers/periph_gpio: let gpio_read() return bool#20936
Merged
maribu merged 3 commits intoRIOT-OS:masterfrom Oct 25, 2024
Merged
drivers/periph_gpio: let gpio_read() return bool#20936maribu merged 3 commits intoRIOT-OS:masterfrom
maribu merged 3 commits intoRIOT-OS:masterfrom
Conversation
dylad
requested changes
Oct 22, 2024
Since RIOT-OS#20935 gpio_write() uses a `bool` instead of an `int`. This does the same treatment for `gpio_read()`. This does indeed add an instruction to `gpio_read()` implementations. However, users caring about an instruction more are better served with `gpio_ll_read()` anyway. And `gpio_read() == 1` is often seen in newcomer's code, which would now work as expected.
We just changed the API so that it returns bool anyway.
0bcbca1 to
815fe17
Compare
Member
Author
Member
|
Don't forget to remove the extra commit :) |
815fe17 to
7d1313b
Compare
Member
Author
Done. But since this requires recently merged changes to the rust wrappers to work with both old and new for dir in $(dirname $(find . -name Cargo.lock)); do
pushd $dir
cargo update riot-wrappers
popd
done |
chrysn
approved these changes
Oct 24, 2024
Member
chrysn
left a comment
There was a problem hiding this comment.
LGTM at a glance, and I checked the Rust changes to be really just what is needed here.
In general I softly prefer doing the Rust changes outside the breaking PR (so that not just the riot-wrappers' limited CI runs, but it gets a full murdock run), but the change is so small here that doing it in the breaking PR is just as fine.
Member
|
@benpicco Should this PR go into master ? |
Member
Author
|
Thx :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
Since #20935 gpio_write() uses a
boolinstead of anint. This does the same treatment forgpio_read().This does indeed add an instruction to
gpio_read()implementations. However, users caring about an instruction more are better served withgpio_ll_read()anyway. Andgpio_read() == 1is often seen in newcomer's code, which would now work as expected.Testing procedure
This should not cause any regressions.
I cannot find any way to use
int gpio_read()that won't work withbool gpio_read()anymore at the top of my head.Issues/PRs references
Same that #20935 did for
gpio_write(), but forgpio_read().