Skip to content

Commit

Permalink
cpufreq: ti-cpufreq: Use devres managed API in probe()
Browse files Browse the repository at this point in the history
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 <s-anna@ti.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Suman Anna authored and Rafael J. Wysocki committed Jun 6, 2018
1 parent e5d295b commit d7231f9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/cpufreq/ti-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
if (!match)
return -ENODEV;

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

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

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

fail_put_node:
of_node_put(opp_data->opp_node);
free_opp_data:
kfree(opp_data);

return ret;
}
Expand Down

0 comments on commit d7231f9

Please sign in to comment.