linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] omap-iommu: no need to check return value of debugfs_create functions
@ 2019-07-04 14:36 Greg Kroah-Hartman
  2019-07-04 15:35 ` Joerg Roedel
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-07-04 14:36 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel

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.

Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Warning, not even test-built, but "should" work :)

 drivers/iommu/omap-iommu-debug.c | 35 ++++++--------------------------
 1 file changed, 6 insertions(+), 29 deletions(-)

diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index 4abc0ef522a8..cea851702f54 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -239,17 +239,6 @@ DEBUG_FOPS_RO(regs);
 DEFINE_SHOW_ATTRIBUTE(tlb);
 DEFINE_SHOW_ATTRIBUTE(pagetable);
 
-#define __DEBUG_ADD_FILE(attr, mode)					\
-	{								\
-		struct dentry *dent;					\
-		dent = debugfs_create_file(#attr, mode, obj->debug_dir,	\
-					   obj, &attr##_fops);	        \
-		if (!dent)						\
-			goto err;					\
-	}
-
-#define DEBUG_ADD_FILE_RO(name) __DEBUG_ADD_FILE(name, 0400)
-
 void omap_iommu_debugfs_add(struct omap_iommu *obj)
 {
 	struct dentry *d;
@@ -257,23 +246,13 @@ void omap_iommu_debugfs_add(struct omap_iommu *obj)
 	if (!iommu_debug_root)
 		return;
 
-	obj->debug_dir = debugfs_create_dir(obj->name, iommu_debug_root);
-	if (!obj->debug_dir)
-		return;
+	d = debugfs_create_dir(obj->name, iommu_debug_root);
+	obj->debug_dir = d;
 
-	d = debugfs_create_u32("nr_tlb_entries", 0400, obj->debug_dir,
-			       &obj->nr_tlb_entries);
-	if (!d)
-		return;
-
-	DEBUG_ADD_FILE_RO(regs);
-	DEBUG_ADD_FILE_RO(tlb);
-	DEBUG_ADD_FILE_RO(pagetable);
-
-	return;
-
-err:
-	debugfs_remove_recursive(obj->debug_dir);
+	debugfs_create_u32("nr_tlb_entries", 0400, d, &obj->nr_tlb_entries);
+	debugfs_create_file("regs", 0400, d, obj, &attrregs_fops);
+	debugfs_create_file("tlb", 0400, d, obj, &attrtlb_fops);
+	debugfs_create_file("pagetable", 0400, d, obj, &attrpagetable_fops);
 }
 
 void omap_iommu_debugfs_remove(struct omap_iommu *obj)
@@ -287,8 +266,6 @@ void omap_iommu_debugfs_remove(struct omap_iommu *obj)
 void __init omap_iommu_debugfs_init(void)
 {
 	iommu_debug_root = debugfs_create_dir("omap_iommu", NULL);
-	if (!iommu_debug_root)
-		pr_err("can't create debugfs dir\n");
 }
 
 void __exit omap_iommu_debugfs_exit(void)
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] omap-iommu: no need to check return value of debugfs_create functions
  2019-07-04 14:36 [PATCH] omap-iommu: no need to check return value of debugfs_create functions Greg Kroah-Hartman
@ 2019-07-04 15:35 ` Joerg Roedel
  2019-07-05  5:24   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2019-07-04 15:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: iommu, linux-kernel

On Thu, Jul 04, 2019 at 04:36:49PM +0200, Greg Kroah-Hartman wrote:
> 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.
> 
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: iommu@lists.linux-foundation.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Warning, not even test-built, but "should" work :)

It almost did :)

> +	debugfs_create_file("regs", 0400, d, obj, &attrregs_fops);
> +	debugfs_create_file("tlb", 0400, d, obj, &attrtlb_fops);
> +	debugfs_create_file("pagetable", 0400, d, obj, &attrpagetable_fops);

The _fops were named without the 'attr' prefix, changed that and it
compiled. Patch is now applied.

Thanks,

	Joerg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] omap-iommu: no need to check return value of debugfs_create functions
  2019-07-04 15:35 ` Joerg Roedel
@ 2019-07-05  5:24   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-07-05  5:24 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel

On Thu, Jul 04, 2019 at 05:35:52PM +0200, Joerg Roedel wrote:
> On Thu, Jul 04, 2019 at 04:36:49PM +0200, Greg Kroah-Hartman wrote:
> > 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.
> > 
> > Cc: Joerg Roedel <joro@8bytes.org>
> > Cc: iommu@lists.linux-foundation.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > Warning, not even test-built, but "should" work :)
> 
> It almost did :)
> 
> > +	debugfs_create_file("regs", 0400, d, obj, &attrregs_fops);
> > +	debugfs_create_file("tlb", 0400, d, obj, &attrtlb_fops);
> > +	debugfs_create_file("pagetable", 0400, d, obj, &attrpagetable_fops);
> 
> The _fops were named without the 'attr' prefix, changed that and it
> compiled. Patch is now applied.

Ah, so close :)

Thanks for fixing it up and applying it!

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-05  5:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04 14:36 [PATCH] omap-iommu: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-07-04 15:35 ` Joerg Roedel
2019-07-05  5:24   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).