Commit 56d426f5 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

ASoC: codecs: wcd934x: Simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling (less
error paths) and make the code a bit simpler.
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240703-asoc-cleanup-h-v1-4-71219dfd0aef@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6344ab5d
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019, Linaro Limited // Copyright (c) 2019, Linaro Limited
#include <linux/cleanup.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -4973,25 +4974,23 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, ...@@ -4973,25 +4974,23 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w,
struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);
unsigned int decimator; unsigned int decimator;
char *dec_adc_mux_name = NULL; char *dec_adc_mux_name = NULL;
char *widget_name = NULL; char *widget_name;
char *wname;
int ret = 0, amic_n; int ret = 0, amic_n;
u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
u16 tx_gain_ctl_reg; u16 tx_gain_ctl_reg;
char *dec; char *dec;
u8 hpf_coff_freq; u8 hpf_coff_freq;
widget_name = kstrndup(w->name, 15, GFP_KERNEL); char *wname __free(kfree) = kstrndup(w->name, 15, GFP_KERNEL);
if (!widget_name) if (!wname)
return -ENOMEM; return -ENOMEM;
wname = widget_name; widget_name = wname;
dec_adc_mux_name = strsep(&widget_name, " "); dec_adc_mux_name = strsep(&widget_name, " ");
if (!dec_adc_mux_name) { if (!dec_adc_mux_name) {
dev_err(comp->dev, "%s: Invalid decimator = %s\n", dev_err(comp->dev, "%s: Invalid decimator = %s\n",
__func__, w->name); __func__, w->name);
ret = -EINVAL; return -EINVAL;
goto out;
} }
dec_adc_mux_name = widget_name; dec_adc_mux_name = widget_name;
...@@ -4999,16 +4998,14 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, ...@@ -4999,16 +4998,14 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w,
if (!dec) { if (!dec) {
dev_err(comp->dev, "%s: decimator index not found\n", dev_err(comp->dev, "%s: decimator index not found\n",
__func__); __func__);
ret = -EINVAL; return -EINVAL;
goto out;
} }
ret = kstrtouint(dec, 10, &decimator); ret = kstrtouint(dec, 10, &decimator);
if (ret < 0) { if (ret < 0) {
dev_err(comp->dev, "%s: Invalid decimator = %s\n", dev_err(comp->dev, "%s: Invalid decimator = %s\n",
__func__, wname); __func__, wname);
ret = -EINVAL; return -EINVAL;
goto out;
} }
tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator; tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator;
...@@ -5101,8 +5098,7 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, ...@@ -5101,8 +5098,7 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w,
WCD934X_DEC_PWR_LVL_DF); WCD934X_DEC_PWR_LVL_DF);
break; break;
} }
out:
kfree(wname);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment