diff options
author | Stephen Boyd <swboyd@chromium.org> | 2020-08-03 17:05:31 -0700 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-08-17 13:33:44 +0100 |
commit | 653bdab267bd8dbce9cbd16bec843ca9d20a8450 (patch) | |
tree | b37580a29e863fb7e85bb7aabb56166b4a6cd35d /sound/soc/codecs | |
parent | edbd24ea1e5c72980b37ae2d271696b05274d509 (diff) | |
download | linux-653bdab267bd8dbce9cbd16bec843ca9d20a8450.tar.gz linux-653bdab267bd8dbce9cbd16bec843ca9d20a8450.tar.bz2 linux-653bdab267bd8dbce9cbd16bec843ca9d20a8450.zip |
ASoC: rt5682: Use clk_hw based APIs for registration
The (new?) style of clk registration uses clk_hw based APIs so that we
can more easily see the difference between clk providers and clk
consumers. Use the clk_hw based APIs to do this and migrate to devm for
the clkdev creation so that we can reduce the amount of code.
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20200804000531.920688-4-swboyd@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/rt5682.c | 47 | ||||
-rw-r--r-- | sound/soc/codecs/rt5682.h | 2 |
2 files changed, 11 insertions, 38 deletions
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index d8a1973a4624..bfb26fec7137 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -2755,8 +2755,6 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component) struct device *dev = component->dev; struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); struct rt5682_platform_data *pdata = &rt5682->pdata; - struct clk *dai_clk; - struct clk_lookup *dai_clk_lookup; struct clk_hw *dai_clk_hw; int i, ret; @@ -2784,8 +2782,7 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component) break; default: dev_err(dev, "Invalid clock index\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } init.name = pdata->dai_clk_names[i]; @@ -2793,39 +2790,26 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component) init.flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_GATE; dai_clk_hw->init = &init; - dai_clk = devm_clk_register(dev, dai_clk_hw); - if (IS_ERR(dai_clk)) { - dev_warn(dev, "Failed to register %s: %ld\n", - init.name, PTR_ERR(dai_clk)); - ret = PTR_ERR(dai_clk); - goto err; + ret = devm_clk_hw_register(dev, dai_clk_hw); + if (ret) { + dev_warn(dev, "Failed to register %s: %d\n", + init.name, ret); + return ret; } - rt5682->dai_clks[i] = dai_clk; if (dev->of_node) { devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, dai_clk_hw); } else { - dai_clk_lookup = clkdev_create(dai_clk, init.name, - "%s", dev_name(dev)); - if (!dai_clk_lookup) { - ret = -ENOMEM; - goto err; - } else { - rt5682->dai_clks_lookup[i] = dai_clk_lookup; - } + ret = devm_clk_hw_register_clkdev(dev, dai_clk_hw, + init.name, + dev_name(dev)); + if (ret) + return ret; } } return 0; - -err: - do { - if (rt5682->dai_clks_lookup[i]) - clkdev_drop(rt5682->dai_clks_lookup[i]); - } while (i-- > 0); - - return ret; } #endif /* CONFIG_COMMON_CLK */ @@ -2882,15 +2866,6 @@ static void rt5682_remove(struct snd_soc_component *component) { struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); -#ifdef CONFIG_COMMON_CLK - int i; - - for (i = RT5682_DAI_NUM_CLKS - 1; i >= 0; --i) { - if (rt5682->dai_clks_lookup[i]) - clkdev_drop(rt5682->dai_clks_lookup[i]); - } -#endif - rt5682_reset(rt5682); } diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h index 6d94327beae5..354acd735ef4 100644 --- a/sound/soc/codecs/rt5682.h +++ b/sound/soc/codecs/rt5682.h @@ -1411,8 +1411,6 @@ struct rt5682_priv { #ifdef CONFIG_COMMON_CLK struct clk_hw dai_clks_hw[RT5682_DAI_NUM_CLKS]; - struct clk_lookup *dai_clks_lookup[RT5682_DAI_NUM_CLKS]; - struct clk *dai_clks[RT5682_DAI_NUM_CLKS]; struct clk *mclk; #endif |