]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: codecs: wcd937x: Simplify with devm_regulator_bulk_get_enable()
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Mon, 26 May 2025 10:49:50 +0000 (12:49 +0200)
committerMark Brown <broonie@kernel.org>
Sun, 8 Jun 2025 22:33:28 +0000 (23:33 +0100)
Drop separate regulator get and enable in probe() path with
devm_regulator_bulk_get_enable(), which simplifies cleanup paths and
device remove().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250526-b4-asoc-wcd9395-vdd-px-v1-1-64d3cb60313b@linaro.org
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wcd937x.c
sound/soc/codecs/wcd937x.h

index b9df58b86ce953427e01ffb8c7eb7e52f9c2392a..92765a8693fbf87e2ba53fef75657ffb1b5fdb8f 100644 (file)
@@ -90,7 +90,6 @@ struct wcd937x_priv {
        struct irq_domain *virq;
        struct regmap_irq_chip *wcd_regmap_irq_chip;
        struct regmap_irq_chip_data *irq_chip;
-       struct regulator_bulk_data supplies[WCD937X_MAX_BULK_SUPPLY];
        struct snd_soc_jack *jack;
        unsigned long status_mask;
        s32 micb_ref[WCD937X_MAX_MICBIAS];
@@ -113,6 +112,10 @@ struct wcd937x_priv {
        atomic_t ana_clk_count;
 };
 
+static const char * const wcd937x_supplies[] = {
+       "vdd-rxtx", "vdd-px", "vdd-mic-bias", "vdd-buck",
+};
+
 static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800);
 static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
 static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
@@ -2934,18 +2937,10 @@ static int wcd937x_probe(struct platform_device *pdev)
        cfg = &wcd937x->mbhc_cfg;
        cfg->swap_gnd_mic = wcd937x_swap_gnd_mic;
 
-       wcd937x->supplies[0].supply = "vdd-rxtx";
-       wcd937x->supplies[1].supply = "vdd-px";
-       wcd937x->supplies[2].supply = "vdd-mic-bias";
-       wcd937x->supplies[3].supply = "vdd-buck";
-
-       ret = devm_regulator_bulk_get(dev, WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
+       ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd937x_supplies),
+                                            wcd937x_supplies);
        if (ret)
-               return dev_err_probe(dev, ret, "Failed to get supplies\n");
-
-       ret = regulator_bulk_enable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
-       if (ret)
-               return dev_err_probe(dev, ret, "Failed to enable supplies\n");
+               return dev_err_probe(dev, ret, "Failed to get and enable supplies\n");
 
        wcd937x_dt_parse_micbias_info(dev, wcd937x);
 
@@ -2962,13 +2957,13 @@ static int wcd937x_probe(struct platform_device *pdev)
 
        ret = wcd937x_add_slave_components(wcd937x, dev, &match);
        if (ret)
-               goto err_disable_regulators;
+               return ret;
 
        wcd937x_reset(wcd937x);
 
        ret = component_master_add_with_match(dev, &wcd937x_comp_ops, match);
        if (ret)
-               goto err_disable_regulators;
+               return ret;
 
        pm_runtime_set_autosuspend_delay(dev, 1000);
        pm_runtime_use_autosuspend(dev);
@@ -2978,25 +2973,17 @@ static int wcd937x_probe(struct platform_device *pdev)
        pm_runtime_idle(dev);
 
        return 0;
-
-err_disable_regulators:
-       regulator_bulk_disable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
-
-       return ret;
 }
 
 static void wcd937x_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct wcd937x_priv *wcd937x = dev_get_drvdata(dev);
 
        component_master_del(&pdev->dev, &wcd937x_comp_ops);
 
        pm_runtime_disable(dev);
        pm_runtime_set_suspended(dev);
        pm_runtime_dont_use_autosuspend(dev);
-
-       regulator_bulk_disable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
 }
 
 #if defined(CONFIG_OF)
index 4ef57c496c37c555c8684d65249c53f6a8b645a1..3ab21bb5846e2c85520d67e7dc248d4e7715dba5 100644 (file)
 #define WCD937X_MAX_REGISTER                   (WCD937X_DIGITAL_EFUSE_REG_31)
 
 #define WCD937X_MAX_MICBIAS                    3
-#define WCD937X_MAX_BULK_SUPPLY                        4
 #define WCD937X_MAX_SWR_CH_IDS                 15
 #define WCD937X_SWRM_CH_MASK(ch_idx)           BIT(ch_idx - 1)