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: wcd939x: 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-3-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
cc50d176 a7ee107c

+10 -28
+10 -28
sound/soc/codecs/wcd939x.c
··· 32 32 #include "wcd939x.h" 33 33 34 34 #define WCD939X_MAX_MICBIAS (4) 35 - #define WCD939X_MAX_SUPPLY (4) 36 35 #define WCD939X_MBHC_MAX_BUTTONS (8) 37 36 #define TX_ADC_MAX (4) 38 37 #define WCD_MBHC_HS_V_MAX 1600 ··· 191 192 struct irq_domain *virq; 192 193 struct regmap_irq_chip *wcd_regmap_irq_chip; 193 194 struct regmap_irq_chip_data *irq_chip; 194 - struct regulator_bulk_data supplies[WCD939X_MAX_SUPPLY]; 195 195 struct snd_soc_jack *jack; 196 196 unsigned long status_mask; 197 197 s32 micb_ref[WCD939X_MAX_MICBIAS]; ··· 209 211 bool comp1_enable; 210 212 bool comp2_enable; 211 213 bool ldoh; 214 + }; 215 + 216 + static const char * const wcd939x_supplies[] = { 217 + "vdd-rxtx", "vdd-io", "vdd-buck", "vdd-mic-bias", 212 218 }; 213 219 214 220 static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800); ··· 3246 3244 return dev_err_probe(dev, ret, "Failed to get reset gpio\n"); 3247 3245 } 3248 3246 3249 - wcd939x->supplies[0].supply = "vdd-rxtx"; 3250 - wcd939x->supplies[1].supply = "vdd-io"; 3251 - wcd939x->supplies[2].supply = "vdd-buck"; 3252 - wcd939x->supplies[3].supply = "vdd-mic-bias"; 3253 - 3254 - ret = regulator_bulk_get(dev, WCD939X_MAX_SUPPLY, wcd939x->supplies); 3247 + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(wcd939x_supplies), 3248 + wcd939x_supplies); 3255 3249 if (ret) 3256 - return dev_err_probe(dev, ret, "Failed to get supplies\n"); 3257 - 3258 - ret = regulator_bulk_enable(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3259 - if (ret) { 3260 - regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3261 - return dev_err_probe(dev, ret, "Failed to enable supplies\n"); 3262 - } 3250 + return dev_err_probe(dev, ret, "Failed to get and enable supplies\n"); 3263 3251 3264 3252 wcd939x_dt_parse_micbias_info(dev, wcd939x); 3265 3253 ··· 3621 3629 3622 3630 ret = wcd939x_add_typec(wcd939x, dev); 3623 3631 if (ret) 3624 - goto err_disable_regulators; 3632 + return ret; 3625 3633 3626 3634 ret = wcd939x_add_slave_components(wcd939x, dev, &match); 3627 3635 if (ret) 3628 - goto err_disable_regulators; 3636 + return ret; 3629 3637 3630 3638 wcd939x_reset(wcd939x); 3631 3639 3632 3640 ret = component_master_add_with_match(dev, &wcd939x_comp_ops, match); 3633 3641 if (ret) 3634 - goto err_disable_regulators; 3642 + return ret; 3635 3643 3636 3644 pm_runtime_set_autosuspend_delay(dev, 1000); 3637 3645 pm_runtime_use_autosuspend(dev); ··· 3641 3649 pm_runtime_idle(dev); 3642 3650 3643 3651 return 0; 3644 - 3645 - err_disable_regulators: 3646 - regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3647 - regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3648 - 3649 - return ret; 3650 3652 } 3651 3653 3652 3654 static void wcd939x_remove(struct platform_device *pdev) 3653 3655 { 3654 3656 struct device *dev = &pdev->dev; 3655 - struct wcd939x_priv *wcd939x = dev_get_drvdata(dev); 3656 3657 3657 3658 component_master_del(dev, &wcd939x_comp_ops); 3658 3659 3659 3660 pm_runtime_disable(dev); 3660 3661 pm_runtime_set_suspended(dev); 3661 3662 pm_runtime_dont_use_autosuspend(dev); 3662 - 3663 - regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3664 - regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); 3665 3663 } 3666 3664 3667 3665 #if defined(CONFIG_OF)