From: Osama Muhammad <osmtendev@gmail.com>
To: rafael@kernel.org, daniel.lezcano@linaro.org,
rui.zhang@intel.com, angelogioacchino.delregno@collabora.com,
DLG-Adam.Ward.opensource@dm.renesas.com, amitk@kernel.org,
wenst@chromium.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Osama Muhammad <osmtendev@gmail.com>
Subject: [PATCH] lvts_thermal.c: Drop error checking for debugfs_create_dir
Date: Tue, 30 May 2023 22:24:39 +0500 [thread overview]
Message-ID: <20230530172439.13683-1-osmtendev@gmail.com> (raw)
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
next reply other threads:[~2023-05-30 17:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 17:24 Osama Muhammad [this message]
2023-06-13 8:40 ` [PATCH] lvts_thermal.c: Drop error checking for debugfs_create_dir Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230530172439.13683-1-osmtendev@gmail.com \
--to=osmtendev@gmail.com \
--cc=DLG-Adam.Ward.opensource@dm.renesas.com \
--cc=amitk@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=wenst@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).