Skip to content

Commit 02611ee

Browse files
krzkvinodkoul
authored andcommitted
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: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 89cc135 commit 02611ee

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/soundwire/amd_manager.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/completion.h>
9+
#include <linux/cleanup.h>
910
#include <linux/device.h>
1011
#include <linux/io.h>
1112
#include <linux/jiffies.h>
@@ -600,7 +601,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream,
600601
struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai);
601602
struct sdw_amd_dai_runtime *dai_runtime;
602603
struct sdw_stream_config sconfig;
603-
struct sdw_port_config *pconfig;
604604
int ch, dir;
605605
int ret;
606606

@@ -623,7 +623,8 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream,
623623
sconfig.bps = snd_pcm_format_width(params_format(params));
624624

625625
/* Port configuration */
626-
pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL);
626+
struct sdw_port_config *pconfig __free(kfree) = kzalloc(sizeof(*pconfig),
627+
GFP_KERNEL);
627628
if (!pconfig)
628629
return -ENOMEM;
629630

@@ -634,8 +635,6 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream,
634635
if (ret)
635636
dev_err(amd_manager->dev, "add manager to stream failed:%d\n", ret);
636637

637-
kfree(pconfig);
638-
639638
return ret;
640639
}
641640

0 commit comments

Comments
 (0)