Skip to content

Commit fdd3d14

Browse files
krzkvinodkoul
authored andcommitted
soundwire: debugfs: 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-9-24fa0dbb948f@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent b72d4af commit fdd3d14

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/soundwire/debugfs.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
// Copyright(c) 2017-2019 Intel Corporation.
33

4+
#include <linux/cleanup.h>
45
#include <linux/device.h>
56
#include <linux/debugfs.h>
67
#include <linux/firmware.h>
@@ -49,18 +50,16 @@ static ssize_t sdw_sprintf(struct sdw_slave *slave,
4950
static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
5051
{
5152
struct sdw_slave *slave = s_file->private;
52-
char *buf;
5353
ssize_t ret;
5454
int i, j;
5555

56-
buf = kzalloc(RD_BUF, GFP_KERNEL);
56+
char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL);
5757
if (!buf)
5858
return -ENOMEM;
5959

6060
ret = pm_runtime_get_sync(&slave->dev);
6161
if (ret < 0 && ret != -EACCES) {
6262
pm_runtime_put_noidle(&slave->dev);
63-
kfree(buf);
6463
return ret;
6564
}
6665

@@ -132,8 +131,6 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
132131
pm_runtime_mark_last_busy(&slave->dev);
133132
pm_runtime_put(&slave->dev);
134133

135-
kfree(buf);
136-
137134
return 0;
138135
}
139136
DEFINE_SHOW_ATTRIBUTE(sdw_slave_reg);

0 commit comments

Comments
 (0)