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: make gpio_write() take a bool #20935

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

benpicco
Copy link
Contributor

Contribution description

There is no reason for gpio_write() to take an int when a GPIO can only be either on or off.
To avoid confusion, switch to bool

Testing procedure

Since a bool is usually just an int in disguise, there should be no code or semantic changes.

Issues/PRs references

@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
@benpicco benpicco changed the title drivers/periph/gpio: make gpio_write() take a bool drivers/periph/gpio: make gpio_write() take a bool Oct 22, 2024
@benpicco benpicco added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 22, 2024
@riot-ci
Copy link

riot-ci commented Oct 22, 2024

Murdock results

✔️ PASSED

4627f66 drivers/periph/gpio: make gpio_write() take a bool

Success Failures Total Runtime
10214 0 10215 13m:54s

Artifacts

Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

lgtm

Normally I would say this is not fit for a last minute merge before branching of the release branch, but your release manager authority should allow you to do just that :-)

@benpicco benpicco added this pull request to the merge queue Oct 22, 2024
Merged via the queue into RIOT-OS:master with commit faa1003 Oct 22, 2024
26 checks passed
maribu added a commit to maribu/RIOT that referenced this pull request 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.
@benpicco benpicco deleted the gpio_write-bool branch October 23, 2024 10:02
maribu added a commit to maribu/RIOT that referenced this pull request Oct 23, 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.
@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 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 Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants