Commit 3ff3a4f6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Mark Brown

ASoC: SOF: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Also, if a debugfs call fails, userspace is notified with an error in
the log, so no need to log the error again.

Because we no longer need to check the return value, there's no need to
save the dentry returned by debugfs.  Just use the dentry in the file
pointer if we really need to figure out the "name" of the file being
opened.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20190731131716.9764-3-gregkh@linuxfoundation.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fee531d6
...@@ -128,6 +128,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer, ...@@ -128,6 +128,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,
unsigned long ipc_duration_ms = 0; unsigned long ipc_duration_ms = 0;
bool flood_duration_test = false; bool flood_duration_test = false;
unsigned long ipc_count = 0; unsigned long ipc_count = 0;
struct dentry *dentry;
int err; int err;
#endif #endif
size_t size; size_t size;
...@@ -149,11 +150,12 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer, ...@@ -149,11 +150,12 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,
* ipc_duration_ms test floods the DSP for the time specified * ipc_duration_ms test floods the DSP for the time specified
* in the debugfs entry. * in the debugfs entry.
*/ */
if (strcmp(dfse->dfsentry->d_name.name, "ipc_flood_count") && dentry = file->f_path.dentry;
strcmp(dfse->dfsentry->d_name.name, "ipc_flood_duration_ms")) if (strcmp(dentry->d_name.name, "ipc_flood_count") &&
strcmp(dentry->d_name.name, "ipc_flood_duration_ms"))
return -EINVAL; return -EINVAL;
if (!strcmp(dfse->dfsentry->d_name.name, "ipc_flood_duration_ms")) if (!strcmp(dentry->d_name.name, "ipc_flood_duration_ms"))
flood_duration_test = true; flood_duration_test = true;
/* test completion criterion */ /* test completion criterion */
...@@ -219,6 +221,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, ...@@ -219,6 +221,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
{ {
struct snd_sof_dfsentry *dfse = file->private_data; struct snd_sof_dfsentry *dfse = file->private_data;
struct snd_sof_dev *sdev = dfse->sdev; struct snd_sof_dev *sdev = dfse->sdev;
struct dentry *dentry;
loff_t pos = *ppos; loff_t pos = *ppos;
size_t size_ret; size_t size_ret;
int skip = 0; int skip = 0;
...@@ -226,8 +229,9 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, ...@@ -226,8 +229,9 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
u8 *buf; u8 *buf;
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST) #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST)
if ((!strcmp(dfse->dfsentry->d_name.name, "ipc_flood_count") || dentry = file->f_path.dentry;
!strcmp(dfse->dfsentry->d_name.name, "ipc_flood_duration_ms")) && if ((!strcmp(dentry->d_name.name, "ipc_flood_count") ||
!strcmp(dentry->d_name.name, "ipc_flood_duration_ms")) &&
dfse->cache_buf) { dfse->cache_buf) {
if (*ppos) if (*ppos)
return 0; return 0;
...@@ -290,8 +294,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, ...@@ -290,8 +294,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
if (!pm_runtime_active(sdev->dev) && if (!pm_runtime_active(sdev->dev) &&
dfse->access_type == SOF_DEBUGFS_ACCESS_D0_ONLY) { dfse->access_type == SOF_DEBUGFS_ACCESS_D0_ONLY) {
dev_err(sdev->dev, dev_err(sdev->dev,
"error: debugfs entry %s cannot be read in DSP D3\n", "error: debugfs entry cannot be read in DSP D3\n");
dfse->dfsentry->d_name.name);
kfree(buf); kfree(buf);
return -EINVAL; return -EINVAL;
} }
...@@ -356,17 +359,11 @@ int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev, ...@@ -356,17 +359,11 @@ int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev,
} }
#endif #endif
dfse->dfsentry = debugfs_create_file(name, 0444, sdev->debugfs_root, debugfs_create_file(name, 0444, sdev->debugfs_root, dfse,
dfse, &sof_dfs_fops); &sof_dfs_fops);
if (!dfse->dfsentry) {
/* can't rely on debugfs, only log error and keep going */
dev_err(sdev->dev, "error: cannot create debugfs entry %s\n",
name);
} else {
/* add to dfsentry list */
list_add(&dfse->list, &sdev->dfsentry_list);
} /* add to dfsentry list */
list_add(&dfse->list, &sdev->dfsentry_list);
return 0; return 0;
} }
...@@ -402,16 +399,10 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev, ...@@ -402,16 +399,10 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
return -ENOMEM; return -ENOMEM;
#endif #endif
dfse->dfsentry = debugfs_create_file(name, mode, sdev->debugfs_root, debugfs_create_file(name, mode, sdev->debugfs_root, dfse,
dfse, &sof_dfs_fops); &sof_dfs_fops);
if (!dfse->dfsentry) { /* add to dfsentry list */
/* can't rely on debugfs, only log error and keep going */ list_add(&dfse->list, &sdev->dfsentry_list);
dev_err(sdev->dev, "error: cannot create debugfs entry %s\n",
name);
} else {
/* add to dfsentry list */
list_add(&dfse->list, &sdev->dfsentry_list);
}
return 0; return 0;
} }
...@@ -426,10 +417,6 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev) ...@@ -426,10 +417,6 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev)
/* use "sof" as top level debugFS dir */ /* use "sof" as top level debugFS dir */
sdev->debugfs_root = debugfs_create_dir("sof", NULL); sdev->debugfs_root = debugfs_create_dir("sof", NULL);
if (IS_ERR_OR_NULL(sdev->debugfs_root)) {
dev_err(sdev->dev, "error: failed to create debugfs directory\n");
return 0;
}
/* init dfsentry list */ /* init dfsentry list */
INIT_LIST_HEAD(&sdev->dfsentry_list); INIT_LIST_HEAD(&sdev->dfsentry_list);
......
...@@ -230,7 +230,6 @@ enum sof_debugfs_access_type { ...@@ -230,7 +230,6 @@ enum sof_debugfs_access_type {
/* FS entry for debug files that can expose DSP memories, registers */ /* FS entry for debug files that can expose DSP memories, registers */
struct snd_sof_dfsentry { struct snd_sof_dfsentry {
struct dentry *dfsentry;
size_t size; size_t size;
enum sof_dfsentry_type type; enum sof_dfsentry_type type;
/* /*
......
...@@ -148,13 +148,8 @@ static int trace_debugfs_create(struct snd_sof_dev *sdev) ...@@ -148,13 +148,8 @@ static int trace_debugfs_create(struct snd_sof_dev *sdev)
dfse->size = sdev->dmatb.bytes; dfse->size = sdev->dmatb.bytes;
dfse->sdev = sdev; dfse->sdev = sdev;
dfse->dfsentry = debugfs_create_file("trace", 0444, sdev->debugfs_root, debugfs_create_file("trace", 0444, sdev->debugfs_root, dfse,
dfse, &sof_dfs_trace_fops); &sof_dfs_trace_fops);
if (!dfse->dfsentry) {
/* can't rely on debugfs, only log error and keep going */
dev_err(sdev->dev,
"error: cannot create debugfs entry for trace\n");
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment