Skip to contentSkip to conversation

mtd: rawnand: nandsim: Merge repeat codes in ns_switch_state

PATCH In review [email protected] 2 participants 2 messages Dec 25, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 mtd: rawnand: nandsim: Merge repeat codes in ns_switch_state

From: RinHizakura <[email protected]>

The moving block of codes is shared between both 'if' and 'else' condition, we can move it out to reduce the duplication.

---
 drivers/mtd/nand/raw/nandsim.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/mtd/nand/raw/nandsim.c +6 -13
index 3698fb430..2ef6bddf0 100644
@@ -1731,14 +1731,6 @@ static void ns_switch_state(struct nandsim *ns)
 			"state: %s, nxstate: %s\n",
 		       ns_get_state_name(ns->state),
 		       ns_get_state_name(ns->nxstate));
-
-		/* See, whether we need to do some action */
-		if ((ns->state & ACTION_MASK) &&
-		    ns_do_state_action(ns, ns->state) < 0) {
-			ns_switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
-			return;
-		}
-
 	} else {
 		/*
 		 * We don't yet know which operation we perform.
@@ -1755,12 +1747,13 @@ static void ns_switch_state(struct nandsim *ns)
 
 		if (ns_find_operation(ns, 0))
 			return;
+	}
 
-		if ((ns->state & ACTION_MASK) &&
-		    ns_do_state_action(ns, ns->state) < 0) {
-			ns_switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
-			return;
-		}
+	/* See, whether we need to do some action */
+	if ((ns->state & ACTION_MASK) &&
+	    ns_do_state_action(ns, ns->state) < 0) {
+		ns_switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
+		return;
 	}
 
 	/* For 16x devices column means the page offset in words */
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 2/3
#1 lore raw

----- Ursprüngliche Mail -----

Quoted 9 lines

Von: [email protected]
An: "richard" <[email protected]>, "Vignesh Raghavendra" <[email protected]>, "Miquel Raynal" <[email protected]>
CC: "linux-mtd" <[email protected]>, "linux-kernel" <[email protected]>, "RinHizakura" <[email protected]>
Gesendet: Samstag, 25. Dezember 2021 11:06:48
Betreff: [PATCH 2/3] mtd: rawnand: nandsim: Merge repeat codes in ns_switch_state

From: RinHizakura <[email protected]>

Quoted 7 lines

The moving block of codes is shared between both 'if' and 'else' condition, we can move it out to reduce the duplication.

---
drivers/mtd/nand/raw/nandsim.c | 19 ++++++-------------

1 file changed, 6 insertions(+), 13 deletions(-)

Thanks,
//richard