ASoC: core: Adapt for debugfs API change
Subsystems (3)
Mark Brown
maintainerPATCH 1/2 ASoC: core: Adapt for debugfs API change
Back in ff9fb72bc07705c (debugfs: return error values, not NULL) the debugfs APIs were changed to return error pointers rather than NULL pointers on error, breaking the error checking in ASoC. Update the code to use IS_ERR() and log the codes that are returned as part of the error messages.
--- sound/soc/soc-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/soc/soc-core.c +10 -6
@@ -165,9 +165,10 @@ static void soc_init_component_debugfs(struct snd_soc_component *component) component->card->debugfs_card_root); } -if (!component->debugfs_root) { +if (IS_ERR (component->debugfs_root)) {dev_warn (component->dev, -"ASoC: Failed to create component debugfs directory\n" ); +"ASoC: Failed to create component debugfs directory: %ld\n" , +PTR_ERR (component->debugfs_root));return ; }
@@ -219,18 +220,21 @@ static void soc_init_card_debugfs(struct snd_soc_card *card) card->debugfs_card_root =debugfs_create_dir (card->name, snd_soc_debugfs_root); -if (!card->debugfs_card_root) { +if (IS_ERR (card->debugfs_card_root)) {dev_warn (card->dev, -"ASoC: Failed to create card debugfs directory\n" ); +"ASoC: Failed to create card debugfs directory: %ld\n" , +PTR_ERR (card->debugfs_card_root)); + card->debugfs_card_root =NULL ;return ; } card->debugfs_pop_time =debugfs_create_u32 ("dapm_pop_time" ,0644 , card->debugfs_card_root, &card->pop_time); -if (!card->debugfs_pop_time) +if (IS_ERR (card->debugfs_pop_time))dev_warn (card->dev, -"ASoC: Failed to create pop time debugfs file\n" ); +"ASoC: Failed to create pop time debugfs file: %ld\n" , +PTR_ERR (card->debugfs_pop_time)); }static void soc_cleanup_card_debugfs (struct snd_soc_card *card)
Signature · 1 line
2.20.1
Mark Brown
maintainerPATCH 2/2 ASoC: dapm: Adapt for debugfs API change
Back in ff9fb72bc07705c (debugfs: return error values, not NULL) the debugfs APIs were changed to return error pointers rather than NULL pointers on error, breaking the error checking in ASoC. Update the code to use IS_ERR() and log the codes that are returned as part of the error messages.
--- sound/soc/soc-dapm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
sound/soc/soc-dapm.c +10 -8
@@ -2156,23 +2156,25 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, {struct dentry *d; -if (!parent) +if (!parent ||IS_ERR (parent))return ; dapm->debugfs_dapm =debugfs_create_dir ("dapm" , parent); -if (!dapm->debugfs_dapm) { +if (IS_ERR (dapm->debugfs_dapm)) {dev_warn (dapm->dev, -"ASoC: Failed to create DAPM debugfs directory\n" ); +"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 (!d) +if (IS_ERR (d))dev_warn (dapm->dev, -"ASoC: Failed to create bias level debugfs file\n" ); +"ASoC: Failed to create bias level debugfs file: %ld\n" , +PTR_ERR (d)); }static void dapm_debugfs_add_widget (struct snd_soc_dapm_widget *w)
@@ -2186,10 +2188,10 @@ static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) d =debugfs_create_file (w->name,0444 , dapm->debugfs_dapm, w, &dapm_widget_power_fops); -if (!d) +if (IS_ERR (d))dev_warn (w->dapm->dev, -"ASoC: Failed to create %s debugfs file\n" , - w->name); +"ASoC: Failed to create %s debugfs file: %ld\n" , + w->name,PTR_ERR (d)); }static void dapm_debugfs_cleanup (struct snd_soc_dapm_context *dapm)
Signature · 1 line
2.20.1
Re: [PATCH 2/2] ASoC: dapm: Adapt for debugfs API change
Quoted 18 lines · Mark Brown
Back in
ff9fb72bc07705c(debugfs: return error values, not NULL) the debugfs APIs were changed to return error pointers rather than NULL pointers on error, breaking the error checking in ASoC. Update the code to useIS_ERR()and log the codes that are returned as part of the error messages.Fixes ff9fb72bc07705c (debugfs: return error values, not NULL)Signed-off-by Mark Brown <[email protected]>--- sound/soc/soc-dapm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)sound/soc/soc-dapm.c +0
-0
sound/soc/soc-dapm.c void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, · line 2160
Quoted 6 lines
sound/soc/soc-dapm.c +1
-1@@ -2156,23 +2156,25 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, {struct dentry *d; -if (!parent) +if (!parent ||IS_ERR (parent))return ;
How can parent be NULL?
sound/soc/soc-dapm.c void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, · line 2167
Quoted 9 lines
sound/soc/soc-dapm.c +3
-2dapm->debugfs_dapm =debugfs_create_dir ("dapm" , parent); -if (!dapm->debugfs_dapm) { +if (IS_ERR (dapm->debugfs_dapm)) {dev_warn (dapm->dev, -"ASoC: Failed to create DAPM debugfs directory\n" ); +"ASoC: Failed to create DAPM debugfs directory %ld\n" , +PTR_ERR (dapm->debugfs_dapm));
Same comment as before, no need to print anything.
sound/soc/soc-dapm.c void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, · line 2177
Quoted 12 lines
sound/soc/soc-dapm.c +3
-2return ; } d =debugfs_create_file ("bias_level" ,0444 , dapm->debugfs_dapm, dapm, &dapm_bias_fops); -if (!d) +if (IS_ERR (d))dev_warn (dapm->dev, -"ASoC: Failed to create bias level debugfs file\n" ); +"ASoC: Failed to create bias level debugfs file: %ld\n" , +PTR_ERR (d));
Again, no need to warn, no one will see it :)
I am trying to make it so that debugfs doesn't return anything for when a file is created. Now if that will ever be possible or not, I don't know, but I am pretty close in one of the branches in my driver-core tree...
thanks,
greg k-h
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: dapm: Adapt for debugfs API change
Quoted 9 lines · Greg KH
sound/soc/soc-dapm.c void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, · line 2160
Quoted 5 lines · Mark Brown
sound/soc/soc-dapm.c +1
-1struct dentry *d; -if (!parent) +if (!parent ||IS_ERR (parent))return ;How can parent be NULL?
It was more effort than it was worth to check to see if it could actually be NULL through default initialization or something and fix it than just not delete the check so I just left it there. I'll probably go back and clean it up more thorougly at some point.
Quoted 4 lines
I am trying to make it so that debugfs doesn't return anything for when a file is created. Now if that will ever be possible or not, I don't know, but I am pretty close in one of the branches in my driver-core tree...
You mentioned this in a mail last week, I then replied pointing out that this is not helpful as it reduces the robustness and quality of our debugging tools and you then did not respond. This is a view I still hold and in any case debugfs as it stands (and was in the kernel versions since this was broken) is still capable of reporting errors so we should fix that.
Re: [PATCH 2/2] ASoC: dapm: Adapt for debugfs API change
Quoted 16 lines · Mark Brown
Quoted 9 lines · Greg KH
sound/soc/soc-dapm.c void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, · line 2160
Quoted 5 lines · Mark Brown
sound/soc/soc-dapm.c +1
-1struct dentry *d; -if (!parent) +if (!parent ||IS_ERR (parent))return ;How can parent be NULL?
It was more effort than it was worth to check to see if it could actually be NULL through default initialization or something and fix it than just not delete the check so I just left it there. I'll probably go back and clean it up more thorougly at some point.
Quoted 8 lines
Quoted 4 lines
I am trying to make it so that debugfs doesn't return anything for when a file is created. Now if that will ever be possible or not, I don't know, but I am pretty close in one of the branches in my driver-core tree...
You mentioned this in a mail last week, I then replied pointing out that this is not helpful as it reduces the robustness and quality of our debugging tools and you then did not respond.
Sorry, had lots of other stuff to work on, it's in my queue to respond to still...
Quoted 3 lines
This is a view I still hold and in any case debugfs as it stands (and was in the kernel versions since this was broken) is still capable of reporting errors so we should fix that.
Sort story is, I am trying to change it so that it can not report errors :)
And even then, no kernel code should be doing anything different if debugfs calls fail or not, that is why I am I making these changes. No "real" code should ever be affected, and right now, it is, if something goes wrong with debugfs.
So removing those checks is the goal here. Your driver code should not care if debugfs is working at all or not.
thanks,
greg k-h
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: dapm: Adapt for debugfs API change
Quoted 8 lines · Greg KH
Quoted 5 lines · Mark Brown
On Fri, Jun 21, 2019 at 03:22:22PM +0200, Greg KH wrote:
This is a view I still hold and in any case debugfs as it stands (and was in the kernel versions since this was broken) is still capable of reporting errors so we should fix that.
Sort story is, I am trying to change it so that it can not report errors :)
Yes, I know. This is what I think is a bad idea.
Quoted 7 lines
And even then, no kernel code should be doing anything different if debugfs calls fail or not, that is why I am I making these changes. No "real" code should ever be affected, and right now, it is, if something goes wrong with debugfs.
So removing those checks is the goal here. Your driver code should not care if debugfs is working at all or not.
None of which addresses the issue which is that we should be telling users who are trying to use debugfs to debug things that something went wrong rather than silently failing and potentially confusing them with corrupted data display. This isn't something you can address through API restrictions without hurting users unless you are prepared to add user visible error reporting to the debugfs core.
The conditional code here beyond printing errors only affects the creation of further debugfs files, it's just there to avoid spewing secondary errors at people when something goes wrong so the underlying problem is clearer and is entirely compatible with the idea of not affecting real code.
Mark Brown
maintainerApplied "ASoC: dapm: Adapt for debugfs API change" to the asoc tree
In reply to Mark BrownThe patch
ASoC: dapm: Adapt for debugfs API change
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.2
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
ceaea851b9ea75f9ea2bbefb53ff0d4b27cd5a6eMon Sep 17 00:00:00 2001
From: Mark Brown <[email protected]>
Date: Fri, 21 Jun 2019 12:33:57 +0100
Subject: [PATCH] ASoC: dapm: Adapt for debugfs API change
Back in ff9fb72bc07705c (debugfs: return error values, not NULL) the debugfs APIs were changed to return error pointers rather than NULL pointers on error, breaking the error checking in ASoC. Update the code to use IS_ERR() and log the codes that are returned as part of the error messages.
--- sound/soc/soc-dapm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
sound/soc/soc-dapm.c +10 -8
@@ -2154,23 +2154,25 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, {struct dentry *d; -if (!parent) +if (!parent ||IS_ERR (parent))return ; dapm->debugfs_dapm =debugfs_create_dir ("dapm" , parent); -if (!dapm->debugfs_dapm) { +if (IS_ERR (dapm->debugfs_dapm)) {dev_warn (dapm->dev, -"ASoC: Failed to create DAPM debugfs directory\n" ); +"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 (!d) +if (IS_ERR (d))dev_warn (dapm->dev, -"ASoC: Failed to create bias level debugfs file\n" ); +"ASoC: Failed to create bias level debugfs file: %ld\n" , +PTR_ERR (d)); }static void dapm_debugfs_add_widget (struct snd_soc_dapm_widget *w)
@@ -2184,10 +2186,10 @@ static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) d =debugfs_create_file (w->name,0444 , dapm->debugfs_dapm, w, &dapm_widget_power_fops); -if (!d) +if (IS_ERR (d))dev_warn (w->dapm->dev, -"ASoC: Failed to create %s debugfs file\n" , - w->name); +"ASoC: Failed to create %s debugfs file: %ld\n" , + w->name,PTR_ERR (d)); }static void dapm_debugfs_cleanup (struct snd_soc_dapm_context *dapm)
Signature · 1 line
2.20.1
Quoted 18 lines · Mark Brown
Back in
ff9fb72bc07705c(debugfs: return error values, not NULL) the debugfs APIs were changed to return error pointers rather than NULL pointers on error, breaking the error checking in ASoC. Update the code to useIS_ERR()and log the codes that are returned as part of the error messages.Fixes ff9fb72bc07705c (debugfs: return error values, not NULL)Signed-off-by Mark Brown <[email protected]>--- sound/soc/soc-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)sound/soc/soc-core.c +0
-0
sound/soc/soc-core.c static void soc_init_component_debugfs(struct snd_soc_component *component) · line 171
Quoted 9 lines
sound/soc/soc-core.c +3
-2@@ -165,9 +165,10 @@ static void soc_init_component_debugfs(struct snd_soc_component *component) component->card->debugfs_card_root); } -if (!component->debugfs_root) { +if (IS_ERR (component->debugfs_root)) {dev_warn (component->dev, -"ASoC: Failed to create component debugfs directory\n" ); +"ASoC: Failed to create component debugfs directory: %ld\n" , +PTR_ERR (component->debugfs_root));
Why warn on this? You will _never_ see this message :)
Quoted 4 lines
sound/soc/soc-core.c +0
-0return ; }
sound/soc/soc-core.c static void soc_init_card_debugfs(struct snd_soc_card *card) · line 227
Quoted 10 lines
sound/soc/soc-core.c +4
-2@@ -219,18 +220,21 @@ static void soc_init_card_debugfs(struct snd_soc_card *card) card->debugfs_card_root =debugfs_create_dir (card->name, snd_soc_debugfs_root); -if (!card->debugfs_card_root) { +if (IS_ERR (card->debugfs_card_root)) {dev_warn (card->dev, -"ASoC: Failed to create card debugfs directory\n" ); +"ASoC: Failed to create card debugfs directory: %ld\n" , +PTR_ERR (card->debugfs_card_root)); + card->debugfs_card_root =NULL ;
Same here.
And keep card->debugfs_card_root to be the error pointer, that way no further files are created for that directory.
thanks,
greg k-h
Mark Brown
maintainerApplied "ASoC: core: Adapt for debugfs API change" to the asoc tree
In reply to Mark BrownThe patch
ASoC: core: Adapt for debugfs API change
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.2
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
c2c928c93173f220955030e8440517b87ec7df92Mon Sep 17 00:00:00 2001
From: Mark Brown <[email protected]>
Date: Fri, 21 Jun 2019 12:33:56 +0100
Subject: [PATCH] ASoC: core: Adapt for debugfs API change
Back in ff9fb72bc07705c (debugfs: return error values, not NULL) the debugfs APIs were changed to return error pointers rather than NULL pointers on error, breaking the error checking in ASoC. Update the code to use IS_ERR() and log the codes that are returned as part of the error messages.
--- sound/soc/soc-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/soc/soc-core.c +10 -6
@@ -158,9 +158,10 @@ static void soc_init_component_debugfs(struct snd_soc_component *component) component->card->debugfs_card_root); } -if (!component->debugfs_root) { +if (IS_ERR (component->debugfs_root)) {dev_warn (component->dev, -"ASoC: Failed to create component debugfs directory\n" ); +"ASoC: Failed to create component debugfs directory: %ld\n" , +PTR_ERR (component->debugfs_root));return ; }
@@ -212,18 +213,21 @@ static void soc_init_card_debugfs(struct snd_soc_card *card) card->debugfs_card_root =debugfs_create_dir (card->name, snd_soc_debugfs_root); -if (!card->debugfs_card_root) { +if (IS_ERR (card->debugfs_card_root)) {dev_warn (card->dev, -"ASoC: Failed to create card debugfs directory\n" ); +"ASoC: Failed to create card debugfs directory: %ld\n" , +PTR_ERR (card->debugfs_card_root)); + card->debugfs_card_root =NULL ;return ; } card->debugfs_pop_time =debugfs_create_u32 ("dapm_pop_time" ,0644 , card->debugfs_card_root, &card->pop_time); -if (!card->debugfs_pop_time) +if (IS_ERR (card->debugfs_pop_time))dev_warn (card->dev, -"ASoC: Failed to create pop time debugfs file\n" ); +"ASoC: Failed to create pop time debugfs file: %ld\n" , +PTR_ERR (card->debugfs_pop_time)); }static void soc_cleanup_card_debugfs (struct snd_soc_card *card)
Signature · 1 line
2.20.1