Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
b72d4af9 3dce6589

+2 -3
+2 -3
drivers/soundwire/cadence_master.c
··· 6 6 * Used by Master driver 7 7 */ 8 8 9 + #include <linux/cleanup.h> 9 10 #include <linux/delay.h> 10 11 #include <linux/device.h> 11 12 #include <linux/debugfs.h> ··· 324 323 static int cdns_reg_show(struct seq_file *s, void *data) 325 324 { 326 325 struct sdw_cdns *cdns = s->private; 327 - char *buf; 328 326 ssize_t ret; 329 327 int num_ports; 330 328 int i, j; 331 329 332 - buf = kzalloc(RD_BUF, GFP_KERNEL); 330 + char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL); 333 331 if (!buf) 334 332 return -ENOMEM; 335 333 ··· 389 389 ret += cdns_sprintf(cdns, buf, ret, CDNS_PDI_CONFIG(i)); 390 390 391 391 seq_printf(s, "%s", buf); 392 - kfree(buf); 393 392 394 393 return 0; 395 394 }