Skip to content
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_gpio: let gpio_read() return bool #20936

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

maribu
Copy link
Member

@maribu maribu commented Oct 22, 2024

Contribution description

Since #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.

Testing procedure

This should not cause any regressions.

I cannot find any way to use int gpio_read() that won't work with bool gpio_read() anymore at the top of my head.

Issues/PRs references

Same that #20935 did for gpio_write(), but for gpio_read().

@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 22, 2024
@github-actions github-actions bot added Platform: native Platform: This PR/issue effects the native platform Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: AVR Platform: This PR/issue effects AVR-based platforms Area: drivers Area: Device drivers Platform: ESP Platform: This PR/issue effects ESP-based platforms Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms Area: cpu Area: CPU/MCU ports labels Oct 22, 2024
@maribu maribu added the Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. label Oct 22, 2024
@riot-ci
Copy link

riot-ci commented Oct 22, 2024

Murdock results

✔️ PASSED

7d1313b treewide: update rust-riot-wrappers

Success Failures Total Runtime
10215 0 10215 17m:50s

Artifacts

drivers/include/periph/gpio.h Outdated Show resolved Hide resolved
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.
@maribu maribu force-pushed the drivers/periph_gpio/gpio_read/bool branch from 0bcbca1 to 815fe17 Compare October 23, 2024 11:24
@maribu
Copy link
Member Author

maribu commented Oct 23, 2024

See RIOT-OS/rust-riot-wrappers#132

Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.

@dylad
Copy link
Member

dylad commented Oct 24, 2024

Don't forget to remove the extra commit :)

@dylad dylad added Process: missing approvals Integration Process: PR needs more ACKS (handled by action) Process: needs >1 ACK Integration Process: This PR requires more than one ACK labels Oct 24, 2024
@maribu maribu force-pushed the drivers/periph_gpio/gpio_read/bool branch from 815fe17 to 7d1313b Compare October 24, 2024 07:58
@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: sys Area: System Area: examples Area: Example Applications labels Oct 24, 2024
@maribu
Copy link
Member Author

maribu commented Oct 24, 2024

Don't forget to remove the extra commit :)

Done. But since this requires recently merged changes to the rust wrappers to work with both old and new gpio_read() signature, I updated the riot-rust-wrappers and added this as commit using:

for dir in $(dirname $(find . -name Cargo.lock)); do 
    pushd $dir
    cargo update riot-wrappers
    popd
done

Copy link
Member

@chrysn chrysn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions bot removed the Process: missing approvals Integration Process: PR needs more ACKS (handled by action) label Oct 24, 2024
@dylad
Copy link
Member

dylad commented Oct 24, 2024

@benpicco Should this PR go into master ?

@benpicco benpicco added this pull request to the merge queue Oct 24, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 24, 2024
@maribu maribu added this pull request to the merge queue Oct 24, 2024
Merged via the queue into RIOT-OS:master with commit ba83fef Oct 25, 2024
26 checks passed
@maribu maribu deleted the drivers/periph_gpio/gpio_read/bool branch October 25, 2024 05:13
@maribu
Copy link
Member Author

maribu commented Oct 25, 2024

Thx :)

@benpicco benpicco added this to the Release 2024.10 milestone Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: examples Area: Example Applications Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: AVR Platform: This PR/issue effects AVR-based platforms Platform: ESP Platform: This PR/issue effects ESP-based platforms Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: native Platform: This PR/issue effects the native platform Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Process: needs >1 ACK Integration Process: This PR requires more than one ACK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants