ASoC: Create card debugfs directory earlier
PATCH 1/3 ASoC: Create card debugfs directory earlier
Create the card debugfs directory at the begining of the initilization rather then the end as various steps in the initilization sequence will try to register files and sub-directories in the card directory.
--- sound/soc/soc-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/soc-core.c +3 -2
@@ -1555,6 +1555,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) goto base_error; } +soc_init_card_debugfs (card); + card->dapm.bias_level =SND_SOC_BIAS_OFF ; card->dapm.dev = card->dev; card->dapm.card = card;
@@ -1684,8 +1686,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)mutex_unlock (&card->mutex);mutex_unlock (&client_mutex); -soc_init_card_debugfs (card); -return 0 ; probe_aux_dev_err:
@@ -1699,6 +1699,7 @@ card_probe_error:if (card->remove) card->remove (card); +soc_cleanup_card_debugfs (card);snd_card_free (card->snd_card); base_error:
Signature · 1 line
1.8.0
PATCH 2/3 ASoC: Make soc_dpcm_debugfs_add() non-fatal
Failing to register the debugfs entries is not fatal and will not affect normal operation of the sound card. Don't abort the card registration if soc_dpcm_debugfs_add() fails.
--- include/sound/soc-dpcm.h | 2 +- sound/soc/soc-core.c | 11 ++--------- sound/soc/soc-pcm.c | 8 +++----- 3 files changed, 6 insertions(+), 15 deletions(-)
include/sound/soc-dpcm.h +1 -1
@@ -135,7 +135,7 @@ void snd_soc_dpcm_be_set_state(struct snd_soc_pcm_runtime *be, int stream,/* internal use only */ int soc_dpcm_be_digital_mute (struct snd_soc_pcm_runtime *fe,int mute); -int soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd); +void soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd);int soc_dpcm_runtime_update (struct snd_soc_card *); int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
sound/soc/soc-core.c +2 -9
@@ -1324,15 +1324,8 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)#ifdef CONFIG_DEBUG_FS /* add DPCM sysfs entries */ -if (dai_link->dynamic) { - ret =soc_dpcm_debugfs_add (rtd); -if (ret <0 ) { -dev_err (rtd->dev, -"ASoC: failed to add dpcm sysfs entries: %d\n" , - ret); -return ret; - } - } +if (dai_link->dynamic) +soc_dpcm_debugfs_add (rtd);#endif if (cpu_dai->driver->compress_dai) {
sound/soc/soc-pcm.c +3 -5
@@ -2803,10 +2803,10 @@ static const struct file_operations dpcm_state_fops = { .llseek = default_llseek, }; -int soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd) +void soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd) {if (!rtd->dai_link) -return 0 ; +return ; rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, rtd->card->debugfs_card_root);
@@ -2814,13 +2814,11 @@ int soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)dev_dbg (rtd->dev,"ASoC: Failed to create dpcm debugfs directory %s\n" , rtd->dai_link->name); - return -EINVAL; + return; } rtd->debugfs_dpcm_state =debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, rtd, &dpcm_state_fops); - -return 0 ; }#endif
Signature · 1 line
1.8.0
Re: [PATCH 2/3] ASoC: Make soc_dpcm_debugfs_add() non-fatal
Quoted 3 lines · Lars-Peter Clausen
Failing to register the debugfs entries is not fatal and will not affect normal operation of the sound card. Don't abort the card registration if
soc_dpcm_debugfs_add()fails.
Applied, thanks.
PATCH 3/3 ASoC: Don't try to register debugfs entries if the parent does not exist
In reply to Lars-Peter ClausenIf the registration of a debugfs directory fails this is treated as a non-fatal error in ASoC and operation continues as normal. This means we need to be careful and check if the parent debugfs directory exists if we try to register a debugfs file or sub-directory. Otherwise we might end up passing NULL for the parent and the file or directory will be registered in the top-level debugfs directory.
--- sound/soc/soc-core.c | 66 +++++++++++++++++++++++++++++++++++----------------- sound/soc/soc-dapm.c | 3 +++ sound/soc/soc-pcm.c | 8 +++++-- 3 files changed, 54 insertions(+), 23 deletions(-)
sound/soc/soc-core.c +45 -21
@@ -292,6 +292,9 @@ static const struct file_operations codec_reg_fops = {static void soc_init_component_debugfs (struct snd_soc_component *component) { +if (!component->card->debugfs_card_root) +return ; +if (component->debugfs_prefix) {char *name;
@@ -455,6 +458,9 @@ static const struct file_operations platform_list_fops = {static void soc_init_card_debugfs (struct snd_soc_card *card) { +if (!snd_soc_debugfs_root) +return ; + card->debugfs_card_root =debugfs_create_dir (card->name, snd_soc_debugfs_root);if (!card->debugfs_card_root) {
@@ -476,6 +482,34 @@ static void soc_cleanup_card_debugfs(struct snd_soc_card *card)debugfs_remove_recursive (card->debugfs_card_root); } + +static void snd_soc_debugfs_init (void ) +{ + snd_soc_debugfs_root =debugfs_create_dir ("asoc" ,NULL ); +if (IS_ERR (snd_soc_debugfs_root) || !snd_soc_debugfs_root) { +pr_warn ("ASoC: Failed to create debugfs directory\n" ); + snd_soc_debugfs_root =NULL ; +return ; + } + +if (!debugfs_create_file ("codecs" ,0444 , snd_soc_debugfs_root,NULL , + &codec_list_fops)) +pr_warn ("ASoC: Failed to create CODEC list debugfs file\n" ); + +if (!debugfs_create_file ("dais" ,0444 , snd_soc_debugfs_root,NULL , + &dai_list_fops)) +pr_warn ("ASoC: Failed to create DAI list debugfs file\n" ); + +if (!debugfs_create_file ("platforms" ,0444 , snd_soc_debugfs_root,NULL , + &platform_list_fops)) +pr_warn ("ASoC: Failed to create platform list debugfs file\n" ); +} + +static void snd_soc_debugfs_exit (void ) +{ +debugfs_remove_recursive (snd_soc_debugfs_root); +} +#else #define soc_init_codec_debugfs NULL
@@ -497,6 +531,15 @@ static inline void soc_init_card_debugfs(struct snd_soc_card *card)static inline void soc_cleanup_card_debugfs (struct snd_soc_card *card) { } + +static inline void snd_soc_debugfs_init (void ) +{ +} + +static inline void snd_soc_debugfs_exit (void ) +{ +} +#endif struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
@@ -3584,26 +3627,7 @@ EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_link_codecs);static int __init snd_soc_init (void ) { -#ifdef CONFIG_DEBUG_FS - snd_soc_debugfs_root =debugfs_create_dir ("asoc" ,NULL ); -if (IS_ERR (snd_soc_debugfs_root) || !snd_soc_debugfs_root) { -pr_warn ("ASoC: Failed to create debugfs directory\n" ); - snd_soc_debugfs_root =NULL ; - } - -if (!debugfs_create_file ("codecs" ,0444 , snd_soc_debugfs_root,NULL , - &codec_list_fops)) -pr_warn ("ASoC: Failed to create CODEC list debugfs file\n" ); - -if (!debugfs_create_file ("dais" ,0444 , snd_soc_debugfs_root,NULL , - &dai_list_fops)) -pr_warn ("ASoC: Failed to create DAI list debugfs file\n" ); - -if (!debugfs_create_file ("platforms" ,0444 , snd_soc_debugfs_root,NULL , - &platform_list_fops)) -pr_warn ("ASoC: Failed to create platform list debugfs file\n" ); -#endif - +snd_soc_debugfs_init ();snd_soc_util_init ();return platform_driver_register (&soc_driver);
@@ -3613,9 +3637,9 @@ module_init(snd_soc_init); static void __exit snd_soc_exit(void) {snd_soc_util_exit (); +snd_soc_debugfs_exit ();#ifdef CONFIG_DEBUG_FS -debugfs_remove_recursive (snd_soc_debugfs_root);#endif platform_driver_unregister (&soc_driver); }
sound/soc/soc-dapm.c +3 -0
@@ -1918,6 +1918,9 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, {struct dentry *d; +if (!parent) +return ; + dapm->debugfs_dapm =debugfs_create_dir ("dapm" , parent);if (!dapm->debugfs_dapm) {
sound/soc/soc-pcm.c +6 -2
@@ -1097,8 +1097,9 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, stream ? "<-" : "->", be->dai_link->name);#ifdef CONFIG_DEBUG_FS - dpcm->debugfs_state =debugfs_create_u32 (be->dai_link->name,0644 , - fe->debugfs_dpcm_root, &dpcm->state); +if (fe->debugfs_dpcm_root) + dpcm->debugfs_state =debugfs_create_u32 (be->dai_link->name,0644 , + fe->debugfs_dpcm_root, &dpcm->state);#endif return 1 ; }
@@ -2808,6 +2809,9 @@ void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)if (!rtd->dai_link)return ; +if (!rtd->card->debugfs_card_root) +return ; + rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, rtd->card->debugfs_card_root);if (!rtd->debugfs_dpcm_root) {
Signature · 1 line
1.8.0
Mark Brown
maintainerRe: [PATCH 3/3] ASoC: Don't try to register debugfs entries if the parent does not exist
Quoted 6 lines · Lars-Peter Clausen
If the registration of a debugfs directory fails this is treated as a non-fatal error in ASoC and operation continues as normal. This means we need to be careful and check if the parent debugfs directory exists if we try to register a debugfs file or sub-directory. Otherwise we might end up passing NULL for the parent and the file or directory will be registered in the top-level debugfs directory.
Hrm, right. On the one hand just silently ignoring the knock on errors feels icky on the other hand it's probably better to do something like this providing the earlier errors got reported (and were actually earlier, I can see us reordering things and causing further problems later on).
Quoted 3 lines · Lars-Peter Clausen
Create the card debugfs directory at the begining of the initilization rather then the end as various steps in the initilization sequence will try to register files and sub-directories in the card directory.
Applied, thanks.