summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2024-07-08 16:50:14 +0100
committerMark Brown <broonie@kernel.org>2024-07-08 16:50:14 +0100
commit0c6c65111ed3b662e179e1ab35a0a6e6b362560a (patch)
treeb483d14f919ccc3f3b26d2a73de2b2ca112b0192 /sound
parent1cc509edbe23b61e8c245611bd15d88edb635a38 (diff)
parent522133d4401010d936b0588a5a975c2c965cb88e (diff)
ASoC: Simplify code with cleanup.h
Merge series from Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>: Allocate the memory with scoped/cleanup.h to reduce error handling (simpler error paths) and make the code a bit smaller.
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/audio-iio-aux.c83
-rw-r--r--sound/soc/codecs/wcd9335.c22
-rw-r--r--sound/soc/codecs/wcd934x.c22
-rw-r--r--sound/soc/generic/audio-graph-card.c5
-rw-r--r--sound/soc/generic/audio-graph-card2.c5
-rw-r--r--sound/soc/generic/simple-card-utils.c13
-rw-r--r--sound/soc/generic/simple-card.c5
-rw-r--r--sound/soc/soc-dapm.c47
-rw-r--r--sound/soc/soc-ops.c26
9 files changed, 87 insertions, 141 deletions
diff --git a/sound/soc/codecs/audio-iio-aux.c b/sound/soc/codecs/audio-iio-aux.c
index 1e8e1effc2af..588e48044c13 100644
--- a/sound/soc/codecs/audio-iio-aux.c
+++ b/sound/soc/codecs/audio-iio-aux.c
@@ -6,6 +6,7 @@
//
// Author: Herve Codina <herve.codina@bootlin.com>
+#include <linux/cleanup.h>
#include <linux/iio/consumer.h>
#include <linux/minmax.h>
#include <linux/mod_devicetable.h>
@@ -131,33 +132,27 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component,
struct audio_iio_aux_chan *chan)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
- char *output_name;
- char *input_name;
- char *pga_name;
int ret;
- input_name = kasprintf(GFP_KERNEL, "%s IN", chan->name);
+ /* Allocated names are not needed afterwards (duplicated in ASoC internals) */
+ char *input_name __free(kfree) = kasprintf(GFP_KERNEL, "%s IN", chan->name);
if (!input_name)
return -ENOMEM;
- output_name = kasprintf(GFP_KERNEL, "%s OUT", chan->name);
- if (!output_name) {
- ret = -ENOMEM;
- goto out_free_input_name;
- }
+ char *output_name __free(kfree) = kasprintf(GFP_KERNEL, "%s OUT", chan->name);
+ if (!output_name)
+ return -ENOMEM;
- pga_name = kasprintf(GFP_KERNEL, "%s PGA", chan->name);
- if (!pga_name) {
- ret = -ENOMEM;
- goto out_free_output_name;
- }
+ char *pga_name __free(kfree) = kasprintf(GFP_KERNEL, "%s PGA", chan->name);
+ if (!pga_name)
+ return -ENOMEM;
widgets[0] = SND_SOC_DAPM_INPUT(input_name);
widgets[1] = SND_SOC_DAPM_OUTPUT(output_name);
widgets[2] = SND_SOC_DAPM_PGA(pga_name, SND_SOC_NOPM, 0, 0, NULL, 0);
ret = snd_soc_dapm_new_controls(dapm, widgets, 3);
if (ret)
- goto out_free_pga_name;
+ return ret;
routes[0].sink = pga_name;
routes[0].control = NULL;
@@ -165,17 +160,8 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component,
routes[1].sink = output_name;
routes[1].control = NULL;
routes[1].source = pga_name;
- ret = snd_soc_dapm_add_routes(dapm, routes, 2);
-
- /* Allocated names are no more needed (duplicated in ASoC internals) */
-out_free_pga_name:
- kfree(pga_name);
-out_free_output_name:
- kfree(output_name);
-out_free_input_name:
- kfree(input_name);
- return ret;
+ return snd_soc_dapm_add_routes(dapm, routes, 2);
}
static int audio_iio_aux_component_probe(struct snd_soc_component *component)
@@ -244,8 +230,6 @@ static int audio_iio_aux_probe(struct platform_device *pdev)
struct audio_iio_aux_chan *iio_aux_chan;
struct device *dev = &pdev->dev;
struct audio_iio_aux *iio_aux;
- const char **names;
- u32 *invert_ranges;
int count;
int ret;
int i;
@@ -262,22 +246,22 @@ static int audio_iio_aux_probe(struct platform_device *pdev)
iio_aux->num_chans = count;
- names = kcalloc(iio_aux->num_chans, sizeof(*names), GFP_KERNEL);
+ const char **names __free(kfree) = kcalloc(iio_aux->num_chans,
+ sizeof(*names),
+ GFP_KERNEL);
if (!names)
return -ENOMEM;
- invert_ranges = kcalloc(iio_aux->num_chans, sizeof(*invert_ranges), GFP_KERNEL);
- if (!invert_ranges) {
- ret = -ENOMEM;
- goto out_free_names;
- }
+ u32 *invert_ranges __free(kfree) = kcalloc(iio_aux->num_chans,
+ sizeof(*invert_ranges),
+ GFP_KERNEL);
+ if (!invert_ranges)
+ return -ENOMEM;
ret = device_property_read_string_array(dev, "io-channel-names",
names, iio_aux->num_chans);
- if (ret < 0) {
- dev_err_probe(dev, ret, "failed to read io-channel-names\n");
- goto out_free_invert_ranges;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "failed to read io-channel-names\n");
/*
* snd-control-invert-range is optional and can contain fewer items
@@ -288,10 +272,8 @@ static int audio_iio_aux_probe(struct platform_device *pdev)
count = min_t(unsigned int, count, iio_aux->num_chans);
ret = device_property_read_u32_array(dev, "snd-control-invert-range",
invert_ranges, count);
- if (ret < 0) {
- dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n");
- goto out_free_invert_ranges;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n");
}
for (i = 0; i < iio_aux->num_chans; i++) {
@@ -300,23 +282,16 @@ static int audio_iio_aux_probe(struct platform_device *pdev)
iio_aux_chan->is_invert_range = invert_ranges[i];
iio_aux_chan->iio_chan = devm_iio_channel_get(dev, iio_aux_chan->name);
- if (IS_ERR(iio_aux_chan->iio_chan)) {
- ret = PTR_ERR(iio_aux_chan->iio_chan);
- dev_err_probe(dev, ret, "get IIO channel '%s' failed\n",
- iio_aux_chan->name);
- goto out_free_invert_ranges;
- }
+ if (IS_ERR(iio_aux_chan->iio_chan))
+ return dev_err_probe(dev, PTR_ERR(iio_aux_chan->iio_chan),
+ "get IIO channel '%s' failed\n",
+ iio_aux_chan->name);
}
platform_set_drvdata(pdev, iio_aux);
- ret = devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver,
- NULL, 0);
-out_free_invert_ranges:
- kfree(invert_ranges);
-out_free_names:
- kfree(names);
- return ret;
+ return devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver,
+ NULL, 0);
}
static const struct of_device_id audio_iio_aux_ids[] = {
diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index 1a20131e2a60..373a31ddccb2 100644
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -5,6 +5,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
+#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/wait.h>
#include <linux/bitops.h>
@@ -2714,25 +2715,23 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w,
struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);
unsigned int decimator;
char *dec_adc_mux_name = NULL;
- char *widget_name = NULL;
- char *wname;
+ char *widget_name;
int ret = 0, amic_n;
u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
u16 tx_gain_ctl_reg;
char *dec;
u8 hpf_coff_freq;
- widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL);
- if (!widget_name)
+ char *wname __free(kfree) = kmemdup_nul(w->name, 15, GFP_KERNEL);
+ if (!wname)
return -ENOMEM;
- wname = widget_name;
+ widget_name = wname;
dec_adc_mux_name = strsep(&widget_name, " ");
if (!dec_adc_mux_name) {
dev_err(comp->dev, "%s: Invalid decimator = %s\n",
__func__, w->name);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
dec_adc_mux_name = widget_name;
@@ -2740,16 +2739,14 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w,
if (!dec) {
dev_err(comp->dev, "%s: decimator index not found\n",
__func__);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
ret = kstrtouint(dec, 10, &decimator);
if (ret < 0) {
dev_err(comp->dev, "%s: Invalid decimator = %s\n",
__func__, wname);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
@@ -2836,8 +2833,7 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w,
snd_soc_component_update_bits(comp, tx_vol_ctl_reg, 0x10, 0x00);
break;
}
-out:
- kfree(wname);
+
return ret;
}
diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index 6c65b46e2dc9..291d0c80a6fc 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019, Linaro Limited
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/interrupt.h>
@@ -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);
unsigned int decimator;
char *dec_adc_mux_name = NULL;
- char *widget_name = NULL;
- char *wname;
+ char *widget_name;
int ret = 0, amic_n;
u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
u16 tx_gain_ctl_reg;
char *dec;
u8 hpf_coff_freq;
- widget_name = kstrndup(w->name, 15, GFP_KERNEL);
- if (!widget_name)
+ char *wname __free(kfree) = kstrndup(w->name, 15, GFP_KERNEL);
+ if (!wname)
return -ENOMEM;
- wname = widget_name;
+ widget_name = wname;
dec_adc_mux_name = strsep(&widget_name, " ");
if (!dec_adc_mux_name) {
dev_err(comp->dev, "%s: Invalid decimator = %s\n",
__func__, w->name);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
dec_adc_mux_name = widget_name;
@@ -4999,16 +4998,14 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w,
if (!dec) {
dev_err(comp->dev, "%s: decimator index not found\n",
__func__);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
ret = kstrtouint(dec, 10, &decimator);
if (ret < 0) {
dev_err(comp->dev, "%s: Invalid decimator = %s\n",
__func__, wname);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
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,
WCD934X_DEC_PWR_LVL_DF);
break;
}
-out:
- kfree(wname);
+
return ret;
}
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index acf7d92d21e6..3425fbbcbd7e 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -7,6 +7,7 @@
//
// based on ${LINUX}/sound/soc/generic/simple-card.c
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/gpio/consumer.h>
@@ -573,10 +574,9 @@ static int graph_get_dais_count(struct simple_util_priv *priv,
int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev)
{
struct snd_soc_card *card = simple_priv_to_card(priv);
- struct link_info *li;
int ret;
- li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL);
+ struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL);
if (!li)
return -ENOMEM;
@@ -628,7 +628,6 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev)
if (ret < 0)
goto err;
- devm_kfree(dev, li);
return 0;
err:
diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index 93d9d045587b..56f7f946882e 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -1350,10 +1350,9 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev,
struct graph2_custom_hooks *hooks)
{
struct snd_soc_card *card = simple_priv_to_card(priv);
- struct link_info *li;
int ret;
- li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL);
+ struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL);
if (!li)
return -ENOMEM;
@@ -1417,8 +1416,6 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev,
ret = devm_snd_soc_register_card(dev, card);
err:
- devm_kfree(dev, li);
-
if (ret < 0)
dev_err_probe(dev, ret, "parse error\n");
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index a18de86b3c88..fedae7f6f70c 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -5,6 +5,7 @@
// Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
#include <dt-bindings/sound/audio-graph.h>
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
@@ -135,8 +136,8 @@ EXPORT_SYMBOL_GPL(simple_util_parse_daifmt);
int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np,
struct simple_util_dai *dai)
{
- u32 *array_values, *p;
int n, i, ret;
+ u32 *p;
if (!of_property_read_bool(np, "dai-tdm-slot-width-map"))
return 0;
@@ -151,14 +152,15 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np,
if (!dai->tdm_width_map)
return -ENOMEM;
- array_values = kcalloc(n, sizeof(*array_values), GFP_KERNEL);
+ u32 *array_values __free(kfree) = kcalloc(n, sizeof(*array_values),
+ GFP_KERNEL);
if (!array_values)
return -ENOMEM;
ret = of_property_read_u32_array(np, "dai-tdm-slot-width-map", array_values, n);
if (ret < 0) {
dev_err(dev, "Could not read dai-tdm-slot-width-map: %d\n", ret);
- goto out;
+ return ret;
}
p = array_values;
@@ -169,11 +171,8 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np,
}
dai->n_tdm_widths = i;
- ret = 0;
-out:
- kfree(array_values);
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(simple_util_parse_tdm_width_map);
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index edbb6322e9be..d2588f1ea54e 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -5,6 +5,7 @@
// Copyright (C) 2012 Renesas Solutions Corp.
// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/module.h>
@@ -727,7 +728,6 @@ static int simple_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct snd_soc_card *card;
- struct link_info *li;
int ret;
/* Allocate the private data and the DAI link array */
@@ -741,7 +741,7 @@ static int simple_probe(struct platform_device *pdev)
card->probe = simple_soc_probe;
card->driver_name = "simple-card";
- li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL);
+ struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL);
if (!li)
return -ENOMEM;
@@ -818,7 +818,6 @@ static int simple_probe(struct platform_device *pdev)
if (ret < 0)
goto err;
- devm_kfree(dev, li);
return 0;
err:
simple_util_clean_reference(card);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 32cc90d09bc2..37dccd9c1ba0 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -20,6 +20,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/async.h>
+#include <linux/cleanup.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/bitops.h>
@@ -323,9 +324,9 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
const struct snd_soc_dapm_widget *_widget,
const char *prefix)
{
- struct snd_soc_dapm_widget *w;
-
- w = kmemdup(_widget, sizeof(*_widget), GFP_KERNEL);
+ struct snd_soc_dapm_widget *w __free(kfree) = kmemdup(_widget,
+ sizeof(*_widget),
+ GFP_KERNEL);
if (!w)
return NULL;
@@ -333,20 +334,18 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, _widget->name);
else
w->name = kstrdup_const(_widget->name, GFP_KERNEL);
- if (!w->name) {
- kfree(w);
+ if (!w->name)
return NULL;
- }
if (_widget->sname) {
w->sname = kstrdup_const(_widget->sname, GFP_KERNEL);
if (!w->sname) {
kfree_const(w->name);
- kfree(w);
return NULL;
}
}
- return w;
+
+ return_ptr(w);
}
struct dapm_kcontrol_data {
@@ -3883,11 +3882,10 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
struct snd_soc_dapm_path *path;
struct snd_soc_dai *source, *sink;
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_pcm_hw_params *params = NULL;
const struct snd_soc_pcm_stream *config = NULL;
struct snd_pcm_runtime *runtime = NULL;
unsigned int fmt;
- int ret = 0;
+ int ret;
/*
* NOTE
@@ -3898,15 +3896,14 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
* stuff that increases stack usage.
* So, we use kzalloc()/kfree() for params in this function.
*/
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ struct snd_pcm_hw_params *params __free(kfree) = kzalloc(sizeof(*params),
+ GFP_KERNEL);
if (!params)
return -ENOMEM;
runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
- if (!runtime) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!runtime)
+ return -ENOMEM;
substream->runtime = runtime;
@@ -3916,7 +3913,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
ret = snd_soc_dai_startup(source, substream);
if (ret < 0)
- goto out;
+ return ret;
snd_soc_dai_activate(source, substream->stream);
}
@@ -3927,7 +3924,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
ret = snd_soc_dai_startup(sink, substream);
if (ret < 0)
- goto out;
+ return ret;
snd_soc_dai_activate(sink, substream->stream);
}
@@ -3942,16 +3939,14 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
config = rtd->dai_link->c2c_params + rtd->c2c_params_select;
if (!config) {
dev_err(w->dapm->dev, "ASoC: link config missing\n");
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
/* Be a little careful as we don't want to overflow the mask array */
if (!config->formats) {
dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n");
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
fmt = ffs(config->formats) - 1;
@@ -3972,7 +3967,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
ret = snd_soc_dai_hw_params(source, substream, params);
if (ret < 0)
- goto out;
+ return ret;
dapm_update_dai_unlocked(substream, params, source);
}
@@ -3983,7 +3978,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
ret = snd_soc_dai_hw_params(sink, substream, params);
if (ret < 0)
- goto out;
+ return ret;
dapm_update_dai_unlocked(substream, params, sink);
}
@@ -3993,11 +3988,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
runtime->channels = params_channels(params);
runtime->rate = params_rate(params);
-out:
- /* see above NOTE */
- kfree(params);
-
- return ret;
+ return 0;
}
static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index b27e89ff6a16..19928f098d8d 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -11,6 +11,7 @@
// with code, comments and ideas from :-
// Richard Purdie <richard@openedhand.com>
+#include <linux/cleanup.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
@@ -727,14 +728,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
struct soc_bytes *params = (void *)kcontrol->private_value;
int ret, len;
unsigned int val, mask;
- void *data;
if (!component->regmap || !params->num_regs)
return -EINVAL;
len = params->num_regs * component->val_bytes;
- data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA);
+ void *data __free(kfree) = kmemdup(ucontrol->value.bytes.data, len,
+ GFP_KERNEL | GFP_DMA);
if (!data)
return -ENOMEM;
@@ -746,7 +747,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
if (params->mask) {
ret = regmap_read(component->regmap, params->base, &val);
if (ret != 0)
- goto out;
+ return ret;
val &= params->mask;
@@ -760,14 +761,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
ret = regmap_parse_val(component->regmap,
&mask, &mask);
if (ret != 0)
- goto out;
+ return ret;
((u16 *)data)[0] &= mask;
ret = regmap_parse_val(component->regmap,
&val, &val);
if (ret != 0)
- goto out;
+ return ret;
((u16 *)data)[0] |= val;
break;
@@ -776,30 +777,23 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
ret = regmap_parse_val(component->regmap,
&mask, &mask);
if (ret != 0)
- goto out;
+ return ret;
((u32 *)data)[0] &= mask;
ret = regmap_parse_val(component->regmap,
&val, &val);
if (ret != 0)
- goto out;
+ return ret;
((u32 *)data)[0] |= val;
break;
default:
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
}
- ret = regmap_raw_write(component->regmap, params->base,
- data, len);
-
-out:
- kfree(data);
-
- return ret;
+ return regmap_raw_write(component->regmap, params->base, data, len);
}
EXPORT_SYMBOL_GPL(snd_soc_bytes_put);