Hidden dependency of i2c-hid on GPIOLIB
Hi,
my touchpad stopped working because of a485923efbb8 ("HID: i2c-hid:
Add support for ACPI GPIO interrupts"). It turned out that I need CONFIG_GPIOLIB. I think this dependency should be made explicit or the driver should not depend on it.
Regards,
Gabriele
Quoted 6 lines · Gabriele Mazzotta
Hi,
my touchpad stopped working because of
a485923efbb8("HID: i2c-hid:
Add support for ACPI GPIO interrupts"). It turned out that I needCONFIG_GPIOLIB. I think this dependency should be made explicit or the driver should not depend on it.
Using GPIOs should be optional. Gpiolib stubs functions out whenever it is not enabled.
However, I made a mistake when GPIOs are fed to the driver. If gpiolib is not enabled acpi_dev_add_driver_gpios() returns -ENXIO and prevents your touchpad from working.
I think it is alright to ignore the error here. Can you try if below patch helps?
drivers/hid/i2c-hid/i2c-hid.c +2 -1
@@ -877,7 +877,8 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client, pdata->hid_descriptor_address = obj->integer.value;ACPI_FREE (obj); -return acpi_dev_add_driver_gpios (adev, i2c_hid_acpi_gpios); +acpi_dev_add_driver_gpios (adev, i2c_hid_acpi_gpios); +return 0 ; }static const struct acpi_device_id i2c_hid_acpi_match[] = {
Quoted 11 lines · On Tuesday 14 April 2015 12:59:24 Mika Westerberg wrote:
Quoted 6 lines · Gabriele Mazzotta
Hi,
my touchpad stopped working because of
a485923efbb8("HID: i2c-hid:
Add support for ACPI GPIO interrupts"). It turned out that I needCONFIG_GPIOLIB. I think this dependency should be made explicit or the driver should not depend on it.Using GPIOs should be optional. Gpiolib stubs functions out whenever it is not enabled.
Quoted 6 lines
However, I made a mistake when GPIOs are fed to the driver. If gpiolib is not enabled
acpi_dev_add_driver_gpios()returns-ENXIOand prevents your touchpad from working.I think it is alright to ignore the error here. Can you try if below patch helps?
Sorry for not being more specific. Yes, the problem is that acpi_dev_add_driver_gpios() returns -ENXIO if CONFIG_GPIOLIB is not set.
Quoted 14 lines
drivers/hid/i2c-hid/i2c-hid.c +2
-1@@ -877,7 +877,8 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client, pdata->hid_descriptor_address = obj->integer.value;ACPI_FREE (obj); -return acpi_dev_add_driver_gpios (adev, i2c_hid_acpi_gpios); +acpi_dev_add_driver_gpios (adev, i2c_hid_acpi_gpios); +return 0 ; }static const struct acpi_device_id i2c_hid_acpi_match[] = {
PATCH 1/1 HID: i2c-hid: Do not fail probing if gpiolib is not enabled
Using GPIOs and gpiolib is optional. If the kernel is compiled without GPIO support the driver should not fail if it finds the interrupt using normal methods.
However, commit a485923efbb8 ("HID: i2c-hid: Add support for ACPI GPIO interrupts") did not take into account that acpi_dev_add_driver_gpios() returns -ENXIO when !CONFIG_GPIOLIB.
Fix this by checking the return value against -ENXIO and 0 and only in that case fail the probe.
--- drivers/hid/i2c-hid/i2c-hid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid.c +4 -1
@@ -862,6 +862,7 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,union acpi_object *obj;struct acpi_device *adev;acpi_handle handle; +int ret; handle =ACPI_HANDLE (&client->dev);if (!handle ||acpi_bus_get_device (handle, &adev))
@@ -877,7 +878,9 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client, pdata->hid_descriptor_address = obj->integer.value;ACPI_FREE (obj); -return acpi_dev_add_driver_gpios (adev, i2c_hid_acpi_gpios); +/* GPIOs are optional */ + ret =acpi_dev_add_driver_gpios (adev, i2c_hid_acpi_gpios); +return ret <0 && ret != -ENXIO ? ret :0 ; }static const struct acpi_device_id i2c_hid_acpi_match[] = {
Signature · 1 line
2.1.4
Jiri Kosina
AppliedRe: [PATCH] HID: i2c-hid: Do not fail probing if gpiolib is not enabled
Quoted 8 lines · Mika Westerberg
Using GPIOs and gpiolib is optional. If the kernel is compiled without GPIO support the driver should not fail if it finds the interrupt using normal methods.
However, commit
a485923efbb8("HID: i2c-hid: Add support for ACPI GPIO interrupts") did not take into account thatacpi_dev_add_driver_gpios()returns-ENXIOwhen !CONFIG_GPIOLIB.
Quoted 5 lines
Fix this by checking the return value against
-ENXIOand 0 and only in that case fail the probe.Reported-by Gabriele Mazzotta <[email protected]>Signed-off-by Mika Westerberg <[email protected]>
I have applied this to for-4.1/upstream-fixes.
Signature · 2 lines
Jiri Kosina SUSE Labs