[alsa-devel] [PATCH 00/14] ASoC: Use devm_* APIs
This series is build tested against the for-next branch of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git tree.
Sachin Kamat (14): ASoC: wm8350: Use devm_regulator_bulk_get ASoC: wm8962: Use devm_regulator_bulk_get ASoC: wm8400: Use devm_regulator_bulk_get ASoC: wm8993: Use devm_regulator_bulk_get ASoC: ak4535: Use devm_regmap_init_i2c() ASoC: da7210: Use devm_regmap_init_i2c() ASoC: lm49453: Use devm_regmap_init_i2c() ASoC: max9768: Use devm_regmap_init_i2c() ASoC: wm8955: Use devm_regmap_init_i2c() ASoC: wm8960: Use devm_regmap_init_i2c() ASoC: wm8962: Use devm_regmap_init_i2c() ASoC: wm8978: Use devm_regmap_init_i2c() ASoC: wm8993: Use devm_regmap_init_i2c() ASoC: wm9081: Use devm_regmap_init_i2c()
sound/soc/codecs/ak4535.c | 7 +------ sound/soc/codecs/da7210.c | 13 ++----------- sound/soc/codecs/lm49453.c | 10 ++-------- sound/soc/codecs/max9768.c | 7 ++----- sound/soc/codecs/wm8350.c | 4 +--- sound/soc/codecs/wm8400.c | 14 +++----------- sound/soc/codecs/wm8955.c | 11 +---------- sound/soc/codecs/wm8960.c | 2 +- sound/soc/codecs/wm8962.c | 24 ++++++++---------------- sound/soc/codecs/wm8978.c | 13 +++---------- sound/soc/codecs/wm8993.c | 14 ++++---------- sound/soc/codecs/wm9081.c | 22 ++++++---------------- 12 files changed, 34 insertions(+), 107 deletions(-)
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8350.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index a4cae06..32b8f08 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1500,7 +1500,7 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) for (i = 0; i < ARRAY_SIZE(supply_names); i++) priv->supplies[i].supply = supply_names[i];
- ret = regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies), + ret = devm_regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies), priv->supplies); if (ret != 0) return ret; @@ -1607,8 +1607,6 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec)
wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
- regulator_bulk_free(ARRAY_SIZE(priv->supplies), priv->supplies); - return 0; }
On Mon, Nov 26, 2012 at 05:19:34PM +0530, Sachin Kamat wrote:
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Applied, thanks, but *ALWAYS* CC maintainers on patches.
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8962.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index ce67200..285a9ef 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -3610,7 +3610,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) wm8962->supplies[i].supply = wm8962_supply_names[i];
- ret = regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8962->supplies), + ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8962->supplies), wm8962->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); @@ -3621,7 +3621,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, wm8962->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); - goto err_get; + return ret; }
wm8962->regmap = regmap_init_i2c(i2c, &wm8962_regmap); @@ -3697,8 +3697,6 @@ err_regmap: regmap_exit(wm8962->regmap); err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); -err_get: - regulator_bulk_free(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); err: return ret; } @@ -3709,7 +3707,6 @@ static __devexit int wm8962_i2c_remove(struct i2c_client *client)
snd_soc_unregister_codec(&client->dev); regmap_exit(wm8962->regmap); - regulator_bulk_free(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); return 0; }
On Mon, Nov 26, 2012 at 05:19:35PM +0530, Sachin Kamat wrote:
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Applied, but again *ALWAYS* CC maintainers.
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8400.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 5d277a9..262c440 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -1373,7 +1373,7 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) codec->control_data = priv->wm8400 = wm8400; priv->codec = codec;
- ret = regulator_bulk_get(wm8400->dev, + ret = devm_regulator_bulk_get(wm8400->dev, ARRAY_SIZE(power), &power[0]); if (ret != 0) { dev_err(codec->dev, "Failed to get regulators: %d\n", ret); @@ -1398,15 +1398,9 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) snd_soc_write(codec, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); snd_soc_write(codec, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8));
- if (!schedule_work(&priv->work)) { - ret = -EINVAL; - goto err_regulator; - } + if (!schedule_work(&priv->work)) + return -EINVAL; return 0; - -err_regulator: - regulator_bulk_free(ARRAY_SIZE(power), power); - return ret; }
static int wm8400_codec_remove(struct snd_soc_codec *codec) @@ -1417,8 +1411,6 @@ static int wm8400_codec_remove(struct snd_soc_codec *codec) snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, reg & (~WM8400_CODEC_ENA));
- regulator_bulk_free(ARRAY_SIZE(power), power); - return 0; }
On Mon, Nov 26, 2012 at 05:19:36PM +0530, Sachin Kamat wrote:
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Applied, thanks. CC maintainers...
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8993.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index 94737a3..c3d3107 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c @@ -1672,7 +1672,7 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c, for (i = 0; i < ARRAY_SIZE(wm8993->supplies); i++) wm8993->supplies[i].supply = wm8993_supply_names[i];
- ret = regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8993->supplies), + ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8993->supplies), wm8993->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); @@ -1683,7 +1683,7 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c, wm8993->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); - goto err_get; + goto err; }
ret = regmap_read(wm8993->regmap, WM8993_SOFTWARE_RESET, ®); @@ -1742,8 +1742,6 @@ err_irq: free_irq(i2c->irq, wm8993); err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); -err_get: - regulator_bulk_free(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); err: regmap_exit(wm8993->regmap); return ret; @@ -1758,7 +1756,6 @@ static __devexit int wm8993_i2c_remove(struct i2c_client *i2c) free_irq(i2c->irq, wm8993); regmap_exit(wm8993->regmap); regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); - regulator_bulk_free(ARRAY_SIZE(wm8993->supplies), wm8993->supplies);
return 0; }
On Mon, Nov 26, 2012 at 05:19:37PM +0530, Sachin Kamat wrote:
devm_regulator_bulk_get() is device managed and makes error handling and code cleanup simpler.
Applied, thanks. CC maintainers.
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/ak4535.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index 618fdc3..fc55810 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c @@ -447,7 +447,7 @@ static __devinit int ak4535_i2c_probe(struct i2c_client *i2c, if (ak4535 == NULL) return -ENOMEM;
- ak4535->regmap = regmap_init_i2c(i2c, &ak4535_regmap); + ak4535->regmap = devm_regmap_init_i2c(i2c, &ak4535_regmap); if (IS_ERR(ak4535->regmap)) { ret = PTR_ERR(ak4535->regmap); dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); @@ -458,18 +458,13 @@ static __devinit int ak4535_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4535, &ak4535_dai, 1); - if (ret != 0) - regmap_exit(ak4535->regmap);
return ret; }
static __devexit int ak4535_i2c_remove(struct i2c_client *client) { - struct ak4535_priv *ak4535 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(ak4535->regmap); return 0; }
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/da7210.c | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index af5db70..ab1ee5b 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -1231,7 +1231,7 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, da7210);
- da7210->regmap = regmap_init_i2c(i2c, &da7210_regmap_config_i2c); + da7210->regmap = devm_regmap_init_i2c(i2c, &da7210_regmap_config_i2c); if (IS_ERR(da7210->regmap)) { ret = PTR_ERR(da7210->regmap); dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); @@ -1245,24 +1245,15 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da7210, &da7210_dai, 1); - if (ret < 0) { + if (ret < 0) dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); - goto err_regmap; - } - return ret; - -err_regmap: - regmap_exit(da7210->regmap);
return ret; }
static int __devexit da7210_i2c_remove(struct i2c_client *client) { - struct da7210_priv *da7210 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(da7210->regmap); return 0; }
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/lm49453.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c index 99b0a9d..096b6aa 100644 --- a/sound/soc/codecs/lm49453.c +++ b/sound/soc/codecs/lm49453.c @@ -1497,7 +1497,7 @@ static __devinit int lm49453_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, lm49453);
- lm49453->regmap = regmap_init_i2c(i2c, &lm49453_regmap_config); + lm49453->regmap = devm_regmap_init_i2c(i2c, &lm49453_regmap_config); if (IS_ERR(lm49453->regmap)) { ret = PTR_ERR(lm49453->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", @@ -1508,21 +1508,15 @@ static __devinit int lm49453_i2c_probe(struct i2c_client *i2c, ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_lm49453, lm49453_dai, ARRAY_SIZE(lm49453_dai)); - if (ret < 0) { + if (ret < 0) dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); - regmap_exit(lm49453->regmap); - return ret; - }
return ret; }
static int __devexit lm49453_i2c_remove(struct i2c_client *client) { - struct lm49453_priv *lm49453 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(lm49453->regmap); return 0; }
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/max9768.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c index 17b3ec2..a777de6 100644 --- a/sound/soc/codecs/max9768.c +++ b/sound/soc/codecs/max9768.c @@ -187,7 +187,7 @@ static int __devinit max9768_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, max9768);
- max9768->regmap = regmap_init_i2c(client, &max9768_i2c_regmap_config); + max9768->regmap = devm_regmap_init_i2c(client, &max9768_i2c_regmap_config); if (IS_ERR(max9768->regmap)) { err = PTR_ERR(max9768->regmap); goto err_gpio_free; @@ -195,12 +195,10 @@ static int __devinit max9768_i2c_probe(struct i2c_client *client,
err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0); if (err) - goto err_regmap_free; + goto err_gpio_free;
return 0;
- err_regmap_free: - regmap_exit(max9768->regmap); err_gpio_free: if (gpio_is_valid(max9768->shdn_gpio)) gpio_free(max9768->shdn_gpio); @@ -215,7 +213,6 @@ static int __devexit max9768_i2c_remove(struct i2c_client *client) struct max9768 *max9768 = i2c_get_clientdata(client);
snd_soc_unregister_codec(&client->dev); - regmap_exit(max9768->regmap);
if (gpio_is_valid(max9768->shdn_gpio)) gpio_free(max9768->shdn_gpio);
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8955.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index 2f1c075..7a82b7d 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c @@ -1023,7 +1023,7 @@ static __devinit int wm8955_i2c_probe(struct i2c_client *i2c, if (wm8955 == NULL) return -ENOMEM;
- wm8955->regmap = regmap_init_i2c(i2c, &wm8955_regmap); + wm8955->regmap = devm_regmap_init_i2c(i2c, &wm8955_regmap); if (IS_ERR(wm8955->regmap)) { ret = PTR_ERR(wm8955->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", @@ -1035,22 +1035,13 @@ static __devinit int wm8955_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8955, &wm8955_dai, 1); - if (ret != 0) - goto err;
return ret; - -err: - regmap_exit(wm8955->regmap); - return ret; }
static __devexit int wm8955_i2c_remove(struct i2c_client *client) { - struct wm8955_priv *wm8955 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(wm8955->regmap);
return 0; }
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler. There was no explicit regmap_exit call in this function which was probably a bug.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8960.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index f0f6f660..cf09cb6 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -1040,7 +1040,7 @@ static __devinit int wm8960_i2c_probe(struct i2c_client *i2c, if (wm8960 == NULL) return -ENOMEM;
- wm8960->regmap = regmap_init_i2c(i2c, &wm8960_regmap); + wm8960->regmap = devm_regmap_init_i2c(i2c, &wm8960_regmap); if (IS_ERR(wm8960->regmap)) return PTR_ERR(wm8960->regmap);
On Mon, Nov 26, 2012 at 05:19:43PM +0530, Sachin Kamat wrote:
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler. There was no explicit regmap_exit call in this function which was probably a bug.
Applied, thanks.
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8962.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 285a9ef..8fd38cb 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -3624,7 +3624,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, return ret; }
- wm8962->regmap = regmap_init_i2c(i2c, &wm8962_regmap); + wm8962->regmap = devm_regmap_init_i2c(i2c, &wm8962_regmap); if (IS_ERR(wm8962->regmap)) { ret = PTR_ERR(wm8962->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); @@ -3641,20 +3641,20 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, ®); if (ret < 0) { dev_err(&i2c->dev, "Failed to read ID register\n"); - goto err_regmap; + goto err_enable; } if (reg != 0x6243) { dev_err(&i2c->dev, "Device is not a WM8962, ID %x != 0x6243\n", reg); ret = -EINVAL; - goto err_regmap; + goto err_enable; }
ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, ®); if (ret < 0) { dev_err(&i2c->dev, "Failed to read device revision: %d\n", ret); - goto err_regmap; + goto err_enable; }
dev_info(&i2c->dev, "customer id %x revision %c\n", @@ -3667,7 +3667,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, ret = wm8962_reset(wm8962); if (ret < 0) { dev_err(&i2c->dev, "Failed to issue reset\n"); - goto err_regmap; + goto err_enable; }
if (pdata && pdata->in4_dc_measure) { @@ -3686,15 +3686,13 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8962, &wm8962_dai, 1); if (ret < 0) - goto err_regmap; + goto err_enable;
/* The drivers should power up as needed */ regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
return 0;
-err_regmap: - regmap_exit(wm8962->regmap); err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); err: @@ -3703,10 +3701,7 @@ err:
static __devexit int wm8962_i2c_remove(struct i2c_client *client) { - struct wm8962_priv *wm8962 = dev_get_drvdata(&client->dev); - snd_soc_unregister_codec(&client->dev); - regmap_exit(wm8962->regmap); return 0; }
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8978.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index 8c1dac9..ef46700 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -1046,7 +1046,7 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c, if (wm8978 == NULL) return -ENOMEM;
- wm8978->regmap = regmap_init_i2c(i2c, &wm8978_regmap_config); + wm8978->regmap = devm_regmap_init_i2c(i2c, &wm8978_regmap_config); if (IS_ERR(wm8978->regmap)) { ret = PTR_ERR(wm8978->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); @@ -1059,29 +1059,22 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c, ret = regmap_write(wm8978->regmap, WM8978_RESET, 0); if (ret != 0) { dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); - goto err; + return ret; }
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8978, &wm8978_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); - goto err; + return ret; }
return 0; - -err: - regmap_exit(wm8978->regmap); - return ret; }
static __devexit int wm8978_i2c_remove(struct i2c_client *client) { - struct wm8978_priv *wm8978 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(wm8978->regmap);
return 0; }
On 2 December 2012 09:37, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Mon, Nov 26, 2012 at 05:19:45PM +0530, Sachin Kamat wrote:
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Applied, thanks.
Mark, Looks like this patch is missed out in your tree. Please let me know if you want me to re-send this.
On 6 December 2012 10:59, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Thu, Dec 06, 2012 at 10:13:22AM +0530, Sachin Kamat wrote:
Looks like this patch is missed out in your tree. Please let me know if you want me to re-send this.
I can see it in my tree
Yes, found it now. Thanks.
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm8993.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index c3d3107..347a359 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c @@ -1660,7 +1660,7 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c, wm8993->dev = &i2c->dev; init_completion(&wm8993->fll_lock);
- wm8993->regmap = regmap_init_i2c(i2c, &wm8993_regmap); + wm8993->regmap = devm_regmap_init_i2c(i2c, &wm8993_regmap); if (IS_ERR(wm8993->regmap)) { ret = PTR_ERR(wm8993->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); @@ -1676,14 +1676,14 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c, wm8993->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); - goto err; + return ret; }
ret = regulator_bulk_enable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); - goto err; + return ret; }
ret = regmap_read(wm8993->regmap, WM8993_SOFTWARE_RESET, ®); @@ -1742,8 +1742,6 @@ err_irq: free_irq(i2c->irq, wm8993); err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); -err: - regmap_exit(wm8993->regmap); return ret; }
@@ -1754,7 +1752,6 @@ static __devexit int wm8993_i2c_remove(struct i2c_client *i2c) snd_soc_unregister_codec(&i2c->dev); if (i2c->irq) free_irq(i2c->irq, wm8993); - regmap_exit(wm8993->regmap); regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies);
return 0;
devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler.
Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- sound/soc/codecs/wm9081.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 2de74e1..860144e 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -1341,28 +1341,27 @@ static __devinit int wm9081_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm9081);
- wm9081->regmap = regmap_init_i2c(i2c, &wm9081_regmap); + wm9081->regmap = devm_regmap_init_i2c(i2c, &wm9081_regmap); if (IS_ERR(wm9081->regmap)) { ret = PTR_ERR(wm9081->regmap); dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); - goto err; + return ret; }
ret = regmap_read(wm9081->regmap, WM9081_SOFTWARE_RESET, ®); if (ret != 0) { dev_err(&i2c->dev, "Failed to read chip ID: %d\n", ret); - goto err_regmap; + return ret; } if (reg != 0x9081) { dev_err(&i2c->dev, "Device is not a WM9081: ID=0x%x\n", reg); - ret = -EINVAL; - goto err_regmap; + return -EINVAL; }
ret = wm9081_reset(wm9081->regmap); if (ret < 0) { dev_err(&i2c->dev, "Failed to issue reset\n"); - goto err_regmap; + return ret; }
if (dev_get_platdata(&i2c->dev)) @@ -1382,23 +1381,14 @@ static __devinit int wm9081_i2c_probe(struct i2c_client *i2c, ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm9081, &wm9081_dai, 1); if (ret < 0) - goto err_regmap; + return ret;
return 0; - -err_regmap: - regmap_exit(wm9081->regmap); -err: - - return ret; }
static __devexit int wm9081_i2c_remove(struct i2c_client *client) { - struct wm9081_priv *wm9081 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(wm9081->regmap); return 0; }
participants (2)
-
Mark Brown
-
Sachin Kamat