Skip to content

Commit

Permalink
phy: realtek: usb: Drop unnecessary error check for debugfs_create_dir()
Browse files Browse the repository at this point in the history
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: 134e6d2 ("phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY")
Fixes: adda6e8 ("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>
Link: https://lore.kernel.org/r/20230901075231.1368947-1-ruanjinjie@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
  • Loading branch information
Jinjie Ruan authored and Vinod Koul committed Sep 21, 2023
1 parent 426e05c commit 6ee8a9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
10 changes: 2 additions & 8 deletions drivers/phy/realtek/phy-rtk-usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions drivers/phy/realtek/phy-rtk-usb3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6ee8a9a

Please sign in to comment.