Skip to content

Commit

Permalink
HID: mcp2221: don't connect hidraw
Browse files Browse the repository at this point in the history
The MCP2221 driver should not connect to the hidraw userspace interface,
as it needs exclusive access to the chip.

If you want to use /dev/hidrawX with the MCP2221, you need to avoid
binding this driver to the device and use the hid generic driver instead
(e.g. using udev rules).

Cc: stable@vger.kernel.org
Reported-by: Sven Zühlsdorf <sven.zuehlsdorf@vigem.de>
Signed-off-by: Enrik Berkhan <Enrik.Berkhan@inka.de>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20221103222714.21566-2-Enrik.Berkhan@inka.de
  • Loading branch information
Enrik Berkhan authored and Benjamin Tissoires committed Dec 19, 2022
1 parent 0e13e7b commit 67c90d1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/hid/hid-mcp2221.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,12 +1110,19 @@ static int mcp2221_probe(struct hid_device *hdev,
return ret;
}

ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
/*
* This driver uses the .raw_event callback and therefore does not need any
* HID_CONNECT_xxx flags.
*/
ret = hid_hw_start(hdev, 0);
if (ret) {
hid_err(hdev, "can't start hardware\n");
return ret;
}

hid_info(hdev, "USB HID v%x.%02x Device [%s] on %s\n", hdev->version >> 8,
hdev->version & 0xff, hdev->name, hdev->phys);

ret = hid_hw_open(hdev);
if (ret) {
hid_err(hdev, "can't open device\n");
Expand Down Expand Up @@ -1145,8 +1152,7 @@ static int mcp2221_probe(struct hid_device *hdev,
mcp->adapter.retries = 1;
mcp->adapter.dev.parent = &hdev->dev;
snprintf(mcp->adapter.name, sizeof(mcp->adapter.name),
"MCP2221 usb-i2c bridge on hidraw%d",
((struct hidraw *)hdev->hidraw)->minor);
"MCP2221 usb-i2c bridge");

ret = devm_i2c_add_adapter(&hdev->dev, &mcp->adapter);
if (ret) {
Expand Down

0 comments on commit 67c90d1

Please sign in to comment.