Unverified Commit 3045e29d authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown
Browse files

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: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20251120130640.1169780-3-rf@opensource.cirrus.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 78cfd833
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -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));
	}
}