Skip to content

Commit

Permalink
ASoC: samsung: Handle errors when getting the op_clk clock
Browse files Browse the repository at this point in the history
Ensure i2s->op_clk is not used when clk_get() for this clock fails.
This prevents working with an incorrectly configured clock in some
conditions.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Sylwester Nawrocki authored and Mark Brown committed May 22, 2014
1 parent 1d55417 commit a6aba53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sound/soc/samsung/i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai,
clk_id = 1;

if (!any_active(i2s)) {
if (i2s->op_clk) {
if (i2s->op_clk && !IS_ERR(i2s->op_clk)) {
if ((clk_id && !(mod & MOD_IMS_SYSMUX)) ||
(!clk_id && (mod & MOD_IMS_SYSMUX))) {
clk_disable_unprepare(i2s->op_clk);
Expand All @@ -506,6 +506,10 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai,
else
i2s->op_clk = clk_get(&i2s->pdev->dev,
"i2s_opclk0");

if (WARN_ON(IS_ERR(i2s->op_clk)))
return PTR_ERR(i2s->op_clk);

clk_prepare_enable(i2s->op_clk);
i2s->rclk_srcrate = clk_get_rate(i2s->op_clk);

Expand Down

0 comments on commit a6aba53

Please sign in to comment.