Skip to content

Conversation

@cbrake
Copy link
Contributor

@cbrake cbrake commented Dec 9, 2025

The drive mode validation added in commit ede19a4 was rejecting valid configurations for input pins. The validation ensures that GPIO_SINGLE_ENDED and GPIO_LINE_OPEN_DRAIN flags match the hardware capabilities of each MCP23xxx variant (push-pull vs open-drain).

However, this validation was applied to all pin configurations, including input pins. Input pins do not have a drive mode, so applications typically configure them without setting drive mode flags. This caused the validation to incorrectly reject input pin configurations with -ENOTSUP.

Fix by only validating drive mode flags when GPIO_OUTPUT is set. Input pins now configure successfully, while output pins still receive proper validation to ensure the requested drive mode matches the hardware capabilities.

Fixes: ede19a4 ("drivers: mcp23xxx: add support for open-drain chip variants")

@cbrake
Copy link
Contributor Author

cbrake commented Dec 9, 2025

Without this fix, I get the following error when trying to use the MCP23018 IOs as inputs:

<err> z_dc: Failed to configure GPIO pin 0: -134

@cbrake
Copy link
Contributor Author

cbrake commented Dec 9, 2025

Tested on an MCP23018 chip with IOs configured as both input and output.

The drive mode validation added in commit ede19a4 was rejecting
valid configurations for input pins. The validation ensures that
GPIO_SINGLE_ENDED and GPIO_LINE_OPEN_DRAIN flags match the hardware
capabilities of each MCP23xxx variant (push-pull vs open-drain).

However, this validation was applied to all pin configurations,
including input pins. Input pins do not have a drive mode, so
applications typically configure them without setting drive mode flags.
This caused the validation to incorrectly reject input pin configurations
with -ENOTSUP.

Fix by only validating drive mode flags when GPIO_OUTPUT is set.
Input pins now configure successfully, while output pins still receive
proper validation to ensure the requested drive mode matches the
hardware capabilities.

Fixes: ede19a4 ("drivers: mcp23xxx: add support for open-drain ...")
Signed-off-by: Cliff Brake <[email protected]>
@cbrake cbrake force-pushed the feature-mcp23xxx-fix branch from f5806af to 337e5e6 Compare December 9, 2025 16:48
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants