Skip to content

Commit d7231f9

Browse files
sumanannarafaeljw
authored andcommitted
cpufreq: ti-cpufreq: Use devres managed API in probe()
The ti_cpufreq_probe() function uses regular kzalloc to allocate the ti_cpufreq_data structure and kfree for freeing this memory on failures. Simplify this code by using the devres managed API. Signed-off-by: Suman Anna <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e5d295b commit d7231f9

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/cpufreq/ti-cpufreq.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
217217
if (!match)
218218
return -ENODEV;
219219

220-
opp_data = kzalloc(sizeof(*opp_data), GFP_KERNEL);
220+
opp_data = devm_kzalloc(&pdev->dev, sizeof(*opp_data), GFP_KERNEL);
221221
if (!opp_data)
222222
return -ENOMEM;
223223

@@ -226,8 +226,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
226226
opp_data->cpu_dev = get_cpu_device(0);
227227
if (!opp_data->cpu_dev) {
228228
pr_err("%s: Failed to get device for CPU0\n", __func__);
229-
ret = -ENODEV;
230-
goto free_opp_data;
229+
return -ENODEV;
231230
}
232231

233232
opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev);
@@ -285,8 +284,6 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
285284

286285
fail_put_node:
287286
of_node_put(opp_data->opp_node);
288-
free_opp_data:
289-
kfree(opp_data);
290287

291288
return ret;
292289
}

0 commit comments

Comments
 (0)