]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ASoC: regulator notifier registration should be managed
authorGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Fri, 8 Feb 2019 13:45:20 +0000 (14:45 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 8 Feb 2019 16:18:49 +0000 (16:18 +0000)
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>
sound/soc/codecs/max9860.c
sound/soc/codecs/pcm512x.c
sound/soc/codecs/tlv320aic31xx.c
sound/soc/codecs/tlv320aic3x.c
sound/soc/codecs/wm8770.c
sound/soc/codecs/wm8962.c
sound/soc/codecs/wm8995.c
sound/soc/codecs/wm8996.c

index de3d44e9199b03c3c2afa5a46aedcdc0c505c329..8be636fe6552063d0a59cad9e215bf377eec686a 100644 (file)
@@ -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);
 
index ae3bd533eadb5ac69d6373f0f4e9e779b46a5294..62d05b01711f121fccfec68e59f7b2e3415bc49e 100644 (file)
@@ -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",
index c6048d95c6d35187d0d974ae9325cf4c00bc5378..c544a1e35f5e03199f71c65bb29539980b800289 100644 (file)
@@ -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),
index 6aa0edf8c5ef92115da50adc8b775235fa60d7ec..283583d1db60555f0831229be3b2f0e1a65bafee 100644 (file)
@@ -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,
index 806245c70f8beb551af92f4ad556d4bb5da929d1..37467c512597740ed95a1395cedf05a23342e28a 100644 (file)
@@ -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);
index efd8910b1ff77ad6f6b074448b43a77ef8123a7e..467ed78dd2df4ebf97f0d0324a631561213ba924 100644 (file)
@@ -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 = {
index 68c99fe3709741cf106b6231068056d309a81e67..79ee91906bb937a057763a98332de46e4342120d 100644 (file)
@@ -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),
index 91711f8958c56245eef728b8fd8309a7370bc44a..ab04ea18c31276a23f112b13e8c3ce7f0417d160 100644 (file)
@@ -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;
 }