Skip to content

Commit 185a23b

Browse files
committed
Merge branch 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm into pm-cpufreq
Pull cpufreq driver fixes for v5.1 from Viresh Kumar: "This pull request contains minor fixes for ap806 and kryo cpufreq drivers (Julia Lawall and Viresh Kumar)." * 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: cpufreq: kryo: Release OPP tables on module removal cpufreq: ap806: add missing of_node_put after of_device_is_available
2 parents 17162a1 + 0334906 commit 185a23b

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

drivers/cpufreq/armada-8k-cpufreq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ static int __init armada_8k_cpufreq_init(void)
128128
struct cpumask cpus;
129129

130130
node = of_find_compatible_node(NULL, NULL, "marvell,ap806-cpu-clock");
131-
if (!node || !of_device_is_available(node))
131+
if (!node || !of_device_is_available(node)) {
132+
of_node_put(node);
132133
return -ENODEV;
134+
}
133135

134136
nb_cpus = num_possible_cpus();
135137
freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);

drivers/cpufreq/qcom-cpufreq-kryo.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static enum _msm8996_version qcom_cpufreq_kryo_get_msm_id(void)
7575

7676
static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
7777
{
78-
struct opp_table *opp_tables[NR_CPUS] = {0};
78+
struct opp_table **opp_tables;
7979
enum _msm8996_version msm8996_version;
8080
struct nvmem_cell *speedbin_nvmem;
8181
struct device_node *np;
@@ -133,6 +133,10 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
133133
}
134134
kfree(speedbin);
135135

136+
opp_tables = kcalloc(num_possible_cpus(), sizeof(*opp_tables), GFP_KERNEL);
137+
if (!opp_tables)
138+
return -ENOMEM;
139+
136140
for_each_possible_cpu(cpu) {
137141
cpu_dev = get_cpu_device(cpu);
138142
if (NULL == cpu_dev) {
@@ -151,8 +155,10 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
151155

152156
cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1,
153157
NULL, 0);
154-
if (!IS_ERR(cpufreq_dt_pdev))
158+
if (!IS_ERR(cpufreq_dt_pdev)) {
159+
platform_set_drvdata(pdev, opp_tables);
155160
return 0;
161+
}
156162

157163
ret = PTR_ERR(cpufreq_dt_pdev);
158164
dev_err(cpu_dev, "Failed to register platform device\n");
@@ -163,13 +169,23 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
163169
break;
164170
dev_pm_opp_put_supported_hw(opp_tables[cpu]);
165171
}
172+
kfree(opp_tables);
166173

167174
return ret;
168175
}
169176

170177
static int qcom_cpufreq_kryo_remove(struct platform_device *pdev)
171178
{
179+
struct opp_table **opp_tables = platform_get_drvdata(pdev);
180+
unsigned int cpu;
181+
172182
platform_device_unregister(cpufreq_dt_pdev);
183+
184+
for_each_possible_cpu(cpu)
185+
dev_pm_opp_put_supported_hw(opp_tables[cpu]);
186+
187+
kfree(opp_tables);
188+
173189
return 0;
174190
}
175191

0 commit comments

Comments
 (0)