Skip to content

Commit

Permalink
HID: quirks: Refactor ELAN 400 and 401 handling
Browse files Browse the repository at this point in the history
There needs to be coordination between hid-quirks and the elan_i2c driver
about which devices are handled by what drivers.  Currently, both use
whitelists, which results in valid devices being unhandled by default,
when they should not be rejected by hid-quirks.  This is quickly becoming
an issue.

Since elan_i2c has a maintained whitelist of what devices it will handle,
which is now in a header file that hid-quirks can access, use that to
implement a blacklist in hid-quirks so that only the devices that need to
be handled by elan_i2c get rejected by hid-quirks, and everything else is
handled by default.

Suggested-by: Benjamin Tissoires <[email protected]>
Signed-off-by: Jeffrey Hugo <[email protected]>
Acked-by: Benjamin Tissoires <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
Jeffrey Hugo authored and dtor committed Jun 30, 2019
1 parent 0828c10 commit d69f62b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions drivers/hid/hid-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/input/elan-i2c-ids.h>

#include "hid-ids.h"

Expand Down Expand Up @@ -923,6 +924,8 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {

bool hid_ignore(struct hid_device *hdev)
{
int i;

if (hdev->quirks & HID_QUIRK_NO_IGNORE)
return false;
if (hdev->quirks & HID_QUIRK_IGNORE)
Expand Down Expand Up @@ -987,18 +990,15 @@ bool hid_ignore(struct hid_device *hdev)
break;
case USB_VENDOR_ID_ELAN:
/*
* Many Elan devices have a product id of 0x0401 and are handled
* by the elan_i2c input driver. But the ACPI HID ELAN0800 dev
* is not (and cannot be) handled by that driver ->
* Ignore all 0x0401 devs except for the ELAN0800 dev.
* Blacklist of everything that gets handled by the elan_i2c
* input driver. This avoids disabling valid touchpads and
* other ELAN devices.
*/
if (hdev->product == 0x0401 &&
strncmp(hdev->name, "ELAN0800", 8) != 0)
return true;
/* Same with product id 0x0400 */
if (hdev->product == 0x0400 &&
strncmp(hdev->name, "QTEC0001", 8) != 0)
return true;
if ((hdev->product == 0x0401 || hdev->product == 0x0400))
for (i = 0; strlen(elan_acpi_id[i].id); ++i)
if (!strncmp(hdev->name, elan_acpi_id[i].id,
strlen(elan_acpi_id[i].id)))
return true;
break;
}

Expand Down

0 comments on commit d69f62b

Please sign in to comment.