All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
	Support Opensource <support.opensource@diasemi.com>,
	linux-input@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	Biju Das <biju.das.au@gmail.com>,
	linux-renesas-soc@vger.kernel.org
Subject: [PATCH v3 2/3] Input: da9063_onkey - Drop scheduling work
Date: Thu, 25 Jan 2024 13:37:32 +0000	[thread overview]
Message-ID: <20240125133733.95081-3-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20240125133733.95081-1-biju.das.jz@bp.renesas.com>

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 --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;
-- 
2.25.1


  parent reply	other threads:[~2024-01-25 13:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 13:37 [PATCH v3 0/3] Add polling support for DA9063 onkey driver Biju Das
2024-01-25 13:37 ` [PATCH v3 1/3] Input: da9063_onkey - Add da9063_onkey_report_key() Biju Das
2024-01-25 13:37 ` Biju Das [this message]
2024-01-25 13:37 ` [PATCH v3 3/3] Input: da9063_onkey - Add polling support Biju Das

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240125133733.95081-3-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=biju.das.au@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=support.opensource@diasemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.