]> www.infradead.org Git - nvme.git/commitdiff
soundwire: cadence: simplify with cleanup.h
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Wed, 3 Jul 2024 10:16:00 +0000 (12:16 +0200)
committerVinod Koul <vkoul@kernel.org>
Tue, 9 Jul 2024 13:42:49 +0000 (19:12 +0530)
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>
drivers/soundwire/cadence_master.c

index 74da99034dab5813e23d788ae30ab23dfb9ba118..e0683a5975d101e6cf612293459c7467064907c2 100644 (file)
@@ -6,6 +6,7 @@
  * Used by Master driver
  */
 
+#include <linux/cleanup.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/debugfs.h>
@@ -323,12 +324,11 @@ static ssize_t cdns_sprintf(struct sdw_cdns *cdns,
 static int cdns_reg_show(struct seq_file *s, void *data)
 {
        struct sdw_cdns *cdns = s->private;
-       char *buf;
        ssize_t ret;
        int num_ports;
        int i, j;
 
-       buf = kzalloc(RD_BUF, GFP_KERNEL);
+       char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
@@ -389,7 +389,6 @@ static int cdns_reg_show(struct seq_file *s, void *data)
                ret += cdns_sprintf(cdns, buf, ret, CDNS_PDI_CONFIG(i));
 
        seq_printf(s, "%s", buf);
-       kfree(buf);
 
        return 0;
 }