mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-09-21 12:11:49 +08:00
soundwire: intel: 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-5-24fa0dbb948f@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
ba874a8c2f
commit
e4fcf153d9
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
|
#include <linux/cleanup.h>
|
||||||
#include <linux/debugfs.h>
|
#include <linux/debugfs.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
@ -73,12 +74,11 @@ static int intel_reg_show(struct seq_file *s_file, void *data)
|
|||||||
struct sdw_intel *sdw = s_file->private;
|
struct sdw_intel *sdw = s_file->private;
|
||||||
void __iomem *s = sdw->link_res->shim;
|
void __iomem *s = sdw->link_res->shim;
|
||||||
void __iomem *a = sdw->link_res->alh;
|
void __iomem *a = sdw->link_res->alh;
|
||||||
char *buf;
|
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
int i, j;
|
int i, j;
|
||||||
unsigned int links, reg;
|
unsigned int links, reg;
|
||||||
|
|
||||||
buf = kzalloc(RD_BUF, GFP_KERNEL);
|
char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -129,7 +129,6 @@ static int intel_reg_show(struct seq_file *s_file, void *data)
|
|||||||
ret += intel_sprintf(a, true, buf, ret, SDW_ALH_STRMZCFG(i));
|
ret += intel_sprintf(a, true, buf, ret, SDW_ALH_STRMZCFG(i));
|
||||||
|
|
||||||
seq_printf(s_file, "%s", buf);
|
seq_printf(s_file, "%s", buf);
|
||||||
kfree(buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -727,7 +726,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
|
|||||||
struct sdw_cdns_dai_runtime *dai_runtime;
|
struct sdw_cdns_dai_runtime *dai_runtime;
|
||||||
struct sdw_cdns_pdi *pdi;
|
struct sdw_cdns_pdi *pdi;
|
||||||
struct sdw_stream_config sconfig;
|
struct sdw_stream_config sconfig;
|
||||||
struct sdw_port_config *pconfig;
|
|
||||||
int ch, dir;
|
int ch, dir;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -771,7 +769,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
|
|||||||
sconfig.bps = snd_pcm_format_width(params_format(params));
|
sconfig.bps = snd_pcm_format_width(params_format(params));
|
||||||
|
|
||||||
/* Port configuration */
|
/* Port configuration */
|
||||||
pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL);
|
struct sdw_port_config *pconfig __free(kfree) = kzalloc(sizeof(*pconfig),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!pconfig)
|
if (!pconfig)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -783,8 +782,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
|
|||||||
if (ret)
|
if (ret)
|
||||||
dev_err(cdns->dev, "add master to stream failed:%d\n", ret);
|
dev_err(cdns->dev, "add master to stream failed:%d\n", ret);
|
||||||
|
|
||||||
kfree(pconfig);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user