mirror of https://gitee.com/openkylin/linux.git
extcon: arizona: Correct error handling on regmap_update_bits_check
Ensure the case when regmap_update_bits_check fails and the change variable is not updated is handled correctly. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
This commit is contained in:
parent
cd6c84d8f0
commit
fbdc60b2a7
|
@ -335,10 +335,12 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
|
||||||
|
|
||||||
arizona_extcon_pulse_micbias(info);
|
arizona_extcon_pulse_micbias(info);
|
||||||
|
|
||||||
regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
|
ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
|
||||||
ARIZONA_MICD_ENA, ARIZONA_MICD_ENA,
|
ARIZONA_MICD_ENA, ARIZONA_MICD_ENA,
|
||||||
&change);
|
&change);
|
||||||
if (!change) {
|
if (ret < 0) {
|
||||||
|
dev_err(arizona->dev, "Failed to enable micd: %d\n", ret);
|
||||||
|
} else if (!change) {
|
||||||
regulator_disable(info->micvdd);
|
regulator_disable(info->micvdd);
|
||||||
pm_runtime_put_autosuspend(info->dev);
|
pm_runtime_put_autosuspend(info->dev);
|
||||||
}
|
}
|
||||||
|
@ -350,12 +352,14 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
|
||||||
const char *widget = arizona_extcon_get_micbias(info);
|
const char *widget = arizona_extcon_get_micbias(info);
|
||||||
struct snd_soc_dapm_context *dapm = arizona->dapm;
|
struct snd_soc_dapm_context *dapm = arizona->dapm;
|
||||||
struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
|
struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
|
||||||
bool change;
|
bool change = false;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
|
ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
|
||||||
ARIZONA_MICD_ENA, 0,
|
ARIZONA_MICD_ENA, 0,
|
||||||
&change);
|
&change);
|
||||||
|
if (ret < 0)
|
||||||
|
dev_err(arizona->dev, "Failed to disable micd: %d\n", ret);
|
||||||
|
|
||||||
ret = snd_soc_component_disable_pin(component, widget);
|
ret = snd_soc_component_disable_pin(component, widget);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
@ -1727,12 +1731,15 @@ static int arizona_extcon_remove(struct platform_device *pdev)
|
||||||
struct arizona *arizona = info->arizona;
|
struct arizona *arizona = info->arizona;
|
||||||
int jack_irq_rise, jack_irq_fall;
|
int jack_irq_rise, jack_irq_fall;
|
||||||
bool change;
|
bool change;
|
||||||
|
int ret;
|
||||||
|
|
||||||
regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
|
ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
|
||||||
ARIZONA_MICD_ENA, 0,
|
ARIZONA_MICD_ENA, 0,
|
||||||
&change);
|
&change);
|
||||||
|
if (ret < 0) {
|
||||||
if (change) {
|
dev_err(&pdev->dev, "Failed to disable micd on remove: %d\n",
|
||||||
|
ret);
|
||||||
|
} else if (change) {
|
||||||
regulator_disable(info->micvdd);
|
regulator_disable(info->micvdd);
|
||||||
pm_runtime_put(info->dev);
|
pm_runtime_put(info->dev);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue