Commit 6440e7b2 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

ASoC: simple-card-utils: 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>
Acked-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/20240703-asoc-cleanup-h-v1-5-71219dfd0aef@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 56d426f5
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
// Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> // Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
#include <dt-bindings/sound/audio-graph.h> #include <dt-bindings/sound/audio-graph.h>
#include <linux/cleanup.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -135,8 +136,8 @@ EXPORT_SYMBOL_GPL(simple_util_parse_daifmt); ...@@ -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, int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np,
struct simple_util_dai *dai) struct simple_util_dai *dai)
{ {
u32 *array_values, *p;
int n, i, ret; int n, i, ret;
u32 *p;
if (!of_property_read_bool(np, "dai-tdm-slot-width-map")) if (!of_property_read_bool(np, "dai-tdm-slot-width-map"))
return 0; return 0;
...@@ -151,14 +152,15 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, ...@@ -151,14 +152,15 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np,
if (!dai->tdm_width_map) if (!dai->tdm_width_map)
return -ENOMEM; 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) if (!array_values)
return -ENOMEM; return -ENOMEM;
ret = of_property_read_u32_array(np, "dai-tdm-slot-width-map", array_values, n); ret = of_property_read_u32_array(np, "dai-tdm-slot-width-map", array_values, n);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Could not read dai-tdm-slot-width-map: %d\n", ret); dev_err(dev, "Could not read dai-tdm-slot-width-map: %d\n", ret);
goto out; return ret;
} }
p = array_values; p = array_values;
...@@ -169,11 +171,8 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, ...@@ -169,11 +171,8 @@ int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np,
} }
dai->n_tdm_widths = i; dai->n_tdm_widths = i;
ret = 0;
out:
kfree(array_values);
return ret; return 0;
} }
EXPORT_SYMBOL_GPL(simple_util_parse_tdm_width_map); EXPORT_SYMBOL_GPL(simple_util_parse_tdm_width_map);
......
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