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

gpio: legacy level interrupt disable API not backwards compatible #22660

Closed
pabigot opened this issue Feb 9, 2020 · 1 comment · Fixed by #22665
Closed

gpio: legacy level interrupt disable API not backwards compatible #22660

pabigot opened this issue Feb 9, 2020 · 1 comment · Fixed by #22665
Assignees
Labels
area: API Changes to public APIs area: Documentation area: GPIO bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Milestone

Comments

@pabigot
Copy link
Collaborator

pabigot commented Feb 9, 2020

The following was discovered in testing and development of #22659:

In the old GPIO API interrupt configuration was integrated with pin configuration, so an interrupt could be enabled with:

gpio_pin_configure(dev, PIN_IN, GPIO_DIR_IN | GPIO_INT | GPIO_INT_LEVEL);

and disabled within the callback with the idiom:

gpio_pin_configure(dev, PIN_IN, GPIO_DIR_IN);

which, because it did not include any interrupt-related flags, was interpreted to mean disable interrupts.

In the new API interrupt configuration is done with the gpio_pin_interrupt_configure() function. The disable flag is a non-zero value distinct from the non-zero enable flag. For legacy compatibility gpio_pin_configure() extracts interrupt-related flags from its flags parameter and invokes gpio_pin_interrupt_configure() with them, which means the legacy enable command works.

However, the legacy disable command has no interrupt-related flags, which means the new implementation of gio_pin_configure() leaves interrupts enabled.

In the case of level-triggered interrupts where the legacy disable operation is invoked in the callback the application will hang unless GPIO_INT_DISABLE is added to the flags.

@pabigot pabigot added bug The issue is a bug, or the PR is fixing a bug area: GPIO area: API Changes to public APIs labels Feb 9, 2020
@mnkp
Copy link
Member

mnkp commented Feb 10, 2020

The difference in behavior will be mentioned in the release notes.

@carlescufi carlescufi added this to the v2.2.0 milestone Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Documentation area: GPIO bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants