diff options
author | Mark Brown <broonie@kernel.org> | 2022-03-25 16:31:18 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2022-04-04 09:39:31 +0200 |
commit | 8875d104af6c237bfedb47309afd938984a3c05b (patch) | |
tree | e55617d6f60ea0071c1a831f5f53eb9092c78ace /sound/soc/codecs/wm8731.c | |
parent | ASoC: wm8731: Move regulator request into wm8731_init() (diff) | |
download | linux-8875d104af6c237bfedb47309afd938984a3c05b.tar.xz linux-8875d104af6c237bfedb47309afd938984a3c05b.zip |
ASoC: wm8731: Factor our MCLK and mutex initialisation
The code for initialising the MCLK and mutex is identical in the I2C and SPI
probe functions so just move this out into wm8731_init().
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220325153121.1598494-5-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/wm8731.c')
-rw-r--r-- | sound/soc/codecs/wm8731.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 334332bb5f22..43730aba11fe 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -588,6 +588,20 @@ static int wm8731_init(struct device *dev, struct wm8731_priv *wm8731) { int ret = 0, i; + wm8731->mclk = devm_clk_get(dev, "mclk"); + if (IS_ERR(wm8731->mclk)) { + ret = PTR_ERR(wm8731->mclk); + if (ret == -ENOENT) { + wm8731->mclk = NULL; + dev_warn(dev, "Assuming static MCLK\n"); + } else { + dev_err(dev, "Failed to get MCLK: %d\n", ret); + return ret; + } + } + + mutex_init(&wm8731->lock); + for (i = 0; i < ARRAY_SIZE(wm8731->supplies); i++) wm8731->supplies[i].supply = wm8731_supply_names[i]; @@ -670,21 +684,6 @@ static int wm8731_spi_probe(struct spi_device *spi) if (wm8731 == NULL) return -ENOMEM; - wm8731->mclk = devm_clk_get(&spi->dev, "mclk"); - if (IS_ERR(wm8731->mclk)) { - ret = PTR_ERR(wm8731->mclk); - if (ret == -ENOENT) { - wm8731->mclk = NULL; - dev_warn(&spi->dev, "Assuming static MCLK\n"); - } else { - dev_err(&spi->dev, "Failed to get MCLK: %d\n", - ret); - return ret; - } - } - - mutex_init(&wm8731->lock); - spi_set_drvdata(spi, wm8731); wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap); @@ -719,21 +718,6 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, if (wm8731 == NULL) return -ENOMEM; - wm8731->mclk = devm_clk_get(&i2c->dev, "mclk"); - if (IS_ERR(wm8731->mclk)) { - ret = PTR_ERR(wm8731->mclk); - if (ret == -ENOENT) { - wm8731->mclk = NULL; - dev_warn(&i2c->dev, "Assuming static MCLK\n"); - } else { - dev_err(&i2c->dev, "Failed to get MCLK: %d\n", - ret); - return ret; - } - } - - mutex_init(&wm8731->lock); - i2c_set_clientdata(i2c, wm8731); wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap); |