Bug 216736 - HID: mcp2221: GPIO input does not work
Summary: HID: mcp2221: GPIO input does not work
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-24 06:35 UTC by Takayuki 'January June' Suwa
Modified: 2022-11-29 15:45 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.7 or later
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Takayuki 'January June' Suwa 2022-11-24 06:35:07 UTC
Hi,

The mcp2221 driver GPIO input handling does not work well due to incorrect 'struct mcp_get_gpio' declaration.

'direction' and 'value' in 'gpio[]' are reversed order.  The correct sequence is pin value first, followed by direction value.  See "TABLE 3-35: RESPONSE 1 STRUCTURE", page 48.

--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -74,8 +74,8 @@ struct mcp_get_gpio {
 	u8 cmd;
 	u8 dummy;
 	struct {
-		u8 direction;
 		u8 value;
+		u8 direction;
 	} gpio[MCP_NGPIO];
 } __packed;
Comment 1 Bjorn Helgaas 2022-11-29 15:45:24 UTC
FWIW, I responded to the original patch that added struct mcp_get_gpio with a pointer to this bug report.  I'm not sure the mcp2221 folks watch the bugzilla.
https://lore.kernel.org/all/20221129153933.GA716319@bhelgaas/

Note You need to log in before you can comment on or make changes to this bug.