-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[topic-gpio] drivers: display: mb_display: Convert to the new GPIO API #22157
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
[topic-gpio] drivers: display: mb_display: Convert to the new GPIO API #22157
Conversation
Convert to the new GPIO API, use raw access since this is a low-level GPIO-based driver. Signed-off-by: Carles Cufi <[email protected]>
| /* Set the column pins to their correct values */ | ||
| for (pin = LED_COL1_GPIO_PIN; pin <= LED_COL9_GPIO_PIN; pin++) { | ||
| gpio_pin_write(disp->dev, pin, !!(val & BIT(pin))); | ||
| gpio_pin_set_raw(disp->dev, pin, !!(val & BIT(pin))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not want to change the original !!(), leaving it to @jhedberg if he prefers to use a simple & instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't the correct values of the last parameter 0 and 1? That's what the !! is there for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the function is documented x & mask should work ("Writing any value other than 0 will set it to a high physical level.") Either !!(x & mask) or (x & mask) != 0 are good for clarity of intention. Sometimes people are confused by !!x though I personally like it (except where MISRA essential type requires a "boolean" expression).
|
Tested on the micro:bit, using the display sample. |
| /* Set the column pins to their correct values */ | ||
| for (pin = LED_COL1_GPIO_PIN; pin <= LED_COL9_GPIO_PIN; pin++) { | ||
| gpio_pin_write(disp->dev, pin, !!(val & BIT(pin))); | ||
| gpio_pin_set_raw(disp->dev, pin, !!(val & BIT(pin))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the function is documented x & mask should work ("Writing any value other than 0 will set it to a high physical level.") Either !!(x & mask) or (x & mask) != 0 are good for clarity of intention. Sometimes people are confused by !!x though I personally like it (except where MISRA essential type requires a "boolean" expression).
Convert to the new GPIO API, use raw access since this is a low-level
GPIO-based driver.
Signed-off-by: Carles Cufi [email protected]