mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
firmware: cs_dsp: Append \n to debugfs string during read
Append the terminating \n to the string during the debugfs file read instead of creating a string that already has a trailing \n. This avoids the ugly behaviour of having to include a trailing \n in the filenames stored to wmfw_file_name and bin_file_name in struct cs_dsp. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20251120130640.1169780-3-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
78cfd833bc
commit
3045e29d24
@@ -389,18 +389,14 @@ EXPORT_SYMBOL_NS_GPL(cs_dsp_mem_region_name, "FW_CS_DSP");
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
static void cs_dsp_debugfs_save_wmfwname(struct cs_dsp *dsp, const char *s)
|
||||
{
|
||||
char *tmp = kasprintf(GFP_KERNEL, "%s\n", s);
|
||||
|
||||
kfree(dsp->wmfw_file_name);
|
||||
dsp->wmfw_file_name = tmp;
|
||||
dsp->wmfw_file_name = kstrdup(s, GFP_KERNEL);
|
||||
}
|
||||
|
||||
static void cs_dsp_debugfs_save_binname(struct cs_dsp *dsp, const char *s)
|
||||
{
|
||||
char *tmp = kasprintf(GFP_KERNEL, "%s\n", s);
|
||||
|
||||
kfree(dsp->bin_file_name);
|
||||
dsp->bin_file_name = tmp;
|
||||
dsp->bin_file_name = kstrdup(s, GFP_KERNEL);
|
||||
}
|
||||
|
||||
static void cs_dsp_debugfs_clear(struct cs_dsp *dsp)
|
||||
@@ -416,13 +412,16 @@ static ssize_t cs_dsp_debugfs_string_read(struct cs_dsp *dsp,
|
||||
size_t count, loff_t *ppos,
|
||||
const char **pstr)
|
||||
{
|
||||
const char *str;
|
||||
const char *str __free(kfree) = NULL;
|
||||
|
||||
scoped_guard(mutex, &dsp->pwr_lock) {
|
||||
str = *pstr;
|
||||
if (!str)
|
||||
if (!*pstr)
|
||||
return 0;
|
||||
|
||||
str = kasprintf(GFP_KERNEL, "%s\n", *pstr);
|
||||
if (!str)
|
||||
return -ENOMEM;
|
||||
|
||||
return simple_read_from_buffer(user_buf, count, ppos, str, strlen(str));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user