Commit 02611eee authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Vinod Koul

soundwire: amd: simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240703-soundwire-cleanup-h-v1-2-24fa0dbb948f@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 89cc1354
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/cleanup.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
...@@ -600,7 +601,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, ...@@ -600,7 +601,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream,
struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai); struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai);
struct sdw_amd_dai_runtime *dai_runtime; struct sdw_amd_dai_runtime *dai_runtime;
struct sdw_stream_config sconfig; struct sdw_stream_config sconfig;
struct sdw_port_config *pconfig;
int ch, dir; int ch, dir;
int ret; int ret;
...@@ -623,7 +623,8 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, ...@@ -623,7 +623,8 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream,
sconfig.bps = snd_pcm_format_width(params_format(params)); sconfig.bps = snd_pcm_format_width(params_format(params));
/* Port configuration */ /* Port configuration */
pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); struct sdw_port_config *pconfig __free(kfree) = kzalloc(sizeof(*pconfig),
GFP_KERNEL);
if (!pconfig) if (!pconfig)
return -ENOMEM; return -ENOMEM;
...@@ -634,8 +635,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream, ...@@ -634,8 +635,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream,
if (ret) if (ret)
dev_err(amd_manager->dev, "add manager to stream failed:%d\n", ret); dev_err(amd_manager->dev, "add manager to stream failed:%d\n", ret);
kfree(pconfig);
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