From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Support Opensource <support.opensource@diasemi.com>
Cc: Myeonghun Pak <mhun512@gmail.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Input: da9055_onkey - switch to using managed resources
Date: Sat, 17 Oct 2026 23:12:10 -0700 [thread overview]
Message-ID: <atRjCWI0PXs840rl@google.com> (raw)
Switch the driver to use devm_input_allocate_device(),
devm_delayed_work_autocancel(), and devm_request_threaded_irq() to
simplify error handling in probe and drop the remove() callback (which
also had a leftover broken regmap_irq_get_virq() call on an already
mapped virtual IRQ). Also use input_set_capability() to advertise
KEY_POWER support and drop unneeded error messages.
Reported-by: Myeonghun Pak <mhun512@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/misc/da9055_onkey.c | 59 ++++++++-----------------------
1 file changed, 15 insertions(+), 44 deletions(-)
diff --git a/drivers/input/misc/da9055_onkey.c b/drivers/input/misc/da9055_onkey.c
index 3e4fc2f01011..25845106b920 100644
--- a/drivers/input/misc/da9055_onkey.c
+++ b/drivers/input/misc/da9055_onkey.c
@@ -7,6 +7,7 @@
* Author: David Dajun Chen <dchen@diasemi.com>
*/
+#include <linux/devm-helpers.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -45,7 +46,6 @@ static void da9055_onkey_query(struct da9055_onkey *onkey)
*/
if (key_stat)
schedule_delayed_work(&onkey->work, msecs_to_jiffies(10));
-
}
static void da9055_onkey_work(struct work_struct *work)
@@ -80,72 +80,43 @@ static int da9055_onkey_probe(struct platform_device *pdev)
return -EINVAL;
onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
- if (!onkey) {
- dev_err(&pdev->dev, "Failed to allocate memory\n");
+ if (!onkey)
return -ENOMEM;
- }
- input_dev = input_allocate_device();
- if (!input_dev) {
- dev_err(&pdev->dev, "Failed to allocate memory\n");
+ input_dev = devm_input_allocate_device(&pdev->dev);
+ if (!input_dev)
return -ENOMEM;
- }
onkey->input = input_dev;
onkey->da9055 = da9055;
input_dev->name = "da9055-onkey";
input_dev->phys = "da9055-onkey/input0";
- input_dev->dev.parent = &pdev->dev;
- input_dev->evbit[0] = BIT_MASK(EV_KEY);
- __set_bit(KEY_POWER, input_dev->keybit);
+ input_set_capability(input_dev, EV_KEY, KEY_POWER);
- INIT_DELAYED_WORK(&onkey->work, da9055_onkey_work);
+ err = devm_delayed_work_autocancel(&pdev->dev, &onkey->work,
+ da9055_onkey_work);
+ if (err)
+ return err;
- err = request_threaded_irq(irq, NULL, da9055_onkey_irq,
- IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
- "ONKEY", onkey);
- if (err < 0) {
- dev_err(&pdev->dev,
- "Failed to register ONKEY IRQ %d, error = %d\n",
- irq, err);
- goto err_free_input;
- }
+ err = devm_request_threaded_irq(&pdev->dev, irq, NULL, da9055_onkey_irq,
+ IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+ "ONKEY", onkey);
+ if (err)
+ return err;
err = input_register_device(input_dev);
if (err) {
dev_err(&pdev->dev, "Unable to register input device, %d\n",
err);
- goto err_free_irq;
+ return err;
}
- platform_set_drvdata(pdev, onkey);
-
return 0;
-
-err_free_irq:
- free_irq(irq, onkey);
- cancel_delayed_work_sync(&onkey->work);
-err_free_input:
- input_free_device(input_dev);
-
- return err;
-}
-
-static void da9055_onkey_remove(struct platform_device *pdev)
-{
- struct da9055_onkey *onkey = platform_get_drvdata(pdev);
- int irq = platform_get_irq_byname(pdev, "ONKEY");
-
- irq = regmap_irq_get_virq(onkey->da9055->irq_data, irq);
- free_irq(irq, onkey);
- cancel_delayed_work_sync(&onkey->work);
- input_unregister_device(onkey->input);
}
static struct platform_driver da9055_onkey_driver = {
.probe = da9055_onkey_probe,
- .remove = da9055_onkey_remove,
.driver = {
.name = "da9055-onkey",
},
--
2.56.0.176.g3575e65682-goog
--
Dmitry
reply other threads:[~2026-10-18 6:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=atRjCWI0PXs840rl@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhun512@gmail.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.