[PATCH] ASoC: fsi: Add check for clk_enable
Mark Brown
broonie at kernel.org
Tue Mar 1 13:44:12 CET 2022
On Tue, Mar 01, 2022 at 03:39:49PM +0800, Jiasheng Jiang wrote:
> As the potential failure of the clk_enable(),
> it should be better to check it and return error
> if fails.
> - clk_enable(clock->xck);
> - clk_enable(clock->ick);
> - clk_enable(clock->div);
> + ret = clk_enable(clock->xck);
> + if (ret)
> + goto err;
> + ret = clk_enable(clock->ick);
> + if (ret)
> + goto err;
> + ret = clk_enable(clock->div);
> + if (ret)
> + goto err;
>
> clock->count++;
> }
>
> return ret;
> +
> +err:
> + clk_disable(clock->xck);
> + clk_disable(clock->ick);
> + clk_disable(clock->div);
You need separate labels for each enable so that we don't end up
disabling clocks we didn't enable, that would also be a bug.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20220301/de2d89ec/attachment.sig>
More information about the Alsa-devel
mailing list