mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: phucduc.bui@gmail.com
To: wbg@kernel.org, andriy.shevchenko@intel.com,
	David Lechner <david@lechnology.com>
Cc: andy@kernel.org, dlechner@baylibre.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	m32285159@gmail.com, nuno.sa@analog.com, phucduc.bui@gmail.com,
	sozdayvek@gmail.com
Subject: [PATCH v4 2/2] counter: ti-eqep: Use devm_counter_add()
Date: Mon,  9 Nov 2026 15:43:42 +0700	[thread overview]
Message-ID: <20261109084342.51865-3-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20261109084342.51865-1-phucduc.bui@gmail.com>

From: bui duc phuc <phucduc.bui@gmail.com>

Use devm_counter_add() instead of counter_add() to automatically
unregister the counter when the device is removed or probe fails.

This makes ti_eqep_remove() unnecessary, so remove it.

Suggested-by: William Breathitt Gray <wbg@kernel.org>
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 drivers/counter/ti-eqep.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c
index 2326515d5585..1c26008846a0 100644
--- a/drivers/counter/ti-eqep.c
+++ b/drivers/counter/ti-eqep.c
@@ -564,20 +564,13 @@ static int ti_eqep_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return dev_err_probe(dev, PTR_ERR(clk), "failed to enable clock\n");
 
-	err = counter_add(counter);
+	err = devm_counter_add(dev, counter);
 	if (err < 0)
 		return dev_err_probe(dev, err, "failed to add counter\n");
 
 	return 0;
 }
 
-static void ti_eqep_remove(struct platform_device *pdev)
-{
-	struct counter_device *counter = platform_get_drvdata(pdev);
-
-	counter_unregister(counter);
-}
-
 static const struct of_device_id ti_eqep_of_match[] = {
 	{ .compatible = "ti,am3352-eqep", },
 	{ .compatible = "ti,am62-eqep", },
@@ -587,7 +580,6 @@ MODULE_DEVICE_TABLE(of, ti_eqep_of_match);
 
 static struct platform_driver ti_eqep_driver = {
 	.probe = ti_eqep_probe,
-	.remove = ti_eqep_remove,
 	.driver = {
 		.name = "ti-eqep-cnt",
 		.of_match_table = ti_eqep_of_match,
-- 
2.43.0


      parent reply	other threads:[~2026-11-09  8:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09  8:43 [PATCH v4 0/2] counter: ti-eqep: Fix runtime PM leak and use devm_counter_add() phucduc.bui
2026-11-09  8:43 ` [PATCH v4 1/2] counter: ti-eqep: Fix runtime PM leak on probe failure phucduc.bui
2026-11-09  8:43 ` phucduc.bui [this message]

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=20261109084342.51865-3-phucduc.bui@gmail.com \
    --to=phucduc.bui@gmail.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=david@lechnology.com \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m32285159@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=sozdayvek@gmail.com \
    --cc=wbg@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®