Skip to content

Fixes for the mcp2221 gpiochip get_* calls

Louis Morhet linux-i2c linux-input lkml 1 version Applied

Status from this message: Applied to https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git (for-6.4/mcp2221), thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2HID: mcp2221: fix report layout for gpio getdrivers/hid/hid-mcp2221.c+1 -10 replies
2/2HID: mcp2221: fix get and get_direction for gpiodrivers/hid/hid-mcp2221.c+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Fixes for the mcp2221 gpiochip get_* calls

The mcp2221 HID driver exposes a gpiochip device.
While gpioset seemed to work fine, gpioget always returned 1 on all 4 GPIOs of the component (0x01 for input in the field "direction", according to the documentation).

This patch series addresses this issue by fixing the order of the fields in the driver's representation of the chip answer, and adding consistency to the way the callbacks prepare their command and the way the hid event handler gets these fields.
The set callbacks use a similar mechanism, but work for now because setting a direction/value only requires gpio-specific positioning in the command preparation, and not in the raw_event handler.

The core of this issue being a discrepancy in the way the command and the answer fetch their fields of interest, I would also like to ask if we should uniformize a bit the way this driver handles gpio, and how. I thought about several possible implementations for that:
Use mcp->gp_idx as the base offset of the gpio for set too, and modify the raw_event handler to fetch all relevant data based on that; or set the buffers in the mcp structure as unions of the various commands handled and use gp_idx simply as the gpio index to access relevant data directly from the structured representation everywhere; or go back to ye old defines to ensure portability...

Louis Morhet (2):
HID: mcp2221: fix report layout for gpio get
HID: mcp2221: fix get and get_direction for gpio

 drivers/hid/hid-mcp2221.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1