diff mbox series

[v3,2/3] Input: da9063_onkey - Drop scheduling work

Message ID 20240125133733.95081-3-biju.das.jz@bp.renesas.com
State New
Headers show
Series Add polling support for DA9063 onkey driver | expand

Commit Message

Biju Das Jan. 25, 2024, 1:37 p.m. UTC
On threaded case it might be cleaner to avoid scheduling work and simply
loop in the interrupt thread as it can sleep.

Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/input/misc/da9063_onkey.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c
index 06ad9d09ada8..e5256bf31140 100644
--- a/drivers/input/misc/da9063_onkey.c
+++ b/drivers/input/misc/da9063_onkey.c
@@ -13,7 +13,6 @@ 
 #include <linux/platform_device.h>
 #include <linux/pm_wakeirq.h>
 #include <linux/property.h>
-#include <linux/workqueue.h>
 #include <linux/regmap.h>
 #include <linux/mfd/da9063/core.h>
 #include <linux/mfd/da9063/registers.h>
@@ -36,7 +35,6 @@  struct da906x_chip_config {
 };
 
 struct da9063_onkey {
-	struct delayed_work work;
 	struct input_dev *input;
 	struct device *dev;
 	struct regmap *regmap;
@@ -82,11 +80,8 @@  static void da9063_onkey_report_key(struct da9063_onkey *onkey,
 	input_sync(onkey->input);
 }
 
-static void da9063_poll_on(struct work_struct *work)
+static bool da9063_poll_on(struct da9063_onkey *onkey)
 {
-	struct da9063_onkey *onkey = container_of(work,
-						struct da9063_onkey,
-						work.work);
 	const struct da906x_chip_config *config = onkey->config;
 	unsigned int val;
 	int fault_log = 0;
@@ -151,8 +146,7 @@  static void da9063_poll_on(struct work_struct *work)
 	}
 
 err_poll:
-	if (poll)
-		schedule_delayed_work(&onkey->work, msecs_to_jiffies(50));
+	return poll;
 }
 
 static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
@@ -165,7 +159,8 @@  static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
 	error = regmap_read(onkey->regmap, config->onkey_status, &val);
 	da9063_onkey_report_key(onkey, KEY_POWER, 1);
 	if (onkey->key_power && !error && (val & config->onkey_nonkey_mask)) {
-		schedule_delayed_work(&onkey->work, 0);
+		while (da9063_poll_on(onkey))
+			msleep(50);
 		dev_dbg(onkey->dev, "KEY_POWER long press.\n");
 	} else {
 		da9063_onkey_report_key(onkey, KEY_POWER, 0);
@@ -211,11 +206,6 @@  static int da9063_onkey_probe(struct platform_device *pdev)
 
 	input_set_capability(onkey->input, EV_KEY, KEY_POWER);
 
-	error = devm_delayed_work_autocancel(&pdev->dev, &onkey->work,
-					     da9063_poll_on);
-	if (error)
-		return error;
-
 	irq = platform_get_irq_byname(pdev, "ONKEY");
 	if (irq < 0)
 		return irq;