Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81793fee authored by Meng Wang's avatar Meng Wang Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: codecs: skip enabling codec power supplies when not defined



When codec power supplies are from external/battery source and enabled
by default, there's no need to enable these power supplies in probe
functions. When the codec power supplies is not defined in device tree,
avoid inititialzing, enabling and disabling it.

Change-Id: Iebb08cca163c966ae8cbe2d20db174fc5ddf03f1
Signed-off-by: default avatarMeng Wang <mengw@codeaurora.org>
parent 1eaaa37d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -387,7 +387,7 @@ int msm_cdc_get_power_supplies(struct device *dev,
	static_sup_cnt = of_property_count_strings(dev->of_node,
						   static_prop_name);
	if (static_sup_cnt < 0) {
		dev_err(dev, "%s: Failed to get static supplies(%d)\n",
		dev_info(dev, "%s: Failed to get static supplies(%d)\n",
			__func__, static_sup_cnt);
		rc = static_sup_cnt;
		goto err_supply_cnt;
+67 −58
Original line number Diff line number Diff line
@@ -1073,7 +1073,9 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client,
			msm_cdc_pinctrl_select_active_state(pdata->buck_vsel_ctl_np);

		wcd9xxx->num_of_supplies = pdata->num_supplies;
		ret = msm_cdc_init_supplies(wcd9xxx->dev, &wcd9xxx->supplies,
		if (pdata->regulator && pdata->num_supplies > 0) {
			ret = msm_cdc_init_supplies(wcd9xxx->dev,
						    &wcd9xxx->supplies,
						    pdata->regulator,
						    pdata->num_supplies);
			if (!wcd9xxx->supplies) {
@@ -1081,7 +1083,8 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client,
					__func__);
				goto err_codec;
			}
		ret = msm_cdc_enable_static_supplies(wcd9xxx->dev,
			ret = msm_cdc_enable_static_supplies(
						wcd9xxx->dev,
						wcd9xxx->supplies,
						pdata->regulator,
						pdata->num_supplies);
@@ -1098,6 +1101,7 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client,
				usleep_range(600, 650);
			else
				usleep_range(5, 10);
		}

		ret = wcd9xxx_reset(wcd9xxx->dev);
		if (ret) {
@@ -1144,11 +1148,13 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client,
err_device_init:
	wcd9xxx_reset_low(wcd9xxx->dev);
err_supplies:
	if (pdata->regulator && pdata->num_supplies > 0) {
		msm_cdc_release_supplies(wcd9xxx->dev, wcd9xxx->supplies,
					 pdata->regulator,
					 pdata->num_supplies);
		pdata->regulator = NULL;
		pdata->num_supplies = 0;
	}
err_codec:
	devm_kfree(&client->dev, wcd9xxx);
	dev_set_drvdata(&client->dev, NULL);
@@ -1328,6 +1334,7 @@ static int wcd9xxx_slim_probe(struct slim_device *slim)
	}

	wcd9xxx->num_of_supplies = pdata->num_supplies;
	if (pdata->regulator && pdata->num_supplies > 0) {
		ret = msm_cdc_init_supplies(&slim->dev, &wcd9xxx->supplies,
					    pdata->regulator,
					    pdata->num_supplies);
@@ -1355,6 +1362,7 @@ static int wcd9xxx_slim_probe(struct slim_device *slim)
			usleep_range(600, 650);
		else
			usleep_range(5, 10);
	}

	ret = wcd9xxx_reset(&slim->dev);
	if (ret) {
@@ -1434,6 +1442,7 @@ static int wcd9xxx_slim_probe(struct slim_device *slim)
err_reset:
	wcd9xxx_reset_low(wcd9xxx->dev);
err_supplies:
	if (pdata->regulator && pdata->num_supplies > 0)
		msm_cdc_release_supplies(wcd9xxx->dev, wcd9xxx->supplies,
					 pdata->regulator,
					 pdata->num_supplies);
+2 −4
Original line number Diff line number Diff line
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -325,9 +325,8 @@ struct wcd9xxx_pdata *wcd9xxx_populate_dt_data(struct device *dev)
	msm_cdc_get_power_supplies(dev, &pdata->regulator,
				   &pdata->num_supplies);
	if (!pdata->regulator || (pdata->num_supplies <= 0)) {
		dev_err(dev, "%s: no power supplies defined for codec\n",
		dev_info(dev, "%s: no power supplies defined for codec\n",
			__func__);
		goto err_power_sup;
	}

	/* Parse micbias info */
@@ -415,7 +414,6 @@ struct wcd9xxx_pdata *wcd9xxx_populate_dt_data(struct device *dev)
	devm_kfree(dev, pdata->regulator);
	pdata->regulator = NULL;
	pdata->num_supplies = 0;
err_power_sup:
	devm_kfree(dev, pdata);
	return NULL;
}