]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
Input: axp20x-pek - do not register input device on some systems
authorHans de Goede <hdegoede@redhat.com>
Thu, 9 Mar 2017 17:55:49 +0000 (09:55 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 9 Mar 2017 18:01:03 +0000 (10:01 -0800)
On some systems (Intel tablets with axp288 pmic) the powerbutton is
also connected to a gpio pin of the SoC, advertised through the
"INTCFD9" / "PNP0C40" acpi device. This leads to double reporting
of powerbutton events, which is undesirable, so one driver needs
to not report input events in this case.

Since the soc_button_array driver for the "PNP0C40" acpi device
also handles wake from suspend on these tablets and since the
axp20x-pel driver requires relative expensive i2c accrsses,
it is best for the axp20x-pek driver to not register an input device
in this case.

Note that this commit leaves the axp20x-driver bound to the
device, rather then returning -ENODEV, this is done so that the
sysfs attributes it offers are kept around.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/axp20x-pek.c

index b7258ecd5a17d0a4c43c85bc16bb7c8bea16aa02..f11807db69792a1c19661b6921caceee247fbaf5 100644 (file)
@@ -13,6 +13,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/acpi.h>
 #include <linux/errno.h>
 #include <linux/irq.h>
 #include <linux/init.h>
@@ -267,9 +268,17 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 
        axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
 
-       error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
-       if (error)
-               return error;
+       /*
+        * Do not register the input device if there is an "INTCFD9"
+        * gpio button ACPI device, that handles the power button too,
+        * and otherwise we end up reporting all presses twice.
+        */
+       if (!acpi_dev_found("INTCFD9") ||
+           !IS_ENABLED(CONFIG_INPUT_SOC_BUTTON_ARRAY)) {
+               error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
+               if (error)
+                       return error;
+       }
 
        error = sysfs_create_group(&pdev->dev.kobj, &axp20x_attribute_group);
        if (error) {