mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 11:30:54 +07:00
ASoC: Don't try to register debugfs entries if the parent does not exist
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. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
2e55b90a5e
commit
6553bf06a3
@ -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,
|
||||
@ -3580,26 +3623,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);
|
||||
@ -3609,9 +3633,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);
|
||||
}
|
||||
|
@ -1898,6 +1898,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) {
|
||||
|
@ -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;
|
||||
}
|
||||
@ -2807,6 +2808,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) {
|
||||
|
Loading…
Reference in New Issue
Block a user