From af287a04b30f1e3f917c027b231803d82c2252c8 Mon Sep 17 00:00:00 2001 From: Taniya Das Date: Wed, 20 May 2020 16:49:51 +0530 Subject: [PATCH] cpufreq: qcom: Add code to support module removal Support module remove and cleanup of the OPP table entries. In the case where the driver registers for IRQ, free the IRQ and also remove the sysfs. Change-Id: I090a6e6fbcce4578e186fb8bc33cd68de42b34d8 Signed-off-by: Taniya Das --- drivers/cpufreq/qcom-cpufreq-hw.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 975943b43459..eee9ab549d6d 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -528,14 +528,14 @@ static int qcom_resources_init(struct platform_device *pdev) unsigned int cpu; int ret; - clk = devm_clk_get(&pdev->dev, "xo"); + clk = clk_get(&pdev->dev, "xo"); if (IS_ERR(clk)) return PTR_ERR(clk); xo_rate = clk_get_rate(clk); clk_put(clk); - clk = devm_clk_get(&pdev->dev, "alternate"); + clk = clk_get(&pdev->dev, "alternate"); if (IS_ERR(clk)) return PTR_ERR(clk); @@ -612,6 +612,25 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) static int qcom_cpufreq_hw_driver_remove(struct platform_device *pdev) { + struct cpufreq_qcom *c; + struct device *cpu_dev; + int cpu; + + for_each_possible_cpu(cpu) { + cpu_dev = get_cpu_device(cpu); + if (!cpu_dev) + continue; + + dev_pm_opp_remove_all_dynamic(cpu_dev); + + c = qcom_freq_domain_map[cpu]; + if (c->dcvsh_irq > 0 && c->is_irq_requested) { + devm_free_irq(cpu_dev, c->dcvsh_irq, c); + device_remove_file(cpu_dev, &c->freq_limit_attr); + c->is_irq_requested = false; + } + } + return cpufreq_unregister_driver(&cpufreq_qcom_hw_driver); }