Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: codecs: wcd938x: Simplify with devm_regulator_bulk_get_enable()

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-2-64d3cb60313b@linaro.org
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
a7ee107c 10cf8f6b

+9 -26
+9 -26
sound/soc/codecs/wcd938x.c
··· 26 26 #include "wcd938x.h" 27 27 28 28 #define WCD938X_MAX_MICBIAS (4) 29 - #define WCD938X_MAX_SUPPLY (4) 30 29 #define WCD938X_MBHC_MAX_BUTTONS (8) 31 30 #define TX_ADC_MAX (4) 32 31 ··· 160 161 struct irq_domain *virq; 161 162 struct regmap_irq_chip *wcd_regmap_irq_chip; 162 163 struct regmap_irq_chip_data *irq_chip; 163 - struct regulator_bulk_data supplies[WCD938X_MAX_SUPPLY]; 164 164 struct snd_soc_jack *jack; 165 165 unsigned long status_mask; 166 166 s32 micb_ref[WCD938X_MAX_MICBIAS]; ··· 184 186 bool comp2_enable; 185 187 bool ldoh; 186 188 bool mux_setup_done; 189 + }; 190 + 191 + static const char * const wcd938x_supplies[] = { 192 + "vdd-rxtx", "vdd-io", "vdd-buck", "vdd-mic-bias", 187 193 }; 188 194 189 195 static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800); ··· 3294 3292 3295 3293 cfg->swap_gnd_mic = wcd938x_swap_gnd_mic; 3296 3294 3297 - wcd938x->supplies[0].supply = "vdd-rxtx"; 3298 - wcd938x->supplies[1].supply = "vdd-io"; 3299 - wcd938x->supplies[2].supply = "vdd-buck"; 3300 - wcd938x->supplies[3].supply = "vdd-mic-bias"; 3301 - 3302 - ret = regulator_bulk_get(dev, WCD938X_MAX_SUPPLY, wcd938x->supplies); 3295 + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd938x_supplies), 3296 + wcd938x_supplies); 3303 3297 if (ret) 3304 - return dev_err_probe(dev, ret, "Failed to get supplies\n"); 3305 - 3306 - ret = regulator_bulk_enable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3307 - if (ret) { 3308 - regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3309 - return dev_err_probe(dev, ret, "Failed to enable supplies\n"); 3310 - } 3298 + return dev_err_probe(dev, ret, "Failed to get and enable supplies\n"); 3311 3299 3312 3300 wcd938x_dt_parse_micbias_info(dev, wcd938x); 3313 3301 ··· 3561 3569 3562 3570 ret = wcd938x_add_slave_components(wcd938x, dev, &match); 3563 3571 if (ret) 3564 - goto err_disable_regulators; 3572 + return ret; 3565 3573 3566 3574 wcd938x_reset(wcd938x); 3567 3575 3568 3576 ret = component_master_add_with_match(dev, &wcd938x_comp_ops, match); 3569 3577 if (ret) 3570 - goto err_disable_regulators; 3578 + return ret; 3571 3579 3572 3580 pm_runtime_set_autosuspend_delay(dev, 1000); 3573 3581 pm_runtime_use_autosuspend(dev); ··· 3577 3585 pm_runtime_idle(dev); 3578 3586 3579 3587 return 0; 3580 - 3581 - err_disable_regulators: 3582 - regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3583 - regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3584 - 3585 - return ret; 3586 3588 } 3587 3589 3588 3590 static void wcd938x_remove(struct platform_device *pdev) ··· 3592 3606 3593 3607 if (wcd938x->us_euro_mux && wcd938x->mux_setup_done) 3594 3608 mux_control_deselect(wcd938x->us_euro_mux); 3595 - 3596 - regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3597 - regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); 3598 3609 } 3599 3610 3600 3611 #if defined(CONFIG_OF)