Skip to content

i2c_hid: ELAN touchpad bugs fix #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/hid/hid-ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@
#define USB_DEVICE_ID_TOSHIBA_CLICK_L9W 0x0401
#define USB_DEVICE_ID_HP_X2 0x074d
#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755
#define I2C_DEVICE_ID_ELAN_TOUCHPAD 0x303e

#define USB_VENDOR_ID_ELECOM 0x056e
#define USB_DEVICE_ID_ELECOM_BM084 0x0061
Expand Down
25 changes: 15 additions & 10 deletions drivers/hid/i2c-hid/i2c-hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2)
#define I2C_HID_QUIRK_DELAY_AFTER_SLEEP BIT(3)
#define I2C_HID_QUIRK_BOGUS_IRQ BIT(4)
#define I2C_HID_QUIRK_FORCE_TRIGGER_FALLING BIT(5)

/* flags */
#define I2C_HID_STARTED 0
Expand Down Expand Up @@ -182,8 +183,10 @@ static const struct i2c_hid_quirks {
I2C_HID_QUIRK_NO_RUNTIME_PM },
{ I2C_VENDOR_ID_GOODIX, I2C_DEVICE_ID_GOODIX_01F0,
I2C_HID_QUIRK_NO_RUNTIME_PM },
{ USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHPAD,
I2C_HID_QUIRK_BOGUS_IRQ | I2C_HID_QUIRK_FORCE_TRIGGER_FALLING },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I tried to explain before, the { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHPAD, ...} quirk MUST be above the { USB_VENDOR_ID_ELAN, HID_ANY_ID, ...} quirk. The quirks are checked one by one until one matches.

Except that I'm wrong and i2c_hid_lookup_quirk keeps going after a match, so the most specific quirk must be at the bottom.

Never mind this is correct, lets discuss this further on the mailinglist.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right because i2c_hid_lookup_quirk looks from the top.

{ USB_VENDOR_ID_ELAN, HID_ANY_ID,
I2C_HID_QUIRK_BOGUS_IRQ },
I2C_HID_QUIRK_BOGUS_IRQ },
{ 0, 0 }
};

Expand Down Expand Up @@ -854,6 +857,8 @@ static int i2c_hid_init_irq(struct i2c_client *client)

if (!irq_get_trigger_type(client->irq))
irqflags = IRQF_TRIGGER_LOW;
if (ihid->quirks & I2C_HID_QUIRK_FORCE_TRIGGER_FALLING)
irqflags = IRQF_TRIGGER_FALLING;

ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq,
irqflags | IRQF_ONESHOT, client->name, ihid);
Expand Down Expand Up @@ -1123,14 +1128,10 @@ static int i2c_hid_probe(struct i2c_client *client,
if (ret < 0)
goto err_pm;

ret = i2c_hid_init_irq(client);
if (ret < 0)
goto err_pm;

hid = hid_allocate_device();
if (IS_ERR(hid)) {
ret = PTR_ERR(hid);
goto err_irq;
goto err_pm;
}

ihid->hid = hid;
Expand All @@ -1149,24 +1150,28 @@ static int i2c_hid_probe(struct i2c_client *client,

ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);

ret = i2c_hid_init_irq(client);
if (ret < 0)
goto err_mem_free;

ret = hid_add_device(hid);
if (ret) {
if (ret != -ENODEV)
hid_err(client, "can't add hid device: %d\n", ret);
goto err_mem_free;
goto err_irq;
}

if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM))
pm_runtime_put(&client->dev);

return 0;

err_irq:
free_irq(client->irq, ihid);

err_mem_free:
hid_destroy_device(hid);

err_irq:
free_irq(client->irq, ihid);

err_pm:
pm_runtime_put_noidle(&client->dev);
pm_runtime_disable(&client->dev);
Expand Down