Skip to content

Commit 728ec8b

Browse files
jwrdegoedebentiss
authored andcommitted
HID: i2c-hid-of: Allow using i2c-hid-of on non OF platforms
There are some x86 tablets / 2-in-1s which ship with Android as their factory OS image. These have pretty broken ACPI tables, relying on everything being hardcoded in the factory kernel image. platform/x86/x86-android-tablets.c manually instantiates i2c-clients for i2c devices on these tablets to make them work with the mainline kernel. The Lenovo Yoga Book 1 (yb1-x90f/l) is such a 2-in-1. It has 2 I2C-HID devices its main touchscreen and a Wacom digitizer. Its main touchscreen can alternatively also be used in HiDeep's native protocol mode but for the Wacom digitizer we really need I2C-HID. This patch allows using i2c-hid-of on non OF platforms so that it can bind to a non ACPI instantiated i2c_client on x86 for the Wacom digitizer. Note the driver already has an "i2c-over-hid" i2c_device_id (rather then an of_device_id). Besides enabling building on non-OF platforms this also replaces the only of_property_read_u32() call with device_property_read_u32() note that other properties where already read using device_property_read_...(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20230413093625.71146-3-hdegoede@redhat.com Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 9d793e7 commit 728ec8b

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

drivers/hid/i2c-hid/Kconfig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ config I2C_HID_ACPI
2323

2424
config I2C_HID_OF
2525
tristate "HID over I2C transport layer Open Firmware driver"
26-
depends on OF
26+
# No "depends on OF" because this can also be used for manually
27+
# (board-file) instantiated "hid-over-i2c" type i2c-clients.
2728
select I2C_HID_CORE
2829
help
2930
Say Y here if you use a keyboard, a touchpad, a touchscreen, or any
3031
other HID based devices which is connected to your computer via I2C.
31-
This driver supports Open Firmware (Device Tree)-based systems.
32+
This driver supports Open Firmware (Device Tree)-based systems as
33+
well as binding to manually (board-file) instantiated i2c-hid-clients.
3234

3335
If unsure, say N.
3436

drivers/hid/i2c-hid/i2c-hid-of.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int i2c_hid_of_probe(struct i2c_client *client)
8282
ihid_of->ops.power_up = i2c_hid_of_power_up;
8383
ihid_of->ops.power_down = i2c_hid_of_power_down;
8484

85-
ret = of_property_read_u32(dev->of_node, "hid-descr-addr", &val);
85+
ret = device_property_read_u32(dev, "hid-descr-addr", &val);
8686
if (ret) {
8787
dev_err(dev, "HID register address not provided\n");
8888
return -ENODEV;
@@ -113,11 +113,13 @@ static int i2c_hid_of_probe(struct i2c_client *client)
113113
hid_descriptor_address, quirks);
114114
}
115115

116+
#ifdef CONFIG_OF
116117
static const struct of_device_id i2c_hid_of_match[] = {
117118
{ .compatible = "hid-over-i2c" },
118119
{},
119120
};
120121
MODULE_DEVICE_TABLE(of, i2c_hid_of_match);
122+
#endif
121123

122124
static const struct i2c_device_id i2c_hid_of_id_table[] = {
123125
{ "hid", 0 },

0 commit comments

Comments
 (0)