From: Abhinav Jain <jain.abhinav177@gmail.com>
To: chris.packham@alliedtelesis.co.nz, andi.shyti@kernel.org,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com,
Abhinav Jain <jain.abhinav177@gmail.com>,
Julia Lawall <julia.lawall@inria.fr>
Subject: [PATCH] i2c: mpc: Removal of of_node_put with __free for auto cleanup
Date: Mon, 15 Apr 2024 16:12:20 +0000 [thread overview]
Message-ID: <20240415161220.8347-1-jain.abhinav177@gmail.com> (raw)
Remove of_node_put from node_ctrl and node struct device_nodes.
Move the declaration to initialization for ensuring scope sanity.
Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
---
drivers/i2c/busses/i2c-mpc.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 8d73c0f405ed..c4223556b3b8 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -304,13 +304,12 @@ static void mpc_i2c_setup_512x(struct device_node *node,
struct mpc_i2c *i2c,
u32 clock)
{
- struct device_node *node_ctrl;
void __iomem *ctrl;
u32 idx;
/* Enable I2C interrupts for mpc5121 */
- node_ctrl = of_find_compatible_node(NULL, NULL,
- "fsl,mpc5121-i2c-ctrl");
+ struct device_node *node_ctrl __free(device_node) =
+ of_find_compatible_node(NULL, NULL, "fsl,mpc5121-i2c-ctrl");
if (node_ctrl) {
ctrl = of_iomap(node_ctrl, 0);
if (ctrl) {
@@ -321,7 +320,6 @@ static void mpc_i2c_setup_512x(struct device_node *node,
setbits32(ctrl, 1 << (24 + idx * 2));
iounmap(ctrl);
}
- of_node_put(node_ctrl);
}
/* The clock setup for the 52xx works also fine for the 512x */
@@ -358,11 +356,11 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
static u32 mpc_i2c_get_sec_cfg_8xxx(void)
{
- struct device_node *node;
u32 __iomem *reg;
u32 val = 0;
- node = of_find_node_by_name(NULL, "global-utilities");
+ struct device_node *node __free(device_node) =
+ of_find_node_by_name(NULL, "global-utilities");
if (node) {
const u32 *prop = of_get_property(node, "reg", NULL);
if (prop) {
@@ -383,7 +381,6 @@ static u32 mpc_i2c_get_sec_cfg_8xxx(void)
iounmap(reg);
}
}
- of_node_put(node);
return val;
}
--
2.34.1
next reply other threads:[~2024-04-15 16:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 16:12 Abhinav Jain [this message]
2024-04-15 20:54 ` [PATCH] i2c: mpc: Removal of of_node_put with __free for auto cleanup Andi Shyti
2024-04-16 3:59 ` Chris Packham
2024-04-16 14:07 ` Andi Shyti
2024-04-16 14:09 ` Andi Shyti
2024-04-19 7:22 ` Michael Ellerman
2024-04-16 4:00 ` Chris Packham
2024-04-16 22:46 ` Andi Shyti
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=20240415161220.8347-1-jain.abhinav177@gmail.com \
--to=jain.abhinav177@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=javier.carrasco.cruz@gmail.com \
--cc=julia.lawall@inria.fr \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.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 read-only IMAP folder(s) and NNTP newsgroup(s).