-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: gpio: gd32: add dependency on the EXTI #50879
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
Conversation
drivers/gpio/gpio_gd32.c
Outdated
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.
It looks as though clkid will be padded out to 32-bits if CONFIG_GD32_EXTI=n, so the #ifdef can be removed here. Then you can switch to using if (IS_ENABLED(CONFIG_GD32_EXTI) elsewhere and remove the #ifdef around static void gpio_gd32_isr(uint8_t line, void *arg)
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.
It looks as though
clkidwill be padded out to 32-bits ifCONFIG_GD32_EXTI=n, so the#ifdefcan be removed here.
Insightful!
Removed the #ifdef.
Then you can switch to using
if (IS_ENABLED(CONFIG_GD32_EXTI)elsewhere and remove the#ifdefaroundstatic void gpio_gd32_isr(uint8_t line, void *arg)
Commenting in follows topics.
drivers/gpio/gpio_gd32.c
Outdated
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.
if (IS_ENABLED(CONFIG_GD32_EXTI))
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.
Fixed it.
drivers/gpio/gpio_gd32.c
Outdated
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.
if (IS_ENABLED(CONFIG_GD32_EXTI))
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.
Fixed it.
drivers/gpio/gpio_gd32.c
Outdated
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.
#ifdef can be removed
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.
This #ifdef suppressing unused-function warning.
It should be better not to remove it.
drivers/gpio/Kconfig.gd32
Outdated
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.
Should this be enabled by default?
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.
Yes, it is.
Interrupts handling needs the EXTI.
The callback function of the GPIO API will not work If this option is disabled.
This PR is intended mainly to clarify dependencies.
I would like to make as few changes as possible from the current behavior.
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.
If it's required, should be depends on. imply means that it is optional but should be the default. Alternatively, selects could be used..
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 added more change gpio_pin_interrupt_configure API returns -ENOTSUP if GD32_EXTI disabled.
It make allow to disable GD32_EXTI without API contradiction.
7d7ad35 to
37a9f70
Compare
fa22798 to
581b7cd
Compare
henrikbrixandersen
left a comment
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.
LGTM
drivers/gpio/gpio_gd32.c
Outdated
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'm not sure but should it be as below?
-#if (IS_ENABLED(CONFIG_GD32_EXTI))
+if (IS_ENABLED(CONFIG_GD32_EXTI)) {
...
-#endif
+}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.
It's a beautiful solution!
The if-else condition must determine at compile time.
I worry that the intention maybe not have been conveyed to the code reader, adding some comments.
gmarull
left a comment
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.
So before reviewing, why do we need this change? Why would a new GD platform need that?
gmarull
left a comment
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.
-1 if this is needed for #49886
|
@gmarull ,
I found this problem in work about #49886, but This PR is not related to #49886 and is also not required by. It is a problem that no dependency defines in Kconfig even though gd32_gpio.c depends on gd32_exti.c. The simple way to solve this is to use
I agree there is no solid reason to merge this patch. |
6e4af77 to
64c8ab8
Compare
drivers/gpio/gpio_gd32.c
Outdated
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.
IMO, what should be done is the following:
- Add a Kconfig option to build the GD32 driver w/o interrupt support, e.g.
CONFIG_GPIO_GD32_INT_ENABLE - Such option should be enabled by default, and select
GD32_EXTI(intc drivers do not have a class, so we need to select on a driver basis) - Just ifdefout code if
CONFIG_GPIO_GD32_INT_ENABLE=n. I've personally never likedIS_ENABLEDbecause it can't be universally used without getting compile errors in some cases.
But still, I feel it is wrong to add such option at a driver level. It should likely be a subsystem setting to build GPIO drivers with/without interrupt support.
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.
It is as you say. I look at the implementation of other GPIO drivers, and none of them enable or disable .pin_interrupt_configure in the settings. So I would like to withdraw this idea.
However, I think that it is better to clarify the dependency on EXTI,
I have changed the fix (and PR title).
Could you please confirm this?
64c8ab8 to
0fcd49a
Compare
The GPIO pin interruption depends on the EXTI. Add "select" to clarify the dependency. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
0fcd49a to
f5da65a
Compare
| bool "GD32 GPIO driver" | ||
| default y | ||
| depends on DT_HAS_GD_GD32_GPIO_ENABLED | ||
| select GD32_EXTI |
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.
Sorry, I confuse the NVIX and EXTI definition. NVIC provide SysTick, PendSV and other fault exception. EXTI provide periphral interrupt.
That's ok for me now.
The GPIO pin interruption depends on the EXTI.
Add "select" to clarify the dependency.
Signed-off-by: TOKITA Hiroshi tokita.hiroshi@gmail.com