Skip to content

Commit 3dce658

Browse files
krzkvinodkoul
authored andcommitted
soundwire: intel_ace2x: 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 13814ed commit 3dce658

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/soundwire/intel_ace2x.c

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

88
#include <linux/acpi.h>
9+
#include <linux/cleanup.h>
910
#include <linux/device.h>
1011
#include <linux/soundwire/sdw_registers.h>
1112
#include <linux/soundwire/sdw.h>
@@ -310,7 +311,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
310311
struct sdw_cdns_dai_runtime *dai_runtime;
311312
struct sdw_cdns_pdi *pdi;
312313
struct sdw_stream_config sconfig;
313-
struct sdw_port_config *pconfig;
314314
int ch, dir;
315315
int ret;
316316

@@ -357,7 +357,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
357357
sconfig.bps = snd_pcm_format_width(params_format(params));
358358

359359
/* Port configuration */
360-
pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL);
360+
struct sdw_port_config *pconfig __free(kfree) = kzalloc(sizeof(*pconfig),
361+
GFP_KERNEL);
361362
if (!pconfig)
362363
return -ENOMEM;
363364

@@ -369,8 +370,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
369370
if (ret)
370371
dev_err(cdns->dev, "add master to stream failed:%d\n", ret);
371372

372-
kfree(pconfig);
373-
374373
return ret;
375374
}
376375

0 commit comments

Comments
 (0)