lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 30 Mar 2023 19:11:25 +0500
From:   Khadija Kamran <kamrankhadijadj@...il.com>
To:     outreachy@...ts.linux.dev
Cc:     hvaibhav.linux@...il.com, johan@...nel.org, elder@...nel.org,
        gregkh@...uxfoundation.org, greybus-dev@...ts.linaro.org,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Alison Schofield <alison.schofield@...el.com>
Subject: [PATCH 2/2] staging: greybus: refactor arche_platform_wd_irq()

Linux kernel coding-style suggests to fix your program if it needs more
than 3 levels of indentation. Due to indentation, line length also
exceeds 100 columns, resulting in issues reported by checkpatch.

Refactor the arche_platform_wd_irq() function and reduce the indentation
with the help of goto statement.

Suggested-by: Alison Schofield <alison.schofield@...el.com>
Signed-off-by: Khadija Kamran <kamrankhadijadj@...il.com>
---
 drivers/staging/greybus/arche-platform.c | 79 ++++++++++++------------
 1 file changed, 41 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index a64c1af091b0..dde30c8da1a1 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -158,49 +158,52 @@ static irqreturn_t arche_platform_wd_irq(int irq, void *devid)
 
 	spin_lock_irqsave(&arche_pdata->wake_lock, flags);
 
-	if (gpiod_get_value(arche_pdata->wake_detect)) {
-		/* wake/detect rising */
+	if (!gpiod_get_value(arche_pdata->wake_detect))
+		goto falling;
 
+	/* wake/detect rising */
+
+	/*
+	 * If wake/detect line goes high after low, within less than
+	 * 30msec, then standby boot sequence is initiated, which is not
+	 * supported/implemented as of now. So ignore it.
+	 */
+	if (arche_pdata->wake_detect_state != WD_STATE_BOOT_INIT)
+		goto out;
+
+	if (time_before(jiffies,
+			arche_pdata->wake_detect_start +
+			msecs_to_jiffies(WD_COLDBOOT_PULSE_WIDTH_MS))) {
+		arche_platform_set_wake_detect_state(arche_pdata,
+						     WD_STATE_IDLE);
+		got out;
+	}
+
+	/* Check we are not in middle of irq thread already */
+	if (arche_pdata->wake_detect_state !=
+			WD_STATE_COLDBOOT_START) {
+		arche_platform_set_wake_detect_state(arche_pdata,
+						     WD_STATE_COLDBOOT_TRIG);
+		rc = IRQ_WAKE_THREAD;
+		goto out;
+	}
+
+falling:
+	/* wake/detect falling */
+	if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
+		arche_pdata->wake_detect_start = jiffies;
 		/*
-		 * If wake/detect line goes high after low, within less than
-		 * 30msec, then standby boot sequence is initiated, which is not
-		 * supported/implemented as of now. So ignore it.
+		 * In the beginning, when wake/detect goes low
+		 * (first time), we assume it is meant for coldboot
+		 * and set the flag. If wake/detect line stays low
+		 * beyond 30msec, then it is coldboot else fallback
+		 * to standby boot.
 		 */
-		if (arche_pdata->wake_detect_state == WD_STATE_BOOT_INIT) {
-			if (time_before(jiffies,
-					arche_pdata->wake_detect_start +
-					msecs_to_jiffies(WD_COLDBOOT_PULSE_WIDTH_MS))) {
-				arche_platform_set_wake_detect_state(arche_pdata,
-								     WD_STATE_IDLE);
-			} else {
-				/*
-				 * Check we are not in middle of irq thread
-				 * already
-				 */
-				if (arche_pdata->wake_detect_state !=
-						WD_STATE_COLDBOOT_START) {
-					arche_platform_set_wake_detect_state(arche_pdata,
-									     WD_STATE_COLDBOOT_TRIG);
-					rc = IRQ_WAKE_THREAD;
-				}
-			}
-		}
-	} else {
-		/* wake/detect falling */
-		if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
-			arche_pdata->wake_detect_start = jiffies;
-			/*
-			 * In the beginning, when wake/detect goes low
-			 * (first time), we assume it is meant for coldboot
-			 * and set the flag. If wake/detect line stays low
-			 * beyond 30msec, then it is coldboot else fallback
-			 * to standby boot.
-			 */
-			arche_platform_set_wake_detect_state(arche_pdata,
-							     WD_STATE_BOOT_INIT);
-		}
+		arche_platform_set_wake_detect_state(arche_pdata,
+						     WD_STATE_BOOT_INIT);
 	}
 
+out:
 	spin_unlock_irqrestore(&arche_pdata->wake_lock, flags);
 
 	return rc;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ