linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lvts_thermal.c: Drop error checking for debugfs_create_dir
@ 2023-05-30 17:24 Osama Muhammad
  2023-06-13  8:40 ` Daniel Lezcano
  0 siblings, 1 reply; 2+ messages in thread
From: Osama Muhammad @ 2023-05-30 17:24 UTC (permalink / raw)
  To: rafael, daniel.lezcano, rui.zhang, angelogioacchino.delregno,
	DLG-Adam.Ward.opensource, amitk, wenst
  Cc: linux-pm, linux-kernel, Osama Muhammad

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lvts_thermal.c: Drop error checking for debugfs_create_dir
  2023-05-30 17:24 [PATCH] lvts_thermal.c: Drop error checking for debugfs_create_dir Osama Muhammad
@ 2023-06-13  8:40 ` Daniel Lezcano
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Lezcano @ 2023-06-13  8:40 UTC (permalink / raw)
  To: Osama Muhammad, rafael, rui.zhang, angelogioacchino.delregno,
	DLG-Adam.Ward.opensource, amitk, wenst
  Cc: linux-pm, linux-kernel

On 30/05/2023 19:24, Osama Muhammad wrote:
> 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@gmail.com>

Is this patch tested ?



-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-13  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 17:24 [PATCH] lvts_thermal.c: Drop error checking for debugfs_create_dir Osama Muhammad
2023-06-13  8:40 ` Daniel Lezcano

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).