From: Robin Murphy <robin.murphy@arm.com>
To: Tiezhu Yang <yangtiezhu@loongson.cn>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
Xuefeng Li <lixuefeng@loongson.cn>
Subject: Re: [PATCH] dma-pool: no need to check return value of debugfs_create functions
Date: Mon, 9 Nov 2020 11:43:25 +0000 [thread overview]
Message-ID: <936ffd36-8814-a8d2-ab94-3edc0642e5a7@arm.com> (raw)
In-Reply-To: <1604743392-21601-1-git-send-email-yangtiezhu@loongson.cn>
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);
>
next prev parent reply other threads:[~2020-11-09 11:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-07 10:03 Tiezhu Yang
2020-11-09 11:43 ` Robin Murphy [this message]
2020-11-14 12:10 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=936ffd36-8814-a8d2-ab94-3edc0642e5a7@arm.com \
--to=robin.murphy@arm.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=m.szyprowski@samsung.com \
--cc=yangtiezhu@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®