From patchwork Wed Oct 2 17:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13820185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88708CEACF3 for ; Wed, 2 Oct 2024 17:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:References:Cc:To:From:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9+tbIUnTt4a/8am5hF5w0MAc7rkV/fOrFs8cjHSvbYI=; b=wndZdG56a70+Ct1spNT+RGmdFY yJScN2qODHi2Vk32SDtvd4mHbDXN9cBlEDel0p6Yxz2ehD0i5yKvuJXiNN+pW4gYlAl5xJRBhZNRt kmxzlf7BjeixDucLTqsRXw2Sf3BMpu9I8cvNNMa00XTyncbVKLRfxtN0JZ+cfcWTyjQcLa9YCOS5k /2MIl1Pec59pSkGUNj9THXz1/K557HgWpM97Y1gexLKM6r8LXAV01zUJdZldKTljUeXsTdsgq6BfF QwVcxxgVTtcSxEvYbxZztPm9msN+Mctkc5BvGQhMEYKwqwsBZE4+Xr69OVzGhjNwntALA+6zu5kXq NXq6lfkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sw3VY-0000000766i-1RMM; Wed, 02 Oct 2024 17:51:28 +0000 Received: from mout.web.de ([212.227.15.3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sw3UH-000000075tS-3lfH for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2024 17:50:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1727891404; x=1728496204; i=markus.elfring@web.de; bh=9+tbIUnTt4a/8am5hF5w0MAc7rkV/fOrFs8cjHSvbYI=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:From:To: Cc:References:In-Reply-To:Content-Type:Content-Transfer-Encoding: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=u/iYR7hMMebxvoYwiF1L95igZc507p5BErhiYs2j8q7Bq/tep83NiNhZjhBE2Dy4 klTxiSQBkFB8wQRVZXCrblDcHMuiZneC1O+dlCPtQpftaG16eE8tOUOdMz2W+5uvx q3vEr3DuejOcLL0oX1Ilk4O9sA5M73xHv3zXZHSEGzkz0/AnXQgeEE1VTgDvJOGAY EgJBp4lnCTKVyrDJCT4qIBj1gmncFdps6YJ965SYKHvd3RdBqY/SgJeivwoSIpQsE VeDiNr5JNxY4rn9lFcmQTFg3/40h5aGjA2eQFe1OoCY/zQYFNge1q1G9XlYcXfXqk wBv5vagR1Tl5CrjLPw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.95]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N9cLR-1rqf4D11Wv-014yJT; Wed, 02 Oct 2024 19:50:04 +0200 Message-ID: Date: Wed, 2 Oct 2024 19:50:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] ARM: mvebu: Call of_node_put(cpu_config_np) only once in armada_370_coherency_init() From: Markus Elfring To: linux-arm-kernel@lists.infradead.org, Andrew Lunn , Gregory Clement , Russell King , Sebastian Hesselbarth , Thomas Petazzoni Cc: LKML , kernel-janitors@vger.kernel.org, Krzysztof Kozlowski References: Content-Language: en-GB In-Reply-To: X-Provags-ID: V03:K1:m5vIIPSZoADKCbGY2A8GWNnm1j2VylPZVBy3RyMdeOdMcdDjJLo usJ4gCliqMBVSJ/JPUjtozGDs6qBWhn3NTAPzgwAi7Uv/oIVw9RDauKt+TMq2lDYjpnW82G WRpMn8f6wEeN+UVsGbzIv0Wohn74Dn23Z6JRAWpQCxdptvEQDykIRJuA3LiJ8wo2DrF503z xMOVwsRMUFzdCFLO1R79Q== UI-OutboundReport: notjunk:1;M01:P0:8v19PMwUCp4=;GH3azTOGEsKURqrbj1flHC8B34l ljxGUGDp5l4Cr97RI8oTtEsN0Wcvq9NGlvpzLtQco6aBMSuLJVcYyZtPeev9HiAoyMbENBbq+ cqV5b/PWPZ7zgrjTv/zA9RDQybBi3+Cn8bi09mDuOo6J0FPcaIEEDHcM+u0JvW7oZZF/FTrL5 +XJWnOYADaHeBFj8IQbDYEZBNEmmYJzl541mGFSaElJZy3twyt/dQ5Oaf7gJ7+CqMerUZbdkI CvLFYrqu4Fl4+4fd7qJx27D2T6DENjbw8E+1URtpCvoIahu1jVzI9IENuLmDcYyMT2Gaa1U7F fIEGQRHjmgiDZpaP9DNctsFivV/zydVSlO0WECTS4ySQAKpc8ORZpsZCW40lGa/A6cita63/N yCbqCS7g6b1y9wm4smU45HK23x5sMqqfqLMY0S1q6GE2/BfuSnjo0kEZuo1Yj9GAaFunVw7Co VWuXAMYu+H4K9Yh2nJzz7JH9riNCdsiU3lSJVcmTr6PMCJwEgnjlc5z1slmEr5BBb7wkjYLul 4DgQpJHYTRIlaI/q9ZpZPKGxT5PhVRy0uemaZpLZqVnWXRTLAkVZ2Yz4Li7kxH3D1CBwZ8QOX cjMNtf6Bpmb+A/EeP1H8SyjUYjbRHU6+hmuH4wy4241mzfowVv/2zIL/860H43PG7L0mygjME 8MHfcjyh8v4+8r9v4+jP2qxKtBdzy9q2MAsAEgUb59WNlCmPuxfu4v6IFvcnq/74l51S9TvDJ E+/+Vt2/pD6KgFfBFxespkZnx2t2AArT98lNLmj21CUMT5BSdLoZzcOU+pmRqThYzNcUo5WFj MaPekFFEjqkd7NGLtVdYZ02w== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241002_105010_261203_04F1DFF2 X-CRM114-Status: GOOD ( 10.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Markus Elfring Date: Wed, 2 Oct 2024 19:02:28 +0200 An of_node_put(cpu_config_np) call was immediately used after a null pointer check for an of_iomap() call in this function implementation. Thus call such a function only once instead directly before the check. This issue was transformed by using the Coccinelle software. Signed-off-by: Markus Elfring --- arch/arm/mach-mvebu/coherency.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.46.1 diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c index a6b621ff0b87..262410ccc4bd 100644 --- a/arch/arm/mach-mvebu/coherency.c +++ b/arch/arm/mach-mvebu/coherency.c @@ -137,12 +137,9 @@ static void __init armada_370_coherency_init(struct device_node *np) goto exit; cpu_config_base = of_iomap(cpu_config_np, 0); - if (!cpu_config_base) { - of_node_put(cpu_config_np); - goto exit; - } - of_node_put(cpu_config_np); + if (!cpu_config_base) + goto exit; cpuhp_setup_state_nocalls(CPUHP_AP_ARM_MVEBU_COHERENCY, "arm/mvebu/coherency:starting", From patchwork Wed Oct 2 17:52:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13820186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1013CEB2E0 for ; Wed, 2 Oct 2024 17:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:References:Cc:To:From:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/4htlgmNOIpnL3ZWdVP9cxfcz3ccpDwRCvCU43T8BnQ=; b=2mMcjc8QF7Su61ylX8YU4TYqiJ az3V0ZprGj5gnbUGLsif8JMY3qiugmxGj0GsIv1kUJ8ij6ExUvlOJ2sbAgJPJDqLXH4126WARuHLl Xdk/3sVC3vn0WsCXSTdnw8hopaaEzAblDpmTZEw+YpPW/l2LI/QnZl+qU370LNLpTh8NELN59lU23 i+JS0OrIom9zUAONJU+ao+aN2xY1L3LH54dgdtP4lLkQq/lB3LSTHVFJ2NGuJZARtSRwk3hJAOdAT G/sxADUXC93TBJ3iksKn966a/hwPazIJVT2Nhz1u2w0krxZUNTuNIOfKb7ORC9PEqizsVSFu8NBTj d3Qo2j8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sw3Xh-000000076NO-2Ci6; Wed, 02 Oct 2024 17:53:41 +0000 Received: from mout.web.de ([212.227.15.4]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sw3WR-000000076Bl-3TEX for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2024 17:52:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1727891539; x=1728496339; i=markus.elfring@web.de; bh=/4htlgmNOIpnL3ZWdVP9cxfcz3ccpDwRCvCU43T8BnQ=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:From:To: Cc:References:In-Reply-To:Content-Type:Content-Transfer-Encoding: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=LWaYsaNMcq4jZ1s+0EhhdiC3aoPFZhM6GA+Rg8FDDwQewqK7vV/DLMKg+GhPrMPW F0lL5ZamNqbN3ceKIfB9tmxXt7vEeEYPibquiRpEZ/UUsDZ55BX9YKd65o2r2oOYw diAVJRgcqmT2ZTZJxKaSBOrSItl3IonZe3bsCHEqRzKYxN02V3zLvztH6jN5pvyiM dBYBdY0HuQ9IisQ+hTPKeQrXXR4lGwdG+yq2cYSIKNpji1TioYV8LA8HN7sQoUVNy hJhERebgFXvrDlBWickeMY7AdyDrWbXjh0jLbyPtSn4kRl4BzA7CiClcA97wtheLq HoWG2Oob+C3m+dIQIg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.95]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MyNwm-1rxVJX2IVY-00y7gA; Wed, 02 Oct 2024 19:52:19 +0200 Message-ID: <49260a2e-a510-4d44-8644-38863abb16c1@web.de> Date: Wed, 2 Oct 2024 19:52:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] ARM: mvebu: Use common of_node_put() code in mvebu_pm_suspend_init() From: Markus Elfring To: linux-arm-kernel@lists.infradead.org, Andrew Lunn , Gregory Clement , Russell King , Sebastian Hesselbarth , Thomas Petazzoni Cc: LKML , kernel-janitors@vger.kernel.org, Krzysztof Kozlowski References: Content-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DvV6r13ZOqMm5Bvz6ZHpqLtSGT4c2Hr5PGgIdv8SiO/HAkw0vZrgt8eq+ sQkYA2IkQYWJ+j2//YxOGJVQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241002_105224_183354_E72D5C39 X-CRM114-Status: GOOD ( 10.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Markus Elfring 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 --- arch/arm/mach-mvebu/pm.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.46.1 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; }