Re: [alsa-devel][PATCH] ASoC: wm8960: Let wm8960 codec driver manage its own MCLK

From: Mark Brown
Date: Wed Dec 03 2014 - 07:41:55 EST


On Wed, Dec 03, 2014 at 07:00:38PM +0800, Zidan Wang wrote:

> #include <sound/core.h>
> @@ -988,6 +990,8 @@ static void wm8960_set_pdata_from_of(struct i2c_client *i2c,
>
> if (of_property_read_bool(np, "wlf,shared-lrclk"))
> pdata->shared_lrclk = true;
> +
> + pdata->mclk = devm_clk_get(&i2c->dev, NULL);

This isn't platform data then... we also need to check the return code
here and handle at least probe deferral.

> + /* Mark the mclk pointer to NULL if no mclk assigned */
> + if (IS_ERR(wm8960->pdata.mclk)) {

Indentation is wrong for the comment here.

> + /* But do not ignore the request for probe defer */
> + if (PTR_ERR(wm8960->pdata.mclk) == -EPROBE_DEFER)
> + return -EPROBE_DEFER;
> + wm8960->pdata.mclk = NULL;
> + }

OK, so we are trying to handle probe deferral - but this should be next
to the clk_get().

> + if (wm8960->pdata.mclk) {
> + ret = clk_prepare_enable(wm8960->pdata.mclk);

Just continue to use !IS_ERR() - NULL is a valid clock.

> +static int wm8960_runtime_suspend(struct device *dev)
> +{
> + struct wm8960_priv *wm8960 = dev_get_drvdata(dev);
> +
> + /* Power down PLL to save power */
> + regmap_update_bits(wm8960->regmap, WM8960_POWER2, 0x1, 0);

This isn't undone by the resume.

Attachment: signature.asc
Description: Digital signature