Commit 0bb423f2 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mark Brown

ASoC: regulator notifier registration should be managed

Regulator notifiers, that were registered during codec driver probing,
must be unregistered during driver release, or device managed versions
have to be used. This patch fixes codec drivers, that weren't explicitly
unregistering notifiers and simplifies those, that did that manually.
Signed-off-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 51013553
...@@ -615,7 +615,8 @@ static int max9860_probe(struct i2c_client *i2c) ...@@ -615,7 +615,8 @@ static int max9860_probe(struct i2c_client *i2c)
max9860->dvddio_nb.notifier_call = max9860_dvddio_event; max9860->dvddio_nb.notifier_call = max9860_dvddio_event;
ret = regulator_register_notifier(max9860->dvddio, &max9860->dvddio_nb); ret = devm_regulator_register_notifier(max9860->dvddio,
&max9860->dvddio_nb);
if (ret) if (ret)
dev_err(dev, "Failed to register DVDDIO notifier: %d\n", ret); dev_err(dev, "Failed to register DVDDIO notifier: %d\n", ret);
......
...@@ -1540,7 +1540,8 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) ...@@ -1540,7 +1540,8 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)
pcm512x->supply_nb[2].notifier_call = pcm512x_regulator_event_2; pcm512x->supply_nb[2].notifier_call = pcm512x_regulator_event_2;
for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) { for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) {
ret = regulator_register_notifier(pcm512x->supplies[i].consumer, ret = devm_regulator_register_notifier(
pcm512x->supplies[i].consumer,
&pcm512x->supply_nb[i]); &pcm512x->supply_nb[i]);
if (ret != 0) { if (ret != 0) {
dev_err(dev, dev_err(dev,
......
...@@ -1274,7 +1274,8 @@ static int aic31xx_codec_probe(struct snd_soc_component *component) ...@@ -1274,7 +1274,8 @@ static int aic31xx_codec_probe(struct snd_soc_component *component)
aic31xx->disable_nb[i].nb.notifier_call = aic31xx->disable_nb[i].nb.notifier_call =
aic31xx_regulator_event; aic31xx_regulator_event;
aic31xx->disable_nb[i].aic31xx = aic31xx; aic31xx->disable_nb[i].aic31xx = aic31xx;
ret = regulator_register_notifier(aic31xx->supplies[i].consumer, ret = devm_regulator_register_notifier(
aic31xx->supplies[i].consumer,
&aic31xx->disable_nb[i].nb); &aic31xx->disable_nb[i].nb);
if (ret) { if (ret) {
dev_err(component->dev, dev_err(component->dev,
...@@ -1298,19 +1299,8 @@ static int aic31xx_codec_probe(struct snd_soc_component *component) ...@@ -1298,19 +1299,8 @@ static int aic31xx_codec_probe(struct snd_soc_component *component)
return 0; return 0;
} }
static void aic31xx_codec_remove(struct snd_soc_component *component)
{
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int i;
for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++)
regulator_unregister_notifier(aic31xx->supplies[i].consumer,
&aic31xx->disable_nb[i].nb);
}
static const struct snd_soc_component_driver soc_codec_driver_aic31xx = { static const struct snd_soc_component_driver soc_codec_driver_aic31xx = {
.probe = aic31xx_codec_probe, .probe = aic31xx_codec_probe,
.remove = aic31xx_codec_remove,
.set_bias_level = aic31xx_set_bias_level, .set_bias_level = aic31xx_set_bias_level,
.controls = common31xx_snd_controls, .controls = common31xx_snd_controls,
.num_controls = ARRAY_SIZE(common31xx_snd_controls), .num_controls = ARRAY_SIZE(common31xx_snd_controls),
......
...@@ -1615,13 +1615,14 @@ static int aic3x_probe(struct snd_soc_component *component) ...@@ -1615,13 +1615,14 @@ static int aic3x_probe(struct snd_soc_component *component)
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event;
aic3x->disable_nb[i].aic3x = aic3x; aic3x->disable_nb[i].aic3x = aic3x;
ret = regulator_register_notifier(aic3x->supplies[i].consumer, ret = devm_regulator_register_notifier(
aic3x->supplies[i].consumer,
&aic3x->disable_nb[i].nb); &aic3x->disable_nb[i].nb);
if (ret) { if (ret) {
dev_err(component->dev, dev_err(component->dev,
"Failed to request regulator notifier: %d\n", "Failed to request regulator notifier: %d\n",
ret); ret);
goto err_notif; return ret;
} }
} }
...@@ -1679,29 +1680,11 @@ static int aic3x_probe(struct snd_soc_component *component) ...@@ -1679,29 +1680,11 @@ static int aic3x_probe(struct snd_soc_component *component)
aic3x_add_widgets(component); aic3x_add_widgets(component);
return 0; return 0;
err_notif:
while (i--)
regulator_unregister_notifier(aic3x->supplies[i].consumer,
&aic3x->disable_nb[i].nb);
return ret;
}
static void aic3x_remove(struct snd_soc_component *component)
{
struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
int i;
list_del(&aic3x->list);
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
regulator_unregister_notifier(aic3x->supplies[i].consumer,
&aic3x->disable_nb[i].nb);
} }
static const struct snd_soc_component_driver soc_component_dev_aic3x = { static const struct snd_soc_component_driver soc_component_dev_aic3x = {
.set_bias_level = aic3x_set_bias_level, .set_bias_level = aic3x_set_bias_level,
.probe = aic3x_probe, .probe = aic3x_probe,
.remove = aic3x_remove,
.controls = aic3x_snd_controls, .controls = aic3x_snd_controls,
.num_controls = ARRAY_SIZE(aic3x_snd_controls), .num_controls = ARRAY_SIZE(aic3x_snd_controls),
.dapm_widgets = aic3x_dapm_widgets, .dapm_widgets = aic3x_dapm_widgets,
......
...@@ -666,7 +666,8 @@ static int wm8770_spi_probe(struct spi_device *spi) ...@@ -666,7 +666,8 @@ static int wm8770_spi_probe(struct spi_device *spi)
/* This should really be moved into the regulator core */ /* This should really be moved into the regulator core */
for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) { for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) {
ret = regulator_register_notifier(wm8770->supplies[i].consumer, ret = devm_regulator_register_notifier(
wm8770->supplies[i].consumer,
&wm8770->disable_nb[i]); &wm8770->disable_nb[i]);
if (ret) { if (ret) {
dev_err(&spi->dev, dev_err(&spi->dev,
...@@ -687,25 +688,12 @@ static int wm8770_spi_probe(struct spi_device *spi) ...@@ -687,25 +688,12 @@ static int wm8770_spi_probe(struct spi_device *spi)
return ret; return ret;
} }
static int wm8770_spi_remove(struct spi_device *spi)
{
struct wm8770_priv *wm8770 = spi_get_drvdata(spi);
int i;
for (i = 0; i < ARRAY_SIZE(wm8770->supplies); ++i)
regulator_unregister_notifier(wm8770->supplies[i].consumer,
&wm8770->disable_nb[i]);
return 0;
}
static struct spi_driver wm8770_spi_driver = { static struct spi_driver wm8770_spi_driver = {
.driver = { .driver = {
.name = "wm8770", .name = "wm8770",
.of_match_table = wm8770_of_match, .of_match_table = wm8770_of_match,
}, },
.probe = wm8770_spi_probe, .probe = wm8770_spi_probe,
.remove = wm8770_spi_remove
}; };
module_spi_driver(wm8770_spi_driver); module_spi_driver(wm8770_spi_driver);
......
...@@ -3424,7 +3424,8 @@ static int wm8962_probe(struct snd_soc_component *component) ...@@ -3424,7 +3424,8 @@ static int wm8962_probe(struct snd_soc_component *component)
/* This should really be moved into the regulator core */ /* This should really be moved into the regulator core */
for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) { for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) {
ret = regulator_register_notifier(wm8962->supplies[i].consumer, ret = devm_regulator_register_notifier(
wm8962->supplies[i].consumer,
&wm8962->disable_nb[i]); &wm8962->disable_nb[i]);
if (ret != 0) { if (ret != 0) {
dev_err(component->dev, dev_err(component->dev,
...@@ -3467,15 +3468,11 @@ static int wm8962_probe(struct snd_soc_component *component) ...@@ -3467,15 +3468,11 @@ static int wm8962_probe(struct snd_soc_component *component)
static void wm8962_remove(struct snd_soc_component *component) static void wm8962_remove(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int i;
cancel_delayed_work_sync(&wm8962->mic_work); cancel_delayed_work_sync(&wm8962->mic_work);
wm8962_free_gpio(component); wm8962_free_gpio(component);
wm8962_free_beep(component); wm8962_free_beep(component);
for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
regulator_unregister_notifier(wm8962->supplies[i].consumer,
&wm8962->disable_nb[i]);
} }
static const struct snd_soc_component_driver soc_component_dev_wm8962 = { static const struct snd_soc_component_driver soc_component_dev_wm8962 = {
......
...@@ -1995,20 +1995,6 @@ static int wm8995_set_bias_level(struct snd_soc_component *component, ...@@ -1995,20 +1995,6 @@ static int wm8995_set_bias_level(struct snd_soc_component *component,
return 0; return 0;
} }
static void wm8995_remove(struct snd_soc_component *component)
{
struct wm8995_priv *wm8995;
int i;
wm8995 = snd_soc_component_get_drvdata(component);
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); ++i)
regulator_unregister_notifier(wm8995->supplies[i].consumer,
&wm8995->disable_nb[i]);
regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
}
static int wm8995_probe(struct snd_soc_component *component) static int wm8995_probe(struct snd_soc_component *component)
{ {
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
...@@ -2021,7 +2007,8 @@ static int wm8995_probe(struct snd_soc_component *component) ...@@ -2021,7 +2007,8 @@ static int wm8995_probe(struct snd_soc_component *component)
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++)
wm8995->supplies[i].supply = wm8995_supply_names[i]; wm8995->supplies[i].supply = wm8995_supply_names[i];
ret = regulator_bulk_get(component->dev, ARRAY_SIZE(wm8995->supplies), ret = devm_regulator_bulk_get(component->dev,
ARRAY_SIZE(wm8995->supplies),
wm8995->supplies); wm8995->supplies);
if (ret) { if (ret) {
dev_err(component->dev, "Failed to request supplies: %d\n", ret); dev_err(component->dev, "Failed to request supplies: %d\n", ret);
...@@ -2039,7 +2026,8 @@ static int wm8995_probe(struct snd_soc_component *component) ...@@ -2039,7 +2026,8 @@ static int wm8995_probe(struct snd_soc_component *component)
/* This should really be moved into the regulator core */ /* This should really be moved into the regulator core */
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) { for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) {
ret = regulator_register_notifier(wm8995->supplies[i].consumer, ret = devm_regulator_register_notifier(
wm8995->supplies[i].consumer,
&wm8995->disable_nb[i]); &wm8995->disable_nb[i]);
if (ret) { if (ret) {
dev_err(component->dev, dev_err(component->dev,
...@@ -2052,7 +2040,7 @@ static int wm8995_probe(struct snd_soc_component *component) ...@@ -2052,7 +2040,7 @@ static int wm8995_probe(struct snd_soc_component *component)
wm8995->supplies); wm8995->supplies);
if (ret) { if (ret) {
dev_err(component->dev, "Failed to enable supplies: %d\n", ret); dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
goto err_reg_get; return ret;
} }
ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET); ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET);
...@@ -2099,8 +2087,6 @@ static int wm8995_probe(struct snd_soc_component *component) ...@@ -2099,8 +2087,6 @@ static int wm8995_probe(struct snd_soc_component *component)
err_reg_enable: err_reg_enable:
regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
err_reg_get:
regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
return ret; return ret;
} }
...@@ -2188,7 +2174,6 @@ static struct snd_soc_dai_driver wm8995_dai[] = { ...@@ -2188,7 +2174,6 @@ static struct snd_soc_dai_driver wm8995_dai[] = {
static const struct snd_soc_component_driver soc_component_dev_wm8995 = { static const struct snd_soc_component_driver soc_component_dev_wm8995 = {
.probe = wm8995_probe, .probe = wm8995_probe,
.remove = wm8995_remove,
.set_bias_level = wm8995_set_bias_level, .set_bias_level = wm8995_set_bias_level,
.controls = wm8995_snd_controls, .controls = wm8995_snd_controls,
.num_controls = ARRAY_SIZE(wm8995_snd_controls), .num_controls = ARRAY_SIZE(wm8995_snd_controls),
......
...@@ -2801,7 +2801,8 @@ static int wm8996_i2c_probe(struct i2c_client *i2c, ...@@ -2801,7 +2801,8 @@ static int wm8996_i2c_probe(struct i2c_client *i2c,
/* This should really be moved into the regulator core */ /* This should really be moved into the regulator core */
for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) { for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) {
ret = regulator_register_notifier(wm8996->supplies[i].consumer, ret = devm_regulator_register_notifier(
wm8996->supplies[i].consumer,
&wm8996->disable_nb[i]); &wm8996->disable_nb[i]);
if (ret != 0) { if (ret != 0) {
dev_err(&i2c->dev, dev_err(&i2c->dev,
...@@ -3071,16 +3072,12 @@ static int wm8996_i2c_probe(struct i2c_client *i2c, ...@@ -3071,16 +3072,12 @@ static int wm8996_i2c_probe(struct i2c_client *i2c,
static int wm8996_i2c_remove(struct i2c_client *client) static int wm8996_i2c_remove(struct i2c_client *client)
{ {
struct wm8996_priv *wm8996 = i2c_get_clientdata(client); struct wm8996_priv *wm8996 = i2c_get_clientdata(client);
int i;
wm8996_free_gpio(wm8996); wm8996_free_gpio(wm8996);
if (wm8996->pdata.ldo_ena > 0) { if (wm8996->pdata.ldo_ena > 0) {
gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
gpio_free(wm8996->pdata.ldo_ena); gpio_free(wm8996->pdata.ldo_ena);
} }
for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++)
regulator_unregister_notifier(wm8996->supplies[i].consumer,
&wm8996->disable_nb[i]);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment