summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>2019-02-08 08:45:20 -0500
committerMark Brown <broonie@kernel.org>2019-02-08 11:18:49 -0500
commit0bb423f2eaafedf89715c482a543dcd629ba3946 (patch)
tree87a45e601cda565f0c66fb46012c9409f7fc16a9
parent510135535382db7f5ee8727818172e42c9c9cbd5 (diff)
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>
-rw-r--r--sound/soc/codecs/max9860.c3
-rw-r--r--sound/soc/codecs/pcm512x.c5
-rw-r--r--sound/soc/codecs/tlv320aic31xx.c16
-rw-r--r--sound/soc/codecs/tlv320aic3x.c25
-rw-r--r--sound/soc/codecs/wm8770.c18
-rw-r--r--sound/soc/codecs/wm8962.c9
-rw-r--r--sound/soc/codecs/wm8995.c29
-rw-r--r--sound/soc/codecs/wm8996.c9
8 files changed, 28 insertions, 86 deletions
diff --git a/sound/soc/codecs/max9860.c b/sound/soc/codecs/max9860.c
index de3d44e9199b..8be636fe6552 100644
--- a/sound/soc/codecs/max9860.c
+++ b/sound/soc/codecs/max9860.c
@@ -615,7 +615,8 @@ static int max9860_probe(struct i2c_client *i2c)
615 615
616 max9860->dvddio_nb.notifier_call = max9860_dvddio_event; 616 max9860->dvddio_nb.notifier_call = max9860_dvddio_event;
617 617
618 ret = regulator_register_notifier(max9860->dvddio, &max9860->dvddio_nb); 618 ret = devm_regulator_register_notifier(max9860->dvddio,
619 &max9860->dvddio_nb);
619 if (ret) 620 if (ret)
620 dev_err(dev, "Failed to register DVDDIO notifier: %d\n", ret); 621 dev_err(dev, "Failed to register DVDDIO notifier: %d\n", ret);
621 622
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index ae3bd533eadb..62d05b01711f 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1540,8 +1540,9 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)
1540 pcm512x->supply_nb[2].notifier_call = pcm512x_regulator_event_2; 1540 pcm512x->supply_nb[2].notifier_call = pcm512x_regulator_event_2;
1541 1541
1542 for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) { 1542 for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) {
1543 ret = regulator_register_notifier(pcm512x->supplies[i].consumer, 1543 ret = devm_regulator_register_notifier(
1544 &pcm512x->supply_nb[i]); 1544 pcm512x->supplies[i].consumer,
1545 &pcm512x->supply_nb[i]);
1545 if (ret != 0) { 1546 if (ret != 0) {
1546 dev_err(dev, 1547 dev_err(dev,
1547 "Failed to register regulator notifier: %d\n", 1548 "Failed to register regulator notifier: %d\n",
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index c6048d95c6d3..c544a1e35f5e 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -1274,8 +1274,9 @@ static int aic31xx_codec_probe(struct snd_soc_component *component)
1274 aic31xx->disable_nb[i].nb.notifier_call = 1274 aic31xx->disable_nb[i].nb.notifier_call =
1275 aic31xx_regulator_event; 1275 aic31xx_regulator_event;
1276 aic31xx->disable_nb[i].aic31xx = aic31xx; 1276 aic31xx->disable_nb[i].aic31xx = aic31xx;
1277 ret = regulator_register_notifier(aic31xx->supplies[i].consumer, 1277 ret = devm_regulator_register_notifier(
1278 &aic31xx->disable_nb[i].nb); 1278 aic31xx->supplies[i].consumer,
1279 &aic31xx->disable_nb[i].nb);
1279 if (ret) { 1280 if (ret) {
1280 dev_err(component->dev, 1281 dev_err(component->dev,
1281 "Failed to request regulator notifier: %d\n", 1282 "Failed to request regulator notifier: %d\n",
@@ -1298,19 +1299,8 @@ static int aic31xx_codec_probe(struct snd_soc_component *component)
1298 return 0; 1299 return 0;
1299} 1300}
1300 1301
1301static void aic31xx_codec_remove(struct snd_soc_component *component)
1302{
1303 struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
1304 int i;
1305
1306 for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++)
1307 regulator_unregister_notifier(aic31xx->supplies[i].consumer,
1308 &aic31xx->disable_nb[i].nb);
1309}
1310
1311static const struct snd_soc_component_driver soc_codec_driver_aic31xx = { 1302static const struct snd_soc_component_driver soc_codec_driver_aic31xx = {
1312 .probe = aic31xx_codec_probe, 1303 .probe = aic31xx_codec_probe,
1313 .remove = aic31xx_codec_remove,
1314 .set_bias_level = aic31xx_set_bias_level, 1304 .set_bias_level = aic31xx_set_bias_level,
1315 .controls = common31xx_snd_controls, 1305 .controls = common31xx_snd_controls,
1316 .num_controls = ARRAY_SIZE(common31xx_snd_controls), 1306 .num_controls = ARRAY_SIZE(common31xx_snd_controls),
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 6aa0edf8c5ef..283583d1db60 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1615,13 +1615,14 @@ static int aic3x_probe(struct snd_soc_component *component)
1615 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { 1615 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) {
1616 aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; 1616 aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event;
1617 aic3x->disable_nb[i].aic3x = aic3x; 1617 aic3x->disable_nb[i].aic3x = aic3x;
1618 ret = regulator_register_notifier(aic3x->supplies[i].consumer, 1618 ret = devm_regulator_register_notifier(
1619 &aic3x->disable_nb[i].nb); 1619 aic3x->supplies[i].consumer,
1620 &aic3x->disable_nb[i].nb);
1620 if (ret) { 1621 if (ret) {
1621 dev_err(component->dev, 1622 dev_err(component->dev,
1622 "Failed to request regulator notifier: %d\n", 1623 "Failed to request regulator notifier: %d\n",
1623 ret); 1624 ret);
1624 goto err_notif; 1625 return ret;
1625 } 1626 }
1626 } 1627 }
1627 1628
@@ -1679,29 +1680,11 @@ static int aic3x_probe(struct snd_soc_component *component)
1679 aic3x_add_widgets(component); 1680 aic3x_add_widgets(component);
1680 1681
1681 return 0; 1682 return 0;
1682
1683err_notif:
1684 while (i--)
1685 regulator_unregister_notifier(aic3x->supplies[i].consumer,
1686 &aic3x->disable_nb[i].nb);
1687 return ret;
1688}
1689
1690static void aic3x_remove(struct snd_soc_component *component)
1691{
1692 struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
1693 int i;
1694
1695 list_del(&aic3x->list);
1696 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
1697 regulator_unregister_notifier(aic3x->supplies[i].consumer,
1698 &aic3x->disable_nb[i].nb);
1699} 1683}
1700 1684
1701static const struct snd_soc_component_driver soc_component_dev_aic3x = { 1685static const struct snd_soc_component_driver soc_component_dev_aic3x = {
1702 .set_bias_level = aic3x_set_bias_level, 1686 .set_bias_level = aic3x_set_bias_level,
1703 .probe = aic3x_probe, 1687 .probe = aic3x_probe,
1704 .remove = aic3x_remove,
1705 .controls = aic3x_snd_controls, 1688 .controls = aic3x_snd_controls,
1706 .num_controls = ARRAY_SIZE(aic3x_snd_controls), 1689 .num_controls = ARRAY_SIZE(aic3x_snd_controls),
1707 .dapm_widgets = aic3x_dapm_widgets, 1690 .dapm_widgets = aic3x_dapm_widgets,
diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c
index 806245c70f8b..37467c512597 100644
--- a/sound/soc/codecs/wm8770.c
+++ b/sound/soc/codecs/wm8770.c
@@ -666,8 +666,9 @@ static int wm8770_spi_probe(struct spi_device *spi)
666 666
667 /* This should really be moved into the regulator core */ 667 /* This should really be moved into the regulator core */
668 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) { 668 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) {
669 ret = regulator_register_notifier(wm8770->supplies[i].consumer, 669 ret = devm_regulator_register_notifier(
670 &wm8770->disable_nb[i]); 670 wm8770->supplies[i].consumer,
671 &wm8770->disable_nb[i]);
671 if (ret) { 672 if (ret) {
672 dev_err(&spi->dev, 673 dev_err(&spi->dev,
673 "Failed to register regulator notifier: %d\n", 674 "Failed to register regulator notifier: %d\n",
@@ -687,25 +688,12 @@ static int wm8770_spi_probe(struct spi_device *spi)
687 return ret; 688 return ret;
688} 689}
689 690
690static int wm8770_spi_remove(struct spi_device *spi)
691{
692 struct wm8770_priv *wm8770 = spi_get_drvdata(spi);
693 int i;
694
695 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); ++i)
696 regulator_unregister_notifier(wm8770->supplies[i].consumer,
697 &wm8770->disable_nb[i]);
698
699 return 0;
700}
701
702static struct spi_driver wm8770_spi_driver = { 691static struct spi_driver wm8770_spi_driver = {
703 .driver = { 692 .driver = {
704 .name = "wm8770", 693 .name = "wm8770",
705 .of_match_table = wm8770_of_match, 694 .of_match_table = wm8770_of_match,
706 }, 695 },
707 .probe = wm8770_spi_probe, 696 .probe = wm8770_spi_probe,
708 .remove = wm8770_spi_remove
709}; 697};
710 698
711module_spi_driver(wm8770_spi_driver); 699module_spi_driver(wm8770_spi_driver);
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index efd8910b1ff7..467ed78dd2df 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3424,8 +3424,9 @@ static int wm8962_probe(struct snd_soc_component *component)
3424 3424
3425 /* This should really be moved into the regulator core */ 3425 /* This should really be moved into the regulator core */
3426 for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) { 3426 for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) {
3427 ret = regulator_register_notifier(wm8962->supplies[i].consumer, 3427 ret = devm_regulator_register_notifier(
3428 &wm8962->disable_nb[i]); 3428 wm8962->supplies[i].consumer,
3429 &wm8962->disable_nb[i]);
3429 if (ret != 0) { 3430 if (ret != 0) {
3430 dev_err(component->dev, 3431 dev_err(component->dev,
3431 "Failed to register regulator notifier: %d\n", 3432 "Failed to register regulator notifier: %d\n",
@@ -3467,15 +3468,11 @@ static int wm8962_probe(struct snd_soc_component *component)
3467static void wm8962_remove(struct snd_soc_component *component) 3468static void wm8962_remove(struct snd_soc_component *component)
3468{ 3469{
3469 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); 3470 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
3470 int i;
3471 3471
3472 cancel_delayed_work_sync(&wm8962->mic_work); 3472 cancel_delayed_work_sync(&wm8962->mic_work);
3473 3473
3474 wm8962_free_gpio(component); 3474 wm8962_free_gpio(component);
3475 wm8962_free_beep(component); 3475 wm8962_free_beep(component);
3476 for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
3477 regulator_unregister_notifier(wm8962->supplies[i].consumer,
3478 &wm8962->disable_nb[i]);
3479} 3476}
3480 3477
3481static const struct snd_soc_component_driver soc_component_dev_wm8962 = { 3478static const struct snd_soc_component_driver soc_component_dev_wm8962 = {
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c
index 68c99fe37097..79ee91906bb9 100644
--- a/sound/soc/codecs/wm8995.c
+++ b/sound/soc/codecs/wm8995.c
@@ -1995,20 +1995,6 @@ static int wm8995_set_bias_level(struct snd_soc_component *component,
1995 return 0; 1995 return 0;
1996} 1996}
1997 1997
1998static void wm8995_remove(struct snd_soc_component *component)
1999{
2000 struct wm8995_priv *wm8995;
2001 int i;
2002
2003 wm8995 = snd_soc_component_get_drvdata(component);
2004
2005 for (i = 0; i < ARRAY_SIZE(wm8995->supplies); ++i)
2006 regulator_unregister_notifier(wm8995->supplies[i].consumer,
2007 &wm8995->disable_nb[i]);
2008
2009 regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
2010}
2011
2012static int wm8995_probe(struct snd_soc_component *component) 1998static int wm8995_probe(struct snd_soc_component *component)
2013{ 1999{
2014 struct wm8995_priv *wm8995; 2000 struct wm8995_priv *wm8995;
@@ -2021,8 +2007,9 @@ static int wm8995_probe(struct snd_soc_component *component)
2021 for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) 2007 for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++)
2022 wm8995->supplies[i].supply = wm8995_supply_names[i]; 2008 wm8995->supplies[i].supply = wm8995_supply_names[i];
2023 2009
2024 ret = regulator_bulk_get(component->dev, ARRAY_SIZE(wm8995->supplies), 2010 ret = devm_regulator_bulk_get(component->dev,
2025 wm8995->supplies); 2011 ARRAY_SIZE(wm8995->supplies),
2012 wm8995->supplies);
2026 if (ret) { 2013 if (ret) {
2027 dev_err(component->dev, "Failed to request supplies: %d\n", ret); 2014 dev_err(component->dev, "Failed to request supplies: %d\n", ret);
2028 return ret; 2015 return ret;
@@ -2039,8 +2026,9 @@ static int wm8995_probe(struct snd_soc_component *component)
2039 2026
2040 /* This should really be moved into the regulator core */ 2027 /* This should really be moved into the regulator core */
2041 for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) { 2028 for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) {
2042 ret = regulator_register_notifier(wm8995->supplies[i].consumer, 2029 ret = devm_regulator_register_notifier(
2043 &wm8995->disable_nb[i]); 2030 wm8995->supplies[i].consumer,
2031 &wm8995->disable_nb[i]);
2044 if (ret) { 2032 if (ret) {
2045 dev_err(component->dev, 2033 dev_err(component->dev,
2046 "Failed to register regulator notifier: %d\n", 2034 "Failed to register regulator notifier: %d\n",
@@ -2052,7 +2040,7 @@ static int wm8995_probe(struct snd_soc_component *component)
2052 wm8995->supplies); 2040 wm8995->supplies);
2053 if (ret) { 2041 if (ret) {
2054 dev_err(component->dev, "Failed to enable supplies: %d\n", ret); 2042 dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
2055 goto err_reg_get; 2043 return ret;
2056 } 2044 }
2057 2045
2058 ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET); 2046 ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET);
@@ -2099,8 +2087,6 @@ static int wm8995_probe(struct snd_soc_component *component)
2099 2087
2100err_reg_enable: 2088err_reg_enable:
2101 regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); 2089 regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
2102err_reg_get:
2103 regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
2104 return ret; 2090 return ret;
2105} 2091}
2106 2092
@@ -2188,7 +2174,6 @@ static struct snd_soc_dai_driver wm8995_dai[] = {
2188 2174
2189static const struct snd_soc_component_driver soc_component_dev_wm8995 = { 2175static const struct snd_soc_component_driver soc_component_dev_wm8995 = {
2190 .probe = wm8995_probe, 2176 .probe = wm8995_probe,
2191 .remove = wm8995_remove,
2192 .set_bias_level = wm8995_set_bias_level, 2177 .set_bias_level = wm8995_set_bias_level,
2193 .controls = wm8995_snd_controls, 2178 .controls = wm8995_snd_controls,
2194 .num_controls = ARRAY_SIZE(wm8995_snd_controls), 2179 .num_controls = ARRAY_SIZE(wm8995_snd_controls),
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index 91711f8958c5..ab04ea18c312 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -2801,8 +2801,9 @@ static int wm8996_i2c_probe(struct i2c_client *i2c,
2801 2801
2802 /* This should really be moved into the regulator core */ 2802 /* This should really be moved into the regulator core */
2803 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) { 2803 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) {
2804 ret = regulator_register_notifier(wm8996->supplies[i].consumer, 2804 ret = devm_regulator_register_notifier(
2805 &wm8996->disable_nb[i]); 2805 wm8996->supplies[i].consumer,
2806 &wm8996->disable_nb[i]);
2806 if (ret != 0) { 2807 if (ret != 0) {
2807 dev_err(&i2c->dev, 2808 dev_err(&i2c->dev,
2808 "Failed to register regulator notifier: %d\n", 2809 "Failed to register regulator notifier: %d\n",
@@ -3071,16 +3072,12 @@ err:
3071static int wm8996_i2c_remove(struct i2c_client *client) 3072static int wm8996_i2c_remove(struct i2c_client *client)
3072{ 3073{
3073 struct wm8996_priv *wm8996 = i2c_get_clientdata(client); 3074 struct wm8996_priv *wm8996 = i2c_get_clientdata(client);
3074 int i;
3075 3075
3076 wm8996_free_gpio(wm8996); 3076 wm8996_free_gpio(wm8996);
3077 if (wm8996->pdata.ldo_ena > 0) { 3077 if (wm8996->pdata.ldo_ena > 0) {
3078 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); 3078 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
3079 gpio_free(wm8996->pdata.ldo_ena); 3079 gpio_free(wm8996->pdata.ldo_ena);
3080 } 3080 }
3081 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++)
3082 regulator_unregister_notifier(wm8996->supplies[i].consumer,
3083 &wm8996->disable_nb[i]);
3084 3081
3085 return 0; 3082 return 0;
3086} 3083}