mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-arm-kernel@lists.infradead.org,
	Andrew Lunn <andrew@lunn.ch>,
	Gregory Clement <gregory.clement@bootlin.com>,
	Russell King <linux@armlinux.org.uk>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Subject: [PATCH 2/2] ARM: mvebu: Use common of_node_put() code in mvebu_pm_suspend_init()
Date: Wed, 2 Oct 2024 19:52:18 +0200	[thread overview]
Message-ID: <49260a2e-a510-4d44-8644-38863abb16c1@web.de> (raw)
In-Reply-To: <ac69dd2e-b4e4-4f70-b6c4-476b92160270@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 2 Oct 2024 19:15:09 +0200

Add a local variable “rc” and a label so that a bit of exception handling
can be better reused at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/mach-mvebu/pm.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c
index b149d9b77505..cd85f2c56836 100644
--- a/arch/arm/mach-mvebu/pm.c
+++ b/arch/arm/mach-mvebu/pm.c
@@ -235,6 +235,7 @@ int __init mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg,
 {
 	struct device_node *np;
 	struct resource res;
+	int rc;

 	np = of_find_compatible_node(NULL, NULL,
 				     "marvell,armada-xp-sdram-controller");
@@ -242,26 +243,26 @@ int __init mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg,
 		return -ENODEV;

 	if (of_address_to_resource(np, 0, &res)) {
-		of_node_put(np);
-		return -ENODEV;
+		rc = -ENODEV;
+		goto put_node;
 	}

 	if (!request_mem_region(res.start, resource_size(&res),
 				np->full_name)) {
-		of_node_put(np);
-		return -EBUSY;
+		rc = -EBUSY;
+		goto put_node;
 	}

 	sdram_ctrl = ioremap(res.start, resource_size(&res));
 	if (!sdram_ctrl) {
 		release_mem_region(res.start, resource_size(&res));
-		of_node_put(np);
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto put_node;
 	}

-	of_node_put(np);
-
 	mvebu_board_pm_enter = board_pm_enter;
-
-	return 0;
+	rc = 0;
+put_node:
+	of_node_put(np);
+	return rc;
 }
--
2.46.1


      parent reply	other threads:[~2024-10-02 17:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 17:48 [PATCH 0/2] ARM: mvebu: Adjustments for common code in two functions Markus Elfring
2024-10-02 17:50 ` [PATCH 1/2] ARM: mvebu: Call of_node_put(cpu_config_np) only once in armada_370_coherency_init() Markus Elfring
2024-10-02 17:52 ` Markus Elfring [this message]

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=49260a2e-a510-4d44-8644-38863abb16c1@web.de \
    --to=markus.elfring@web.de \
    --cc=andrew@lunn.ch \
    --cc=gregory.clement@bootlin.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=thomas.petazzoni@free-electrons.com \
    /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

all inboxes | Powered by JetHome®