Skip to content

Commit 03a8610

Browse files
dtorbentiss
authored andcommitted
HID: retain initial quirks set up when creating HID devices
In certain circumstances, such as when creating I2C-connected HID devices, we want to pass and retain some quirks (axis inversion, etc). The source of such quirks may be device tree, or DMI data, or something else not readily available to the HID core itself and therefore cannot be reconstructed easily. To allow this, introduce "initial_quirks" field in hid_device structure and use it when determining the final set of quirks. This fixes the problem with i2c-hid setting up device-tree sourced quirks too late and losing them on device rebind, and also allows to sever the tie between hid-code and i2c-hid when applying DMI-based quirks. Fixes: b60d3c8 ("HID: i2c-hid-of: Expose the touchscreen-inverted properties") Fixes: a2f416b ("HID: multitouch: Add quirks for flipped axes") Reviewed-by: Guenter Roeck <[email protected]> Tested-by: Allen Ballway <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent a2f416b commit 03a8610

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

drivers/hid/hid-quirks.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/input/elan-i2c-ids.h>
2020

2121
#include "hid-ids.h"
22-
#include "i2c-hid/i2c-hid.h"
2322

2423
/*
2524
* Alphabetically sorted by vendor then product.
@@ -1238,7 +1237,7 @@ EXPORT_SYMBOL_GPL(hid_quirks_exit);
12381237
static unsigned long hid_gets_squirk(const struct hid_device *hdev)
12391238
{
12401239
const struct hid_device_id *bl_entry;
1241-
unsigned long quirks = 0;
1240+
unsigned long quirks = hdev->initial_quirks;
12421241

12431242
if (hid_match_id(hdev, hid_ignore_list))
12441243
quirks |= HID_QUIRK_IGNORE;
@@ -1299,11 +1298,6 @@ unsigned long hid_lookup_quirk(const struct hid_device *hdev)
12991298
quirks = hid_gets_squirk(hdev);
13001299
mutex_unlock(&dquirks_lock);
13011300

1302-
/* Get quirks specific to I2C devices */
1303-
if (IS_ENABLED(CONFIG_I2C_DMI_CORE) && IS_ENABLED(CONFIG_DMI) &&
1304-
hdev->bus == BUS_I2C)
1305-
quirks |= i2c_hid_get_dmi_quirks(hdev->vendor, hdev->product);
1306-
13071301
return quirks;
13081302
}
13091303
EXPORT_SYMBOL_GPL(hid_lookup_quirk);

drivers/hid/i2c-hid/i2c-hid-core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,10 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
10351035
hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
10361036
hid->product = le16_to_cpu(ihid->hdesc.wProductID);
10371037

1038+
hid->initial_quirks = quirks;
1039+
hid->initial_quirks |= i2c_hid_get_dmi_quirks(hid->vendor,
1040+
hid->product);
1041+
10381042
snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
10391043
client->name, (u16)hid->vendor, (u16)hid->product);
10401044
strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
@@ -1048,8 +1052,6 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
10481052
goto err_mem_free;
10491053
}
10501054

1051-
hid->quirks |= quirks;
1052-
10531055
return 0;
10541056

10551057
err_mem_free:

drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,4 +492,3 @@ u32 i2c_hid_get_dmi_quirks(const u16 vendor, const u16 product)
492492

493493
return quirks;
494494
}
495-
EXPORT_SYMBOL_GPL(i2c_hid_get_dmi_quirks);

include/linux/hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ struct hid_device { /* device report descriptor */
619619
unsigned long status; /* see STAT flags above */
620620
unsigned claimed; /* Claimed by hidinput, hiddev? */
621621
unsigned quirks; /* Various quirks the device can pull on us */
622+
unsigned initial_quirks; /* Initial set of quirks supplied when creating device */
622623
bool io_started; /* If IO has started */
623624

624625
struct list_head inputs; /* The list of inputs */

0 commit comments

Comments
 (0)