ASoC: Intel: SoC: skylake: no need to check return value of debugfs_create functions
Subsystems (4)
PATCH v2 1/3 ASoC: Intel: SoC: skylake: 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.
---
v2: rebase on 5.3-rc1
change Subject line to match the subsystem better rework based on debugfs core now reporting errors.
sound/soc/intel/skylake/skl-debug.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-)
sound/soc/intel/skylake/skl-debug.c +5 -23
@@ -162,10 +162,8 @@ void skl_debug_init_module(struct skl_debug *d,struct snd_soc_dapm_widget *w, struct skl_module_cfg *mconfig) { -if (!debugfs_create_file (w->name,0444 , - d->modules, mconfig, - &mcfg_fops)) -dev_err (d->dev,"%s: module debugfs init failed\n" , w->name); + debugfs_create_file(w->name, 0444, d->modules, mconfig, + &mcfg_fops); } static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
@@ -222,34 +220,18 @@ struct skl_debug *skl_debugfs_init(struct skl *skl)return NULL ;/* create the debugfs dir with platform component's debugfs as parent */ - d->fs =debugfs_create_dir ("dsp" , - skl->component->debugfs_root); -if (IS_ERR (d->fs) || !d->fs) { -dev_err (&skl->pci->dev,"debugfs root creation failed\n" ); -return NULL ; - } + d->fs =debugfs_create_dir ("dsp" , skl->component->debugfs_root); d->skl = skl; d->dev = &skl->pci->dev;/* now create the module dir */ d->modules =debugfs_create_dir ("modules" , d->fs); -if (IS_ERR (d->modules) || !d->modules) { -dev_err (&skl->pci->dev,"modules debugfs create failed\n" ); - goto err; - } -if (!debugfs_create_file ("fw_soft_regs_rd" ,0444 , d->fs, d, - &soft_regs_ctrl_fops)) { -dev_err (d->dev,"fw soft regs control debugfs init failed\n" ); - goto err; - } +debugfs_create_file ("fw_soft_regs_rd" ,0444 , d->fs, d, + &soft_regs_ctrl_fops);return d; - -err: -debugfs_remove_recursive (d->fs); -return NULL ; }void skl_debugfs_exit (struct skl *skl)
Signature · 1 line
2.22.0
PATCH v2 2/3 ASoC: core: 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, there is no need to store the individual debugfs file name, just remove the whole directory all at once, saving a local variable.
Note, the soc-pcm "state" file has now moved to a subdirectory, as it is only a good idea to save the dentries for debugfs directories, not individual files, as the individual file debugfs functions are changing to not return a dentry.
---
v2: rebase on 5.3-rc1
change Subject line to match the subsystem better rework based on debugfs core now reporting errors.
include/sound/soc.h | 1 - sound/soc/soc-core.c | 43 ++++++------------------------------------- sound/soc/soc-dapm.c | 30 ++++-------------------------- sound/soc/soc-pcm.c | 14 ++++---------- 4 files changed, 14 insertions(+), 74 deletions(-)
include/sound/soc.h +0 -1
@@ -1224,7 +1224,6 @@ struct snd_soc_card {#ifdef CONFIG_DEBUG_FS struct dentry *debugfs_card_root; -struct dentry *debugfs_pop_time;#endif u32 pop_time;
sound/soc/soc-core.c +6 -37
70 lines not on this page · raw message
sound/soc/soc-dapm.c +4 -26
@@ -2154,50 +2154,28 @@ static const struct file_operations dapm_bias_fops = {void snd_soc_dapm_debugfs_init (struct snd_soc_dapm_context *dapm,struct dentry *parent) { -struct dentry *d; -if (!parent ||IS_ERR (parent))return ; dapm->debugfs_dapm =debugfs_create_dir ("dapm" , parent); -if (IS_ERR (dapm->debugfs_dapm)) { -dev_warn (dapm->dev, -"ASoC: Failed to create DAPM debugfs directory %ld\n" , -PTR_ERR (dapm->debugfs_dapm)); -return ; - } - - d =debugfs_create_file ("bias_level" ,0444 , - dapm->debugfs_dapm, dapm, - &dapm_bias_fops); -if (IS_ERR (d)) -dev_warn (dapm->dev, -"ASoC: Failed to create bias level debugfs file: %ld\n" , -PTR_ERR (d)); +debugfs_create_file ("bias_level" ,0444 , dapm->debugfs_dapm, dapm, + &dapm_bias_fops); }static void dapm_debugfs_add_widget (struct snd_soc_dapm_widget *w) {struct snd_soc_dapm_context *dapm = w->dapm; -struct dentry *d;if (!dapm->debugfs_dapm || !w->name)return ; - d =debugfs_create_file (w->name,0444 , - dapm->debugfs_dapm, w, - &dapm_widget_power_fops); -if (IS_ERR (d)) -dev_warn (w->dapm->dev, -"ASoC: Failed to create %s debugfs file: %ld\n" , - w->name,PTR_ERR (d)); +debugfs_create_file (w->name,0444 , dapm->debugfs_dapm, w, + &dapm_widget_power_fops); }static void dapm_debugfs_cleanup (struct snd_soc_dapm_context *dapm) { -if (!dapm->debugfs_dapm) -return ;debugfs_remove_recursive (dapm->debugfs_dapm); dapm->debugfs_dapm =NULL ; }
sound/soc/soc-pcm.c +4 -10
@@ -1274,9 +1274,9 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, stream ? "<-" : "->", be->dai_link->name);#ifdef CONFIG_DEBUG_FS -if (fe->debugfs_dpcm_root) - dpcm->debugfs_state =debugfs_create_u32 (be->dai_link->name,0644 , - fe->debugfs_dpcm_root, &dpcm->state); + dpcm->debugfs_state =debugfs_create_dir (be->dai_link->name, + fe->debugfs_dpcm_root); +debugfs_create_u32 ("state" ,0644 , dpcm->debugfs_state, &dpcm->state);#endif return 1 ; }
@@ -1331,7 +1331,7 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)dpcm_be_reparent (fe, dpcm->be, stream);#ifdef CONFIG_DEBUG_FS -debugfs_remove (dpcm->debugfs_state); +debugfs_remove_recursive (dpcm->debugfs_state);#endif spin_lock_irqsave (&fe->card->dpcm_lock, flags);list_del (&dpcm->list_be);
@@ -3466,12 +3466,6 @@ void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd) rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, rtd->card->debugfs_card_root); -if (!rtd->debugfs_dpcm_root) { -dev_dbg (rtd->dev, -"ASoC: Failed to create dpcm debugfs directory %s\n" , - rtd->dai_link->name); -return ; - }debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, rtd, &dpcm_state_fops);
Signature · 1 line
2.22.0
Mark Brown
maintainerApplied "ASoC: core: no need to check return value of debugfs_create functions" to the asoc tree
The patch
ASoC: core: no need to check return value of debugfs_create functions
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
fee531d6fc49b9a616525e30955c4cf3b403f632Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <[email protected]>
Date: Wed, 31 Jul 2019 15:17:15 +0200
Subject: [PATCH] ASoC: core: 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, there is no need to store the individual debugfs file name, just remove the whole directory all at once, saving a local variable.
Note, the soc-pcm "state" file has now moved to a subdirectory, as it is only a good idea to save the dentries for debugfs directories, not individual files, as the individual file debugfs functions are changing to not return a dentry.
--- include/sound/soc.h | 1 - sound/soc/soc-core.c | 43 ++++++------------------------------------- sound/soc/soc-dapm.c | 30 ++++-------------------------- sound/soc/soc-pcm.c | 14 ++++---------- 4 files changed, 14 insertions(+), 74 deletions(-)
include/sound/soc.h +0 -1
@@ -1220,7 +1220,6 @@ struct snd_soc_card {#ifdef CONFIG_DEBUG_FS struct dentry *debugfs_card_root; -struct dentry *debugfs_pop_time;#endif u32 pop_time;
sound/soc/soc-core.c +6 -37
70 lines not on this page · raw message
sound/soc/soc-dapm.c +4 -26
@@ -2154,50 +2154,28 @@ static const struct file_operations dapm_bias_fops = {void snd_soc_dapm_debugfs_init (struct snd_soc_dapm_context *dapm,struct dentry *parent) { -struct dentry *d; -if (!parent ||IS_ERR (parent))return ; dapm->debugfs_dapm =debugfs_create_dir ("dapm" , parent); -if (IS_ERR (dapm->debugfs_dapm)) { -dev_warn (dapm->dev, -"ASoC: Failed to create DAPM debugfs directory %ld\n" , -PTR_ERR (dapm->debugfs_dapm)); -return ; - } - - d =debugfs_create_file ("bias_level" ,0444 , - dapm->debugfs_dapm, dapm, - &dapm_bias_fops); -if (IS_ERR (d)) -dev_warn (dapm->dev, -"ASoC: Failed to create bias level debugfs file: %ld\n" , -PTR_ERR (d)); +debugfs_create_file ("bias_level" ,0444 , dapm->debugfs_dapm, dapm, + &dapm_bias_fops); }static void dapm_debugfs_add_widget (struct snd_soc_dapm_widget *w) {struct snd_soc_dapm_context *dapm = w->dapm; -struct dentry *d;if (!dapm->debugfs_dapm || !w->name)return ; - d =debugfs_create_file (w->name,0444 , - dapm->debugfs_dapm, w, - &dapm_widget_power_fops); -if (IS_ERR (d)) -dev_warn (w->dapm->dev, -"ASoC: Failed to create %s debugfs file: %ld\n" , - w->name,PTR_ERR (d)); +debugfs_create_file (w->name,0444 , dapm->debugfs_dapm, w, + &dapm_widget_power_fops); }static void dapm_debugfs_cleanup (struct snd_soc_dapm_context *dapm) { -if (!dapm->debugfs_dapm) -return ;debugfs_remove_recursive (dapm->debugfs_dapm); dapm->debugfs_dapm =NULL ; }
sound/soc/soc-pcm.c +4 -10
@@ -1205,9 +1205,9 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, stream ? "<-" : "->", be->dai_link->name);#ifdef CONFIG_DEBUG_FS -if (fe->debugfs_dpcm_root) - dpcm->debugfs_state =debugfs_create_u32 (be->dai_link->name,0644 , - fe->debugfs_dpcm_root, &dpcm->state); + dpcm->debugfs_state =debugfs_create_dir (be->dai_link->name, + fe->debugfs_dpcm_root); +debugfs_create_u32 ("state" ,0644 , dpcm->debugfs_state, &dpcm->state);#endif return 1 ; }
@@ -1262,7 +1262,7 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)dpcm_be_reparent (fe, dpcm->be, stream);#ifdef CONFIG_DEBUG_FS -debugfs_remove (dpcm->debugfs_state); +debugfs_remove_recursive (dpcm->debugfs_state);#endif spin_lock_irqsave (&fe->card->dpcm_lock, flags);list_del (&dpcm->list_be);
@@ -3415,12 +3415,6 @@ void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd) rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, rtd->card->debugfs_card_root); -if (!rtd->debugfs_dpcm_root) { -dev_dbg (rtd->dev, -"ASoC: Failed to create dpcm debugfs directory %s\n" , - rtd->dai_link->name); -return ; - }debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, rtd, &dpcm_state_fops);
Signature · 1 line
2.20.1
PATCH v2 3/3 ASoC: SOF: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
---
v2: rebase on 5.3-rc1
change Subject line to match the subsystem better rework based on debugfs core now reporting errors.
sound/soc/sof/debug.c | 49 +++++++++++++++------------------------- sound/soc/sof/sof-priv.h | 1 - sound/soc/sof/trace.c | 9 ++------ 3 files changed, 20 insertions(+), 39 deletions(-)
sound/soc/sof/debug.c +18 -31
@@ -128,6 +128,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,unsigned long ipc_duration_ms =0 ;bool flood_duration_test = false;unsigned long ipc_count =0 ; +struct dentry *dentry;int err;#endif size_t size;
@@ -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 * in the debugfs entry. */ -if (strcmp (dfse->dfsentry->d_name.name,"ipc_flood_count" ) && -strcmp (dfse->dfsentry->d_name.name,"ipc_flood_duration_ms" )) + dentry = file->f_path.dentry; +if (strcmp (dentry->d_name.name,"ipc_flood_count" ) && +strcmp (dentry->d_name.name,"ipc_flood_duration_ms" ))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;/* test completion criterion */
@@ -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_dev *sdev = dfse->sdev; +struct dentry *dentry;loff_t pos = *ppos;size_t size_ret;int skip =0 ;
@@ -226,8 +229,9 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,u8 *buf;#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST ) -if ((!strcmp (dfse->dfsentry->d_name.name,"ipc_flood_count" ) || - !strcmp (dfse->dfsentry->d_name.name,"ipc_flood_duration_ms" )) && + dentry = file->f_path.dentry; +if ((!strcmp (dentry->d_name.name,"ipc_flood_count" ) || + !strcmp (dentry->d_name.name,"ipc_flood_duration_ms" )) && dfse->cache_buf) {if (*ppos)return 0 ;
@@ -290,8 +294,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,if (!pm_runtime_active (sdev->dev) && dfse->access_type ==SOF_DEBUGFS_ACCESS_D0_ONLY ) {dev_err (sdev->dev, -"error: debugfs entry %s cannot be read in DSP D3\n" , - dfse->dfsentry->d_name.name); +"error: debugfs entry cannot be read in DSP D3\n" );kfree (buf);return -EINVAL ; }
@@ -356,17 +359,11 @@ int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev, }#endif - dfse->dfsentry =debugfs_create_file (name,0444 , sdev->debugfs_root, - dfse, &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); +debugfs_create_file (name,0444 , sdev->debugfs_root, dfse, + &sof_dfs_fops); - } +/* add to dfsentry list */ +list_add (&dfse->list, &sdev->dfsentry_list);return 0 ; }
@@ -402,16 +399,10 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,return -ENOMEM ;#endif - dfse->dfsentry =debugfs_create_file (name, mode, sdev->debugfs_root, - dfse, &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); - } +debugfs_create_file (name, mode, sdev->debugfs_root, dfse, + &sof_dfs_fops); +/* add to dfsentry list */ +list_add (&dfse->list, &sdev->dfsentry_list);return 0 ; }
@@ -426,10 +417,6 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev)/* use "sof" as top level debugFS dir */ 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_LIST_HEAD (&sdev->dfsentry_list);
sound/soc/sof/sof-priv.h +0 -1
@@ -228,7 +228,6 @@ enum sof_debugfs_access_type {/* FS entry for debug files that can expose DSP memories, registers */ struct snd_sof_dfsentry { -struct dentry *dfsentry;size_t size;enum sof_dfsentry_type type;/*
sound/soc/sof/trace.c +2 -7
@@ -148,13 +148,8 @@ static int trace_debugfs_create(struct snd_sof_dev *sdev) dfse->size = sdev->dmatb.bytes; dfse->sdev = sdev; - dfse->dfsentry =debugfs_create_file ("trace" ,0444 , sdev->debugfs_root, - dfse, &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" ); - } +debugfs_create_file ("trace" ,0444 , sdev->debugfs_root, dfse, + &sof_dfs_trace_fops);return 0 ; }
Signature · 1 line
2.22.0
Re: [alsa-devel] [PATCH v2 3/3] ASoC: SOF: no need to check return value of debugfs_create functions
Quoted 110 lines · Greg Kroah-Hartman
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 <[email protected]>Cc Mark Brown <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Ranjani Sridharan <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
v2: rebase on 5.3-rc1
change Subject line to match the subsystem better rework based on debugfs core now reporting errors.sound/soc/sof/debug.c | 49 +++++++++++++++----------------------- -- sound/soc/sof/sof-priv.h | 1 - sound/soc/sof/trace.c | 9 ++------ 3 files changed, 20 insertions(+), 39 deletions(-)sound/soc/sof/debug.c +1
-0@@ -128,6 +128,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer, unsigned long ipc_duration_ms = 0;bool flood_duration_test = false;unsigned long ipc_count =0 ; +struct dentry *dentry;int err;#endif sound/soc/sof/debug.c +4
-3size_t size;@@ -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 * in the debugfs entry. */ -if (strcmp (dfse->dfsentry->d_name.name,"ipc_flood_count" ) && -strcmp (dfse->dfsentry->d_name.name, "ipc_flood_duration_ms")) + dentry = file->f_path.dentry; +if (strcmp (dentry->d_name.name,"ipc_flood_count" ) && +strcmp (dentry->d_name.name,"ipc_flood_duration_ms" ))return -EINVAL ; -if (!strcmp (dfse->dfsentry->d_name.name, "ipc_flood_duration_ms")) +if (!strcmp (dentry->d_name.name,"ipc_flood_duration_ms" ))sound/soc/sof/debug.c +1
-0flood_duration_test = true;/* test completion criterion */ @@ -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_dev *sdev = dfse->sdev; +struct dentry *dentry;loff_t pos = *ppos;size_t size_ret;sound/soc/sof/debug.c +0
-2int skip =0 ;@@ -226,8 +229,9 @@ static ssize_t sof_dfsentry_read(struct file *file, char__user *buffer, u8 *buf;#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST ) - if ((!strcmp(dfse->dfsentry->d_name.name, "ipc_flood_count") || - !strcmp(dfse->dfsentry->d_name.name,"
ipc_flood_duration_ms")) &&sound/soc/sof/debug.c +4
-2+ dentry = file->f_path.dentry; +if ((!strcmp (dentry->d_name.name,"ipc_flood_count" ) || + !strcmp (dentry->d_name.name,"ipc_flood_duration_ms" )) && dfse->cache_buf) {if (*ppos)return 0 ;@@ -290,8 +294,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, if (!pm_runtime_active(sdev->dev) && dfse->access_type == SOF_DEBUGFS_ACCESS_D0_ONLY) { dev_err(sdev->dev, - "error: debugfs entry %s cannot be read in DSP D3\n", - dfse->dfsentry->d_name.name); + "error: debugfs entry cannot be read in DSP D3\n");sound/soc/sof/debug.c +0
-3kfree (buf);return -EINVAL ; }@@ -356,17 +359,11 @@ int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev, } #endif - dfse->dfsentry =debugfs_create_file (name,0444 , sdev- >debugfs_root, - dfse, &sof_dfs_fops); -if (!dfse->dfsentry) {
sound/soc/sof/debug.c int snd_sof_debugfs_io_item(struct snd_sof_dev · line 367
Quoted 10 lines
sound/soc/sof/debug.c +2
-6-/* 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); + debugfs_create_file(name, 0444, sdev->debugfs_root, dfse, + &sof_dfs_fops);
Minor nit-pick but looks good otherwise. This will fit all in one line (same with the lines below).
Quoted 82 lines
sound/soc/sof/debug.c +2
-1- } +/* add to dfsentry list */ +list_add (&dfse->list, &sdev->dfsentry_list);sound/soc/sof/debug.c +4
-14return 0 ; }@@ -402,16 +399,10 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev*sdev, return -ENOMEM; #endif - dfse->dfsentry =debugfs_create_file (name, mode, sdev->debugfs_root, - dfse, &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); - } + debugfs_create_file(name, mode, sdev->debugfs_root, dfse, + &sof_dfs_fops); +/* add to dfsentry list */ +list_add (&dfse->list, &sdev->dfsentry_list); return 0; }@@ -426,10 +417,6 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev)/* use "sof" as top level debugFS dir */ 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 */sound/soc/sof/debug.c +0
-0INIT_LIST_HEAD (&sdev->dfsentry_list);sound/soc/sof/sof-priv.h +0
-1@@ -228,7 +228,6 @@ enum sof_debugfs_access_type {/* FS entry for debug files that can expose DSP memories, registers */ struct snd_sof_dfsentry { -struct dentry *dfsentry;size_t size;enum sof_dfsentry_type type;sound/soc/sof/sof-priv.h +0
-0/* sound/soc/sof/trace.c +0
-6@@ -148,13 +148,8 @@ static int trace_debugfs_create(structsnd_sof_dev *sdev) dfse->size = sdev->dmatb.bytes; dfse->sdev = sdev; - dfse->dfsentry =debugfs_create_file ("trace" ,0444 , sdev->debugfs_root, - dfse,&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 fortrace\n");
sound/soc/sof/trace.c +2
-1- } +debugfs_create_file ("trace" ,0444 , sdev->debugfs_root, dfse, + &sof_dfs_trace_fops);return 0 ; }
Mark Brown
maintainerApplied "ASoC: SOF: no need to check return value of debugfs_create functions" to the asoc tree
In reply to Greg Kroah-HartmanThe patch
ASoC: SOF: no need to check return value of debugfs_create functions
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
3ff3a4f657b3fab2d56247983c2ebed180ef2fbbMon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <[email protected]>
Date: Wed, 31 Jul 2019 15:17:16 +0200
Subject: [PATCH] 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.
--- sound/soc/sof/debug.c | 49 +++++++++++++++------------------------- sound/soc/sof/sof-priv.h | 1 - sound/soc/sof/trace.c | 9 ++------ 3 files changed, 20 insertions(+), 39 deletions(-)
sound/soc/sof/debug.c +18 -31
@@ -128,6 +128,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,unsigned long ipc_duration_ms =0 ;bool flood_duration_test = false;unsigned long ipc_count =0 ; +struct dentry *dentry;int err;#endif size_t size;
@@ -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 * in the debugfs entry. */ -if (strcmp (dfse->dfsentry->d_name.name,"ipc_flood_count" ) && -strcmp (dfse->dfsentry->d_name.name,"ipc_flood_duration_ms" )) + dentry = file->f_path.dentry; +if (strcmp (dentry->d_name.name,"ipc_flood_count" ) && +strcmp (dentry->d_name.name,"ipc_flood_duration_ms" ))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;/* test completion criterion */
@@ -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_dev *sdev = dfse->sdev; +struct dentry *dentry;loff_t pos = *ppos;size_t size_ret;int skip =0 ;
@@ -226,8 +229,9 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,u8 *buf;#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST ) -if ((!strcmp (dfse->dfsentry->d_name.name,"ipc_flood_count" ) || - !strcmp (dfse->dfsentry->d_name.name,"ipc_flood_duration_ms" )) && + dentry = file->f_path.dentry; +if ((!strcmp (dentry->d_name.name,"ipc_flood_count" ) || + !strcmp (dentry->d_name.name,"ipc_flood_duration_ms" )) && dfse->cache_buf) {if (*ppos)return 0 ;
@@ -290,8 +294,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,if (!pm_runtime_active (sdev->dev) && dfse->access_type ==SOF_DEBUGFS_ACCESS_D0_ONLY ) {dev_err (sdev->dev, -"error: debugfs entry %s cannot be read in DSP D3\n" , - dfse->dfsentry->d_name.name); +"error: debugfs entry cannot be read in DSP D3\n" );kfree (buf);return -EINVAL ; }
@@ -356,17 +359,11 @@ int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev, }#endif - dfse->dfsentry =debugfs_create_file (name,0444 , sdev->debugfs_root, - dfse, &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); +debugfs_create_file (name,0444 , sdev->debugfs_root, dfse, + &sof_dfs_fops); - } +/* add to dfsentry list */ +list_add (&dfse->list, &sdev->dfsentry_list);return 0 ; }
@@ -402,16 +399,10 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,return -ENOMEM ;#endif - dfse->dfsentry =debugfs_create_file (name, mode, sdev->debugfs_root, - dfse, &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); - } +debugfs_create_file (name, mode, sdev->debugfs_root, dfse, + &sof_dfs_fops); +/* add to dfsentry list */ +list_add (&dfse->list, &sdev->dfsentry_list);return 0 ; }
@@ -426,10 +417,6 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev)/* use "sof" as top level debugFS dir */ 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_LIST_HEAD (&sdev->dfsentry_list);
sound/soc/sof/sof-priv.h +0 -1
@@ -230,7 +230,6 @@ enum sof_debugfs_access_type {/* FS entry for debug files that can expose DSP memories, registers */ struct snd_sof_dfsentry { -struct dentry *dfsentry;size_t size;enum sof_dfsentry_type type;/*
sound/soc/sof/trace.c +2 -7
@@ -148,13 +148,8 @@ static int trace_debugfs_create(struct snd_sof_dev *sdev) dfse->size = sdev->dmatb.bytes; dfse->sdev = sdev; - dfse->dfsentry =debugfs_create_file ("trace" ,0444 , sdev->debugfs_root, - dfse, &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" ); - } +debugfs_create_file ("trace" ,0444 , sdev->debugfs_root, dfse, + &sof_dfs_trace_fops);return 0 ; }
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "ASoC: Intel: SoC: skylake: no need to check return value of debugfs_create functions" to the asoc tree
In reply to Greg Kroah-HartmanThe patch
ASoC: Intel: SoC: skylake: no need to check return value of debugfs_create functions
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
d8701fae95c0e6cb587b293cb8e01acc96dd1095Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <[email protected]>
Date: Wed, 31 Jul 2019 15:17:14 +0200
Subject: [PATCH] ASoC: Intel: SoC: skylake: 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.
--- sound/soc/intel/skylake/skl-debug.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-)
sound/soc/intel/skylake/skl-debug.c +5 -23
@@ -164,10 +164,8 @@ void skl_debug_init_module(struct skl_debug *d,struct snd_soc_dapm_widget *w, struct skl_module_cfg *mconfig) { -if (!debugfs_create_file (w->name,0444 , - d->modules, mconfig, - &mcfg_fops)) -dev_err (d->dev,"%s: module debugfs init failed\n" , w->name); + debugfs_create_file(w->name, 0444, d->modules, mconfig, + &mcfg_fops); } static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
@@ -224,34 +222,18 @@ struct skl_debug *skl_debugfs_init(struct skl_dev *skl)return NULL ;/* create the debugfs dir with platform component's debugfs as parent */ - d->fs =debugfs_create_dir ("dsp" , - skl->component->debugfs_root); -if (IS_ERR (d->fs) || !d->fs) { -dev_err (&skl->pci->dev,"debugfs root creation failed\n" ); -return NULL ; - } + d->fs =debugfs_create_dir ("dsp" , skl->component->debugfs_root); d->skl = skl; d->dev = &skl->pci->dev;/* now create the module dir */ d->modules =debugfs_create_dir ("modules" , d->fs); -if (IS_ERR (d->modules) || !d->modules) { -dev_err (&skl->pci->dev,"modules debugfs create failed\n" ); - goto err; - } -if (!debugfs_create_file ("fw_soft_regs_rd" ,0444 , d->fs, d, - &soft_regs_ctrl_fops)) { -dev_err (d->dev,"fw soft regs control debugfs init failed\n" ); - goto err; - } +debugfs_create_file ("fw_soft_regs_rd" ,0444 , d->fs, d, + &soft_regs_ctrl_fops);return d; - -err: -debugfs_remove_recursive (d->fs); -return NULL ; }void skl_debugfs_exit (struct skl_dev *skl)
Signature · 1 line
2.20.1