* [PATCH 1/3] Input: axp20x-pek - Use our own device for errors
@ 2017-01-09 17:56 Hans de Goede
2017-01-09 17:56 ` [PATCH 2/3] Input: axp20x_pek - Add axp20x_pek_probe_input_device helper Hans de Goede
2017-01-09 17:56 ` [PATCH 3/3] Input: axp20x-pek - Do not register input device on some systems Hans de Goede
0 siblings, 2 replies; 3+ messages in thread
From: Hans de Goede @ 2017-01-09 17:56 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Hans de Goede, russianneuromancer @ ya . ru, Gregor Riepl,
linux-input
Before this commit axp20x-pek was mixing 2 style error reporting calls:
dev_err(&pdev->dev, ...);
dev_err(axp20x->dev, ...);
But the second is our parent device, not our own device, so switch to
using &pdev->dev everywhere.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/misc/axp20x-pek.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 1ac898d..a041365 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -239,7 +239,7 @@ static int axp20x_pek_probe(struct platform_device *pdev)
axp20x_pek_irq, 0,
"axp20x-pek-dbr", idev);
if (error < 0) {
- dev_err(axp20x->dev, "Failed to request dbr IRQ#%d: %d\n",
+ dev_err(&pdev->dev, "Failed to request dbr IRQ#%d: %d\n",
axp20x_pek->irq_dbr, error);
return error;
}
@@ -248,14 +248,14 @@ static int axp20x_pek_probe(struct platform_device *pdev)
axp20x_pek_irq, 0,
"axp20x-pek-dbf", idev);
if (error < 0) {
- dev_err(axp20x->dev, "Failed to request dbf IRQ#%d: %d\n",
+ dev_err(&pdev->dev, "Failed to request dbf IRQ#%d: %d\n",
axp20x_pek->irq_dbf, error);
return error;
}
error = sysfs_create_group(&pdev->dev.kobj, &axp20x_attribute_group);
if (error) {
- dev_err(axp20x->dev, "Failed to create sysfs attributes: %d\n",
+ dev_err(&pdev->dev, "Failed to create sysfs attributes: %d\n",
error);
return error;
}
@@ -271,7 +271,7 @@ static int axp20x_pek_probe(struct platform_device *pdev)
error = input_register_device(idev);
if (error) {
- dev_err(axp20x->dev, "Can't register input device: %d\n",
+ dev_err(&pdev->dev, "Can't register input device: %d\n",
error);
return error;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] Input: axp20x_pek - Add axp20x_pek_probe_input_device helper
2017-01-09 17:56 [PATCH 1/3] Input: axp20x-pek - Use our own device for errors Hans de Goede
@ 2017-01-09 17:56 ` Hans de Goede
2017-01-09 17:56 ` [PATCH 3/3] Input: axp20x-pek - Do not register input device on some systems Hans de Goede
1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2017-01-09 17:56 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Hans de Goede, russianneuromancer @ ya . ru, Gregor Riepl,
linux-input
Move all input device related initialization into a new
axp20x_pek_probe_input_device helper function.
This introduces one functional change, the input device is now
registered before the sysfs attr get registered. This is not a problem
as the sysfs attr are to configure some long press settings (forced
poweroff) in the hardware and do not interact with the input_device.
This is a preparation patch for not always registering the input dev.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/misc/axp20x-pek.c | 47 +++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 18 deletions(-)
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index a041365..b7258ec 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -188,21 +188,13 @@ static void axp20x_remove_sysfs_group(void *_data)
sysfs_remove_group(&dev->kobj, &axp20x_attribute_group);
}
-static int axp20x_pek_probe(struct platform_device *pdev)
+static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
+ struct platform_device *pdev)
{
- struct axp20x_pek *axp20x_pek;
- struct axp20x_dev *axp20x;
+ struct axp20x_dev *axp20x = axp20x_pek->axp20x;
struct input_dev *idev;
int error;
- axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
- GFP_KERNEL);
- if (!axp20x_pek)
- return -ENOMEM;
-
- axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
- axp20x = axp20x_pek->axp20x;
-
axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
if (axp20x_pek->irq_dbr < 0) {
dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n",
@@ -253,6 +245,32 @@ static int axp20x_pek_probe(struct platform_device *pdev)
return error;
}
+ error = input_register_device(idev);
+ if (error) {
+ dev_err(&pdev->dev, "Can't register input device: %d\n",
+ error);
+ return error;
+ }
+
+ return 0;
+}
+
+static int axp20x_pek_probe(struct platform_device *pdev)
+{
+ struct axp20x_pek *axp20x_pek;
+ int error;
+
+ axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
+ GFP_KERNEL);
+ if (!axp20x_pek)
+ return -ENOMEM;
+
+ axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
+
+ 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) {
dev_err(&pdev->dev, "Failed to create sysfs attributes: %d\n",
@@ -269,13 +287,6 @@ static int axp20x_pek_probe(struct platform_device *pdev)
return error;
}
- error = input_register_device(idev);
- if (error) {
- dev_err(&pdev->dev, "Can't register input device: %d\n",
- error);
- return error;
- }
-
platform_set_drvdata(pdev, axp20x_pek);
return 0;
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] Input: axp20x-pek - Do not register input device on some systems
2017-01-09 17:56 [PATCH 1/3] Input: axp20x-pek - Use our own device for errors Hans de Goede
2017-01-09 17:56 ` [PATCH 2/3] Input: axp20x_pek - Add axp20x_pek_probe_input_device helper Hans de Goede
@ 2017-01-09 17:56 ` Hans de Goede
1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2017-01-09 17:56 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Hans de Goede, russianneuromancer @ ya . ru, Gregor Riepl,
linux-input
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>
---
drivers/input/misc/axp20x-pek.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index b7258ec..dbd2c89 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -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,16 @@ 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")) {
+ 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) {
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-09 17:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-09 17:56 [PATCH 1/3] Input: axp20x-pek - Use our own device for errors Hans de Goede
2017-01-09 17:56 ` [PATCH 2/3] Input: axp20x_pek - Add axp20x_pek_probe_input_device helper Hans de Goede
2017-01-09 17:56 ` [PATCH 3/3] Input: axp20x-pek - Do not register input device on some systems Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).