forked from Minki/linux
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: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
5101355353
commit
0bb423f2ea
@ -615,7 +615,8 @@ static int max9860_probe(struct i2c_client *i2c)
|
||||
|
||||
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)
|
||||
dev_err(dev, "Failed to register DVDDIO notifier: %d\n", ret);
|
||||
|
||||
|
@ -1540,8 +1540,9 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)
|
||||
pcm512x->supply_nb[2].notifier_call = pcm512x_regulator_event_2;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) {
|
||||
ret = regulator_register_notifier(pcm512x->supplies[i].consumer,
|
||||
&pcm512x->supply_nb[i]);
|
||||
ret = devm_regulator_register_notifier(
|
||||
pcm512x->supplies[i].consumer,
|
||||
&pcm512x->supply_nb[i]);
|
||||
if (ret != 0) {
|
||||
dev_err(dev,
|
||||
"Failed to register regulator notifier: %d\n",
|
||||
|
@ -1274,8 +1274,9 @@ static int aic31xx_codec_probe(struct snd_soc_component *component)
|
||||
aic31xx->disable_nb[i].nb.notifier_call =
|
||||
aic31xx_regulator_event;
|
||||
aic31xx->disable_nb[i].aic31xx = aic31xx;
|
||||
ret = regulator_register_notifier(aic31xx->supplies[i].consumer,
|
||||
&aic31xx->disable_nb[i].nb);
|
||||
ret = devm_regulator_register_notifier(
|
||||
aic31xx->supplies[i].consumer,
|
||||
&aic31xx->disable_nb[i].nb);
|
||||
if (ret) {
|
||||
dev_err(component->dev,
|
||||
"Failed to request regulator notifier: %d\n",
|
||||
@ -1298,19 +1299,8 @@ static int aic31xx_codec_probe(struct snd_soc_component *component)
|
||||
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 = {
|
||||
.probe = aic31xx_codec_probe,
|
||||
.remove = aic31xx_codec_remove,
|
||||
.set_bias_level = aic31xx_set_bias_level,
|
||||
.controls = common31xx_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(common31xx_snd_controls),
|
||||
|
@ -1615,13 +1615,14 @@ static int aic3x_probe(struct snd_soc_component *component)
|
||||
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
|
||||
aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event;
|
||||
aic3x->disable_nb[i].aic3x = aic3x;
|
||||
ret = regulator_register_notifier(aic3x->supplies[i].consumer,
|
||||
&aic3x->disable_nb[i].nb);
|
||||
ret = devm_regulator_register_notifier(
|
||||
aic3x->supplies[i].consumer,
|
||||
&aic3x->disable_nb[i].nb);
|
||||
if (ret) {
|
||||
dev_err(component->dev,
|
||||
"Failed to request regulator notifier: %d\n",
|
||||
ret);
|
||||
goto err_notif;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1679,29 +1680,11 @@ static int aic3x_probe(struct snd_soc_component *component)
|
||||
aic3x_add_widgets(component);
|
||||
|
||||
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 = {
|
||||
.set_bias_level = aic3x_set_bias_level,
|
||||
.probe = aic3x_probe,
|
||||
.remove = aic3x_remove,
|
||||
.controls = aic3x_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(aic3x_snd_controls),
|
||||
.dapm_widgets = aic3x_dapm_widgets,
|
||||
|
@ -666,8 +666,9 @@ static int wm8770_spi_probe(struct spi_device *spi)
|
||||
|
||||
/* This should really be moved into the regulator core */
|
||||
for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) {
|
||||
ret = regulator_register_notifier(wm8770->supplies[i].consumer,
|
||||
&wm8770->disable_nb[i]);
|
||||
ret = devm_regulator_register_notifier(
|
||||
wm8770->supplies[i].consumer,
|
||||
&wm8770->disable_nb[i]);
|
||||
if (ret) {
|
||||
dev_err(&spi->dev,
|
||||
"Failed to register regulator notifier: %d\n",
|
||||
@ -687,25 +688,12 @@ static int wm8770_spi_probe(struct spi_device *spi)
|
||||
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 = {
|
||||
.driver = {
|
||||
.name = "wm8770",
|
||||
.of_match_table = wm8770_of_match,
|
||||
},
|
||||
.probe = wm8770_spi_probe,
|
||||
.remove = wm8770_spi_remove
|
||||
};
|
||||
|
||||
module_spi_driver(wm8770_spi_driver);
|
||||
|
@ -3424,8 +3424,9 @@ static int wm8962_probe(struct snd_soc_component *component)
|
||||
|
||||
/* This should really be moved into the regulator core */
|
||||
for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) {
|
||||
ret = regulator_register_notifier(wm8962->supplies[i].consumer,
|
||||
&wm8962->disable_nb[i]);
|
||||
ret = devm_regulator_register_notifier(
|
||||
wm8962->supplies[i].consumer,
|
||||
&wm8962->disable_nb[i]);
|
||||
if (ret != 0) {
|
||||
dev_err(component->dev,
|
||||
"Failed to register regulator notifier: %d\n",
|
||||
@ -3467,15 +3468,11 @@ static int wm8962_probe(struct snd_soc_component *component)
|
||||
static void wm8962_remove(struct snd_soc_component *component)
|
||||
{
|
||||
struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
|
||||
int i;
|
||||
|
||||
cancel_delayed_work_sync(&wm8962->mic_work);
|
||||
|
||||
wm8962_free_gpio(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 = {
|
||||
|
@ -1995,20 +1995,6 @@ static int wm8995_set_bias_level(struct snd_soc_component *component,
|
||||
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)
|
||||
{
|
||||
struct wm8995_priv *wm8995;
|
||||
@ -2021,8 +2007,9 @@ static int wm8995_probe(struct snd_soc_component *component)
|
||||
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++)
|
||||
wm8995->supplies[i].supply = wm8995_supply_names[i];
|
||||
|
||||
ret = regulator_bulk_get(component->dev, ARRAY_SIZE(wm8995->supplies),
|
||||
wm8995->supplies);
|
||||
ret = devm_regulator_bulk_get(component->dev,
|
||||
ARRAY_SIZE(wm8995->supplies),
|
||||
wm8995->supplies);
|
||||
if (ret) {
|
||||
dev_err(component->dev, "Failed to request supplies: %d\n", ret);
|
||||
return ret;
|
||||
@ -2039,8 +2026,9 @@ static int wm8995_probe(struct snd_soc_component *component)
|
||||
|
||||
/* This should really be moved into the regulator core */
|
||||
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) {
|
||||
ret = regulator_register_notifier(wm8995->supplies[i].consumer,
|
||||
&wm8995->disable_nb[i]);
|
||||
ret = devm_regulator_register_notifier(
|
||||
wm8995->supplies[i].consumer,
|
||||
&wm8995->disable_nb[i]);
|
||||
if (ret) {
|
||||
dev_err(component->dev,
|
||||
"Failed to register regulator notifier: %d\n",
|
||||
@ -2052,7 +2040,7 @@ static int wm8995_probe(struct snd_soc_component *component)
|
||||
wm8995->supplies);
|
||||
if (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);
|
||||
@ -2099,8 +2087,6 @@ static int wm8995_probe(struct snd_soc_component *component)
|
||||
|
||||
err_reg_enable:
|
||||
regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
|
||||
err_reg_get:
|
||||
regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2188,7 +2174,6 @@ static struct snd_soc_dai_driver wm8995_dai[] = {
|
||||
|
||||
static const struct snd_soc_component_driver soc_component_dev_wm8995 = {
|
||||
.probe = wm8995_probe,
|
||||
.remove = wm8995_remove,
|
||||
.set_bias_level = wm8995_set_bias_level,
|
||||
.controls = wm8995_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(wm8995_snd_controls),
|
||||
|
@ -2801,8 +2801,9 @@ static int wm8996_i2c_probe(struct i2c_client *i2c,
|
||||
|
||||
/* This should really be moved into the regulator core */
|
||||
for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) {
|
||||
ret = regulator_register_notifier(wm8996->supplies[i].consumer,
|
||||
&wm8996->disable_nb[i]);
|
||||
ret = devm_regulator_register_notifier(
|
||||
wm8996->supplies[i].consumer,
|
||||
&wm8996->disable_nb[i]);
|
||||
if (ret != 0) {
|
||||
dev_err(&i2c->dev,
|
||||
"Failed to register regulator notifier: %d\n",
|
||||
@ -3071,16 +3072,12 @@ err:
|
||||
static int wm8996_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
struct wm8996_priv *wm8996 = i2c_get_clientdata(client);
|
||||
int i;
|
||||
|
||||
wm8996_free_gpio(wm8996);
|
||||
if (wm8996->pdata.ldo_ena > 0) {
|
||||
gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user