Skip to content

Commit 3e4daba

Browse files
WillLesterjic23
authored andcommitted
counter/ftm-quaddec: Use device-managed registration API
Make use of devm_counter_register. Then we can remove redundant unregistration API usage to make code simpler. Signed-off-by: Chuhong Yuan <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent ec76d91 commit 3e4daba

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

drivers/counter/ftm-quaddec.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,18 @@ static void ftm_quaddec_init(struct ftm_quaddec *ftm)
100100
ftm_set_write_protection(ftm);
101101
}
102102

103-
static void ftm_quaddec_disable(struct ftm_quaddec *ftm)
103+
static void ftm_quaddec_disable(void *ftm)
104104
{
105-
ftm_clear_write_protection(ftm);
106-
ftm_write(ftm, FTM_MODE, 0);
107-
ftm_write(ftm, FTM_QDCTRL, 0);
105+
struct ftm_quaddec *ftm_qua = ftm;
106+
107+
ftm_clear_write_protection(ftm_qua);
108+
ftm_write(ftm_qua, FTM_MODE, 0);
109+
ftm_write(ftm_qua, FTM_QDCTRL, 0);
108110
/*
109111
* This is enough to disable the counter. No clock has been
110112
* selected by writing to FTM_SC in init()
111113
*/
112-
ftm_set_write_protection(ftm);
114+
ftm_set_write_protection(ftm_qua);
113115
}
114116

115117
static int ftm_quaddec_get_prescaler(struct counter_device *counter,
@@ -317,20 +319,13 @@ static int ftm_quaddec_probe(struct platform_device *pdev)
317319

318320
ftm_quaddec_init(ftm);
319321

320-
ret = counter_register(&ftm->counter);
322+
ret = devm_add_action_or_reset(&pdev->dev, ftm_quaddec_disable, ftm);
321323
if (ret)
322-
ftm_quaddec_disable(ftm);
323-
324-
return ret;
325-
}
324+
return ret;
326325

327-
static int ftm_quaddec_remove(struct platform_device *pdev)
328-
{
329-
struct ftm_quaddec *ftm = platform_get_drvdata(pdev);
330-
331-
counter_unregister(&ftm->counter);
332-
333-
ftm_quaddec_disable(ftm);
326+
ret = devm_counter_register(&pdev->dev, &ftm->counter);
327+
if (ret)
328+
return ret;
334329

335330
return 0;
336331
}
@@ -346,7 +341,6 @@ static struct platform_driver ftm_quaddec_driver = {
346341
.of_match_table = ftm_quaddec_match,
347342
},
348343
.probe = ftm_quaddec_probe,
349-
.remove = ftm_quaddec_remove,
350344
};
351345

352346
module_platform_driver(ftm_quaddec_driver);

0 commit comments

Comments
 (0)