Skip to content

Commit b72d4af

Browse files
krzkvinodkoul
authored andcommitted
soundwire: cadence: 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 <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20240703-soundwire-cleanup-h-v1-8-24fa0dbb948f@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 3dce658 commit b72d4af

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/soundwire/cadence_master.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Used by Master driver
77
*/
88

9+
#include <linux/cleanup.h>
910
#include <linux/delay.h>
1011
#include <linux/device.h>
1112
#include <linux/debugfs.h>
@@ -323,12 +324,11 @@ static ssize_t cdns_sprintf(struct sdw_cdns *cdns,
323324
static int cdns_reg_show(struct seq_file *s, void *data)
324325
{
325326
struct sdw_cdns *cdns = s->private;
326-
char *buf;
327327
ssize_t ret;
328328
int num_ports;
329329
int i, j;
330330

331-
buf = kzalloc(RD_BUF, GFP_KERNEL);
331+
char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL);
332332
if (!buf)
333333
return -ENOMEM;
334334

@@ -389,7 +389,6 @@ static int cdns_reg_show(struct seq_file *s, void *data)
389389
ret += cdns_sprintf(cdns, buf, ret, CDNS_PDI_CONFIG(i));
390390

391391
seq_printf(s, "%s", buf);
392-
kfree(buf);
393392

394393
return 0;
395394
}

0 commit comments

Comments
 (0)