[PATCH v4 2/2] counter: ti-eqep: Use devm_counter_add()

From: phucduc . bui

Date: Mon Nov 09 2026 - 03:57:50 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
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