* [PATCH -next v2] phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir()
@ 2023-09-01 7:52 Jinjie Ruan
2023-09-01 8:25 ` Greg Kroah-Hartman
2023-09-21 14:26 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Jinjie Ruan @ 2023-09-01 7:52 UTC (permalink / raw)
To: linux-phy, Vinod Koul, Kishon Vijay Abraham I, Greg Kroah-Hartman,
Stanley Chang
Cc: ruanjinjie
Both debugfs_create_dir() and debugfs_create_file() return ERR_PTR
and never return NULL.
As Greg suggested, this patch removes the error checking for
debugfs_create_dir in phy-rtk-usb2.c and phy-rtk-usb3.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: 134e6d25f6bd ("phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY")
Fixes: adda6e82a7de ("phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2:
- Remove the err check instead of using IS_ERR to replace NULL check.
- Update the commit message and title.
---
drivers/phy/realtek/phy-rtk-usb2.c | 10 ++--------
drivers/phy/realtek/phy-rtk-usb3.c | 10 ++--------
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-rtk-usb2.c
index 5e7ee060b404..aedc78bd37f7 100644
--- a/drivers/phy/realtek/phy-rtk-usb2.c
+++ b/drivers/phy/realtek/phy-rtk-usb2.c
@@ -853,17 +853,11 @@ static inline void create_debug_files(struct rtk_phy *rtk_phy)
rtk_phy->debug_dir = debugfs_create_dir(dev_name(rtk_phy->dev),
phy_debug_root);
- if (!rtk_phy->debug_dir)
- return;
- if (!debugfs_create_file("parameter", 0444, rtk_phy->debug_dir, rtk_phy,
- &rtk_usb2_parameter_fops))
- goto file_error;
+ debugfs_create_file("parameter", 0444, rtk_phy->debug_dir, rtk_phy,
+ &rtk_usb2_parameter_fops);
return;
-
-file_error:
- debugfs_remove_recursive(rtk_phy->debug_dir);
}
static inline void remove_debug_files(struct rtk_phy *rtk_phy)
diff --git a/drivers/phy/realtek/phy-rtk-usb3.c b/drivers/phy/realtek/phy-rtk-usb3.c
index 7881f908aade..dfb3122f3f11 100644
--- a/drivers/phy/realtek/phy-rtk-usb3.c
+++ b/drivers/phy/realtek/phy-rtk-usb3.c
@@ -416,17 +416,11 @@ static inline void create_debug_files(struct rtk_phy *rtk_phy)
return;
rtk_phy->debug_dir = debugfs_create_dir(dev_name(rtk_phy->dev), phy_debug_root);
- if (!rtk_phy->debug_dir)
- return;
- if (!debugfs_create_file("parameter", 0444, rtk_phy->debug_dir, rtk_phy,
- &rtk_usb3_parameter_fops))
- goto file_error;
+ debugfs_create_file("parameter", 0444, rtk_phy->debug_dir, rtk_phy,
+ &rtk_usb3_parameter_fops);
return;
-
-file_error:
- debugfs_remove_recursive(rtk_phy->debug_dir);
}
static inline void remove_debug_files(struct rtk_phy *rtk_phy)
--
2.34.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH -next v2] phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir()
2023-09-01 7:52 [PATCH -next v2] phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir() Jinjie Ruan
@ 2023-09-01 8:25 ` Greg Kroah-Hartman
2023-09-21 14:26 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-09-01 8:25 UTC (permalink / raw)
To: Jinjie Ruan; +Cc: linux-phy, Vinod Koul, Kishon Vijay Abraham I, Stanley Chang
On Fri, Sep 01, 2023 at 03:52:31PM +0800, Jinjie Ruan wrote:
> Both debugfs_create_dir() and debugfs_create_file() return ERR_PTR
> and never return NULL.
>
> As Greg suggested, this patch removes the error checking for
> debugfs_create_dir in phy-rtk-usb2.c and phy-rtk-usb3.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: 134e6d25f6bd ("phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY")
> Fixes: adda6e82a7de ("phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH -next v2] phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir()
2023-09-01 7:52 [PATCH -next v2] phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir() Jinjie Ruan
2023-09-01 8:25 ` Greg Kroah-Hartman
@ 2023-09-21 14:26 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2023-09-21 14:26 UTC (permalink / raw)
To: linux-phy, Kishon Vijay Abraham I, Greg Kroah-Hartman,
Stanley Chang, Jinjie Ruan
On Fri, 01 Sep 2023 15:52:31 +0800, Jinjie Ruan wrote:
> Both debugfs_create_dir() and debugfs_create_file() return ERR_PTR
> and never return NULL.
>
> As Greg suggested, this patch removes the error checking for
> debugfs_create_dir in phy-rtk-usb2.c and phy-rtk-usb3.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.
>
> [...]
Applied, thanks!
[1/1] phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir()
commit: 6ee8a9a772b5abd9a9791123ca7aee2dbf126d5f
Best regards,
--
~Vinod
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-21 14:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-01 7:52 [PATCH -next v2] phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir() Jinjie Ruan
2023-09-01 8:25 ` Greg Kroah-Hartman
2023-09-21 14:26 ` Vinod Koul
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).