Skip to content

Commit f126fba

Browse files
mtk-rex-bc-chenvireshk
authored andcommitted
cpufreq: mediatek: Unregister platform device on exit
We register the platform device when driver inits. However, we do not unregister it when driver exits. To resolve this, we declare the platform data to be a global static variable and rename it to be "cpufreq_pdev". With this global variable, we can do platform_device_unregister() when driver exits. Fixes: 501c574 ("cpufreq: mediatek: Add support of cpufreq to MT2701/MT7623 SoC") Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com> [ Viresh: Commit log and Subject ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent a3b8d1b commit f126fba

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/cpufreq/mediatek-cpufreq.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ struct mtk_cpu_dvfs_info {
4343
int pre_vproc;
4444
};
4545

46+
static struct platform_device *cpufreq_pdev;
47+
4648
static LIST_HEAD(dvfs_info_list);
4749

4850
static struct mtk_cpu_dvfs_info *mtk_cpu_dvfs_info_lookup(int cpu)
@@ -578,7 +580,6 @@ static int __init mtk_cpufreq_driver_init(void)
578580
{
579581
struct device_node *np;
580582
const struct of_device_id *match;
581-
struct platform_device *pdev;
582583
int err;
583584

584585
np = of_find_node_by_path("/");
@@ -602,11 +603,11 @@ static int __init mtk_cpufreq_driver_init(void)
602603
* and the device registration codes are put here to handle defer
603604
* probing.
604605
*/
605-
pdev = platform_device_register_simple("mtk-cpufreq", -1, NULL, 0);
606-
if (IS_ERR(pdev)) {
606+
cpufreq_pdev = platform_device_register_simple("mtk-cpufreq", -1, NULL, 0);
607+
if (IS_ERR(cpufreq_pdev)) {
607608
pr_err("failed to register mtk-cpufreq platform device\n");
608609
platform_driver_unregister(&mtk_cpufreq_platdrv);
609-
return PTR_ERR(pdev);
610+
return PTR_ERR(cpufreq_pdev);
610611
}
611612

612613
return 0;
@@ -615,6 +616,7 @@ module_init(mtk_cpufreq_driver_init)
615616

616617
static void __exit mtk_cpufreq_driver_exit(void)
617618
{
619+
platform_device_unregister(cpufreq_pdev);
618620
platform_driver_unregister(&mtk_cpufreq_platdrv);
619621
}
620622
module_exit(mtk_cpufreq_driver_exit)

0 commit comments

Comments
 (0)