Skip to content

Commit

Permalink
ALSA: ASoC: Fix error paths in N810 machine driver init and release c…
Browse files Browse the repository at this point in the history
…locks at exit

Thanks to Felipe Balbi <felipe.balbi@nokia.com> by noticing that if clk_get
to sys_clkout2_src fails, then n810_snd_device is never released.

Add also sys_clkout2_src release into error path, error code return and
release the clocks at exit.

Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Jarkko Nikula authored and Takashi Iwai committed Aug 26, 2008
1 parent 3d839e5 commit e784539
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions sound/soc/omap/n810.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,14 @@ static int __init n810_soc_init(void)
sys_clkout2_src = clk_get(dev, "sys_clkout2_src");
if (IS_ERR(sys_clkout2_src)) {
dev_err(dev, "Could not get sys_clkout2_src clock\n");
return -ENODEV;
err = PTR_ERR(sys_clkout2_src);
goto err2;
}
sys_clkout2 = clk_get(dev, "sys_clkout2");
if (IS_ERR(sys_clkout2)) {
dev_err(dev, "Could not get sys_clkout2\n");
goto err1;
err = PTR_ERR(sys_clkout2);
goto err3;
}
/*
* Configure 12 MHz output on SYS_CLKOUT2. Therefore we must use
Expand All @@ -343,7 +345,8 @@ static int __init n810_soc_init(void)
func96m_clk = clk_get(dev, "func_96m_ck");
if (IS_ERR(func96m_clk)) {
dev_err(dev, "Could not get func 96M clock\n");
goto err2;
err = PTR_ERR(func96m_clk);
goto err4;
}
clk_set_parent(sys_clkout2_src, func96m_clk);
clk_set_rate(sys_clkout2, 12000000);
Expand All @@ -356,20 +359,25 @@ static int __init n810_soc_init(void)
gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);

return 0;
err2:
err4:
clk_put(sys_clkout2);
err3:
clk_put(sys_clkout2_src);
err2:
platform_device_del(n810_snd_device);
err1:
platform_device_put(n810_snd_device);

return err;

}

static void __exit n810_soc_exit(void)
{
gpio_free(N810_SPEAKER_AMP_GPIO);
gpio_free(N810_HEADSET_AMP_GPIO);
clk_put(sys_clkout2_src);
clk_put(sys_clkout2);
clk_put(func96m_clk);

platform_device_unregister(n810_snd_device);
}
Expand Down

0 comments on commit e784539

Please sign in to comment.