[PATCH] lvts_thermal.c: Drop error checking for debugfs_create_dir

From: Osama Muhammad
Date: Tue May 30 2023 - 13:26:41 EST


This patch removes the error checking for debugfs_create_dir
in lvts_thermal.c. This is because the debugfs_create_dir()
does not return NULL but an ERR_PTR after an error.
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 Api handles
it gracefully. The check is unnecessary.

Link to the comment above debugfs_create_dir:
https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451

Signed-off-by: Osama Muhammad <osmtendev@xxxxxxxxx>
---
drivers/thermal/mediatek/lvts_thermal.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index d0a3f95b7884..da5e3652ff3b 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -179,7 +179,7 @@ static const struct debugfs_reg32 lvts_regs[] = {
LVTS_DEBUG_FS_REGS(LVTS_CLKEN),
};

-static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
+static void lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
{
struct debugfs_regset32 *regset;
struct lvts_ctrl *lvts_ctrl;
@@ -188,8 +188,6 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
int i;

lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL);
- if (!lvts_td->dom_dentry)
- return 0;

for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {

@@ -197,8 +195,6 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)

sprintf(name, "controller%d", i);
dentry = debugfs_create_dir(name, lvts_td->dom_dentry);
- if (!dentry)
- continue;

regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
if (!regset)
@@ -211,7 +207,6 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
debugfs_create_regset32("registers", 0400, dentry, regset);
}

- return 0;
}

static void lvts_debugfs_exit(struct lvts_domain *lvts_td)
@@ -221,10 +216,9 @@ static void lvts_debugfs_exit(struct lvts_domain *lvts_td)

#else

-static inline int lvts_debugfs_init(struct device *dev,
+static inline void lvts_debugfs_init(struct device *dev,
struct lvts_domain *lvts_td)
{
- return 0;
}

static void lvts_debugfs_exit(struct lvts_domain *lvts_td) { }
@@ -1099,7 +1093,8 @@ static int lvts_domain_init(struct device *dev, struct lvts_domain *lvts_td,
}
}

- return lvts_debugfs_init(dev, lvts_td);
+ lvts_debugfs_init(dev, lvts_td);
+ return 0;
}

static int lvts_probe(struct platform_device *pdev)
--
2.34.1