mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 22:25:03 +00:00
cpufreq: brcmstb-avs-cpufreq: Free resources in error path
[ Upstream commit05f456286f
] If 'cpufreq_register_driver()' fails, we must release the resources allocated in 'brcm_avs_prepare_init()' as already done in the remove function. To do that, introduce a new function 'brcm_avs_prepare_uninit()' in order to avoid code duplication. This also makes the code more readable (IMHO). Fixes:de322e0859
("cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> [ Viresh: Updated Subject ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
24932862d9
commit
279bc604e2
1 changed files with 16 additions and 5 deletions
|
@ -566,6 +566,16 @@ static int brcm_avs_prepare_init(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void brcm_avs_prepare_uninit(struct platform_device *pdev)
|
||||
{
|
||||
struct private_data *priv;
|
||||
|
||||
priv = platform_get_drvdata(pdev);
|
||||
|
||||
iounmap(priv->avs_intr_base);
|
||||
iounmap(priv->base);
|
||||
}
|
||||
|
||||
static int brcm_avs_cpufreq_init(struct cpufreq_policy *policy)
|
||||
{
|
||||
struct cpufreq_frequency_table *freq_table;
|
||||
|
@ -701,21 +711,22 @@ static int brcm_avs_cpufreq_probe(struct platform_device *pdev)
|
|||
|
||||
brcm_avs_driver.driver_data = pdev;
|
||||
|
||||
return cpufreq_register_driver(&brcm_avs_driver);
|
||||
ret = cpufreq_register_driver(&brcm_avs_driver);
|
||||
if (ret)
|
||||
brcm_avs_prepare_uninit(pdev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int brcm_avs_cpufreq_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct private_data *priv;
|
||||
int ret;
|
||||
|
||||
ret = cpufreq_unregister_driver(&brcm_avs_driver);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
priv = platform_get_drvdata(pdev);
|
||||
iounmap(priv->base);
|
||||
iounmap(priv->avs_intr_base);
|
||||
brcm_avs_prepare_uninit(pdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue