* [PATCH] iommu/tegra-smmu: fix error checking for debugfs_create_dir()
@ 2023-10-25 11:01 Dario Binacchi
2023-10-25 11:25 ` Baolu Lu
0 siblings, 1 reply; 4+ messages in thread
From: Dario Binacchi @ 2023-10-25 11:01 UTC (permalink / raw)
To: linux-kernel
Cc: Dario Binacchi, Joerg Roedel, Jonathan Hunter, Krishna Reddy,
Robin Murphy, Thierry Reding, Will Deacon, iommu, linux-tegra
The return value of debugfs_create_dir() should be checked using the
IS_ERR() function.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
drivers/iommu/tegra-smmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index e445f80d0226..cd1d80c4c673 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
{
smmu->debugfs = debugfs_create_dir("smmu", NULL);
- if (!smmu->debugfs)
+ if (IS_ERR(smmu->debugfs))
return;
debugfs_create_file("swgroups", S_IRUGO, smmu->debugfs, smmu,
--
2.42.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/tegra-smmu: fix error checking for debugfs_create_dir()
2023-10-25 11:01 [PATCH] iommu/tegra-smmu: fix error checking for debugfs_create_dir() Dario Binacchi
@ 2023-10-25 11:25 ` Baolu Lu
2023-10-30 15:30 ` Thierry Reding
0 siblings, 1 reply; 4+ messages in thread
From: Baolu Lu @ 2023-10-25 11:25 UTC (permalink / raw)
To: Dario Binacchi, linux-kernel
Cc: baolu.lu, Joerg Roedel, Jonathan Hunter, Krishna Reddy,
Robin Murphy, Thierry Reding, Will Deacon, iommu, linux-tegra
On 2023/10/25 19:01, Dario Binacchi wrote:
> The return value of debugfs_create_dir() should be checked using the
> IS_ERR() function.
>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> ---
>
> drivers/iommu/tegra-smmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index e445f80d0226..cd1d80c4c673 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
> static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
> {
> smmu->debugfs = debugfs_create_dir("smmu", NULL);
> - if (!smmu->debugfs)
> + if (IS_ERR(smmu->debugfs))
> return;
This check can be removed, as debugfs_create_file() can handle the case
where @parent is an error pointer.
>
> debugfs_create_file("swgroups", S_IRUGO, smmu->debugfs, smmu,
Best regards,
baolu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/tegra-smmu: fix error checking for debugfs_create_dir()
2023-10-25 11:25 ` Baolu Lu
@ 2023-10-30 15:30 ` Thierry Reding
2023-10-31 7:54 ` Dario Binacchi
0 siblings, 1 reply; 4+ messages in thread
From: Thierry Reding @ 2023-10-30 15:30 UTC (permalink / raw)
To: Baolu Lu
Cc: Dario Binacchi, linux-kernel, Joerg Roedel, Jonathan Hunter,
Krishna Reddy, Robin Murphy, Will Deacon, iommu, linux-tegra
[-- Attachment #1: Type: text/plain, Size: 2217 bytes --]
On Wed, Oct 25, 2023 at 07:25:50PM +0800, Baolu Lu wrote:
> On 2023/10/25 19:01, Dario Binacchi wrote:
> > The return value of debugfs_create_dir() should be checked using the
> > IS_ERR() function.
> >
> > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> > ---
> >
> > drivers/iommu/tegra-smmu.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> > index e445f80d0226..cd1d80c4c673 100644
> > --- a/drivers/iommu/tegra-smmu.c
> > +++ b/drivers/iommu/tegra-smmu.c
> > @@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
> > static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
> > {
> > smmu->debugfs = debugfs_create_dir("smmu", NULL);
> > - if (!smmu->debugfs)
> > + if (IS_ERR(smmu->debugfs))
> > return;
>
> This check can be removed, as debugfs_create_file() can handle the case
> where @parent is an error pointer.
A patch for this has been in linux-next for a few weeks, see:
commit f7da9c081517daba70f9f9342e09d7a6322ba323
Author: Jinjie Ruan <ruanjinjie@huawei.com>
Date: Fri Sep 1 15:30:56 2023 +0800
iommu/tegra-smmu: Drop unnecessary error check for for debugfs_create_dir()
The debugfs_create_dir() function returns error pointers.
It never returns NULL.
As Baolu suggested, this patch removes the error checking for
debugfs_create_dir in tegra-smmu.c. This is because the DebugFS kernel API
is developed in a way that the caller can safely ignore the errors that
occur during the creation of DebugFS nodes. The debugfs APIs have
a IS_ERR() judge in start_creating() which can handle it gracefully. So
these checks are unnecessary.
Fixes: d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Suggested-by: Baolu Lu <baolu.lu@linux.intel.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20230901073056.1364755-1-ruanjinjie@huawei.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/tegra-smmu: fix error checking for debugfs_create_dir()
2023-10-30 15:30 ` Thierry Reding
@ 2023-10-31 7:54 ` Dario Binacchi
0 siblings, 0 replies; 4+ messages in thread
From: Dario Binacchi @ 2023-10-31 7:54 UTC (permalink / raw)
To: Thierry Reding
Cc: Baolu Lu, linux-kernel, Joerg Roedel, Jonathan Hunter,
Krishna Reddy, Robin Murphy, Will Deacon, iommu, linux-tegra
Hello Thierry,
On Mon, Oct 30, 2023 at 4:30 PM Thierry Reding <thierry.reding@gmail.com> wrote:
>
> On Wed, Oct 25, 2023 at 07:25:50PM +0800, Baolu Lu wrote:
> > On 2023/10/25 19:01, Dario Binacchi wrote:
> > > The return value of debugfs_create_dir() should be checked using the
> > > IS_ERR() function.
> > >
> > > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> > > ---
> > >
> > > drivers/iommu/tegra-smmu.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> > > index e445f80d0226..cd1d80c4c673 100644
> > > --- a/drivers/iommu/tegra-smmu.c
> > > +++ b/drivers/iommu/tegra-smmu.c
> > > @@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
> > > static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
> > > {
> > > smmu->debugfs = debugfs_create_dir("smmu", NULL);
> > > - if (!smmu->debugfs)
> > > + if (IS_ERR(smmu->debugfs))
> > > return;
> >
> > This check can be removed, as debugfs_create_file() can handle the case
> > where @parent is an error pointer.
>
> A patch for this has been in linux-next for a few weeks, see:
>
> commit f7da9c081517daba70f9f9342e09d7a6322ba323
> Author: Jinjie Ruan <ruanjinjie@huawei.com>
> Date: Fri Sep 1 15:30:56 2023 +0800
>
> iommu/tegra-smmu: Drop unnecessary error check for for debugfs_create_dir()
>
> The debugfs_create_dir() function returns error pointers.
> It never returns NULL.
>
> As Baolu suggested, this patch removes the error checking for
> debugfs_create_dir in tegra-smmu.c. This is because the DebugFS kernel API
> is developed in a way that the caller can safely ignore the errors that
> occur during the creation of DebugFS nodes. The debugfs APIs have
> a IS_ERR() judge in start_creating() which can handle it gracefully. So
> these checks are unnecessary.
>
> Fixes: d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Suggested-by: Baolu Lu <baolu.lu@linux.intel.com>
> Acked-by: Thierry Reding <treding@nvidia.com>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Link: https://lore.kernel.org/r/20230901073056.1364755-1-ruanjinjie@huawei.com
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
>
Thanks for the explanation,
regards
Dario
> Thierry
--
Dario Binacchi
Senior Embedded Linux Developer
dario.binacchi@amarulasolutions.com
__________________________________
Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
info@amarulasolutions.com
www.amarulasolutions.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-31 7:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25 11:01 [PATCH] iommu/tegra-smmu: fix error checking for debugfs_create_dir() Dario Binacchi
2023-10-25 11:25 ` Baolu Lu
2023-10-30 15:30 ` Thierry Reding
2023-10-31 7:54 ` Dario Binacchi
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®