Skip to content

Commit ca6961d

Browse files
Louis Morhetbentiss
authored andcommitted
HID: mcp2221: fix get and get_direction for gpio
The mcp2221_raw_event retrieves the value and direction of gpio on the same command, by setting the value on mcp->status and the direction on mcp->gpio_dir; and the offset at which they are read is based on mcp->gp_idx, set by the gpiochip callbacks. However, the individual gpiochip calls set the index to look for directly on the field they want to track. This create a "double offset" in the final read in the response report. Align the behaviour of mcp2221_raw_event and mcp_gpio_get/mcp_gpio_get_direction by putting gp_idx on those calls to the base offset of the gpio status struct. Signed-off-by: Louis Morhet <[email protected]> Link: https://lore.kernel.org/r/dd0b23800a79d2a464e1e9ed429b018b69fd5df2.1680602387.git.lmorhet@kalrayinc.com Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent e36c31f commit ca6961d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/hid/hid-mcp2221.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static int mcp_gpio_get(struct gpio_chip *gc,
594594

595595
mcp->txbuf[0] = MCP2221_GPIO_GET;
596596

597-
mcp->gp_idx = offsetof(struct mcp_get_gpio, gpio[offset].value);
597+
mcp->gp_idx = offsetof(struct mcp_get_gpio, gpio[offset]);
598598

599599
mutex_lock(&mcp->lock);
600600
ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
@@ -675,7 +675,7 @@ static int mcp_gpio_get_direction(struct gpio_chip *gc,
675675

676676
mcp->txbuf[0] = MCP2221_GPIO_GET;
677677

678-
mcp->gp_idx = offsetof(struct mcp_get_gpio, gpio[offset].direction);
678+
mcp->gp_idx = offsetof(struct mcp_get_gpio, gpio[offset]);
679679

680680
mutex_lock(&mcp->lock);
681681
ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);

0 commit comments

Comments
 (0)