linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-pool: no need to check return value of debugfs_create functions
@ 2020-11-07 10:03 Tiezhu Yang
  2020-11-09 11:43 ` Robin Murphy
  2020-11-14 12:10 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Tiezhu Yang @ 2020-11-07 10:03 UTC (permalink / raw)
  To: Christoph Hellwig, Marek Szyprowski, Robin Murphy
  Cc: iommu, linux-kernel, Xuefeng Li

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.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 kernel/dma/pool.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
index d4637f7..5f84e6c 100644
--- a/kernel/dma/pool.c
+++ b/kernel/dma/pool.c
@@ -38,9 +38,6 @@ static void __init dma_atomic_pool_debugfs_init(void)
 	struct dentry *root;
 
 	root = debugfs_create_dir("dma_pools", NULL);
-	if (IS_ERR_OR_NULL(root))
-		return;
-
 	debugfs_create_ulong("pool_size_dma", 0400, root, &pool_size_dma);
 	debugfs_create_ulong("pool_size_dma32", 0400, root, &pool_size_dma32);
 	debugfs_create_ulong("pool_size_kernel", 0400, root, &pool_size_kernel);
-- 
2.1.0


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

* Re: [PATCH] dma-pool: no need to check return value of debugfs_create functions
  2020-11-07 10:03 [PATCH] dma-pool: no need to check return value of debugfs_create functions Tiezhu Yang
@ 2020-11-09 11:43 ` Robin Murphy
  2020-11-14 12:10 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2020-11-09 11:43 UTC (permalink / raw)
  To: Tiezhu Yang, Christoph Hellwig, Marek Szyprowski
  Cc: iommu, linux-kernel, Xuefeng Li

On 2020-11-07 10:03, Tiezhu Yang 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.

Well, the only difference in behaviour is that it won't attempt to call 
further debugfs functions if they're definitely going to fail anyway, so 
no "real" logic is affected. AFAICS it's not possible for 
debugfs_create_dir() to return NULL, so this check makes no practical 
difference, just means that if it did ever fail we would save a bit of 
unnecessary work by not subsequently calling all the way down to the "if 
(IS_ERR(parent))" check in start_creating() several times.

So the given justification is a little overdramatic for this particular 
situation, when it's really just that it's not worth optimising an 
unexpected failure case, but the change itself is obviously fine.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>   kernel/dma/pool.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
> index d4637f7..5f84e6c 100644
> --- a/kernel/dma/pool.c
> +++ b/kernel/dma/pool.c
> @@ -38,9 +38,6 @@ static void __init dma_atomic_pool_debugfs_init(void)
>   	struct dentry *root;
>   
>   	root = debugfs_create_dir("dma_pools", NULL);
> -	if (IS_ERR_OR_NULL(root))
> -		return;
> -
>   	debugfs_create_ulong("pool_size_dma", 0400, root, &pool_size_dma);
>   	debugfs_create_ulong("pool_size_dma32", 0400, root, &pool_size_dma32);
>   	debugfs_create_ulong("pool_size_kernel", 0400, root, &pool_size_kernel);
> 

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

* Re: [PATCH] dma-pool: no need to check return value of debugfs_create functions
  2020-11-07 10:03 [PATCH] dma-pool: no need to check return value of debugfs_create functions Tiezhu Yang
  2020-11-09 11:43 ` Robin Murphy
@ 2020-11-14 12:10 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-11-14 12:10 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, iommu,
	linux-kernel, Xuefeng Li

Thanks,

applied.

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

end of thread, other threads:[~2020-11-14 12:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-07 10:03 [PATCH] dma-pool: no need to check return value of debugfs_create functions Tiezhu Yang
2020-11-09 11:43 ` Robin Murphy
2020-11-14 12:10 ` Christoph Hellwig

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).