Bug 216736

Summary: HID: mcp2221: GPIO input does not work
Product: Drivers Reporter: Takayuki 'January June' Suwa (jjsuwa_sys3175)
Component: OtherAssignee: drivers_other
Status: NEW ---    
Severity: normal CC: bjorn
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.7 or later Subsystem:
Regression: No Bisected commit-id:

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/