[PATCH] ARM: bL_switcher: use IS_ERR_OR_NULL() to simplify code

Subsystems: arm port, the rest

STALE1866d

2 messages, 2 authors, 2021-06-24 · open the first message on its own page

[PATCH] ARM: bL_switcher: use IS_ERR_OR_NULL() to simplify code

From: Tang Bin <hidden>
Date: 2021-06-24 07:52:09

Use IS_ERR_OR_NULL() instead of IS_ERR() to simplify code.

Signed-off-by: Tang Bin <redacted>
---
 arch/arm/common/bL_switcher.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index 9a9aa5354..b8e8e2567 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -352,11 +352,9 @@ int bL_switch_request_cb(unsigned int cpu, unsigned int new_cluster_id,
 
 	t = &bL_threads[cpu];
 
-	if (IS_ERR(t->task))
-		return PTR_ERR(t->task);
-	if (!t->task)
-		return -ESRCH;
-
+	if (IS_ERR_OR_NULL(t->task))
+		return t->task ? PTR_ERR(t->task) : -ESRCH;
+
 	spin_lock(&t->lock);
 	if (t->completer) {
 		spin_unlock(&t->lock);
-- 
2.20.1.windows.1




_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] ARM: bL_switcher: use IS_ERR_OR_NULL() to simplify code

From: "Russell King (Oracle)" <linux@armlinux.org.uk>
Date: 2021-06-24 09:23:36

On Thu, Jun 24, 2021 at 03:42:23PM +0800, Tang Bin wrote:
quoted hunk
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index 9a9aa5354..b8e8e2567 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -352,11 +352,9 @@ int bL_switch_request_cb(unsigned int cpu, unsigned int new_cluster_id,
 
 	t = &bL_threads[cpu];
 
-	if (IS_ERR(t->task))
-		return PTR_ERR(t->task);
-	if (!t->task)
-		return -ESRCH;
-
+	if (IS_ERR_OR_NULL(t->task))
+		return t->task ? PTR_ERR(t->task) : -ESRCH;
+
 	spin_lock(&t->lock);
 	if (t->completer) {
 		spin_unlock(&t->lock);
I don't think this improves the code. The original is more readable, and
readability is what we care about rather than code compactness.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help