Skip to contentSkip to conversation

regulator: of: Drop dead code in of_get_regulation_constraints()

PATCH New Sergey Shtylyov 1 participant 1 message Jun 8 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 regulator: of: Drop dead code in of_get_regulation_constraints()

From: Karina Yankevich <[email protected]>

In of_get_regulation_constraints(), the variable suspend_state is either assigned &constraints->state_* pointer (that apparently can never be NULL) in the *switch* statement at the start of the *for* loop or that loop just skips the current iteration using the *continue* statement; thus the 2nd (after the of_get_child_by_name() call) *if* statement's condition would never be true. Hence we can drop the dead code...

Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.

[Sergey: rewrote the subject/description]

---
The patch is against the for-next branch of Mark Brown's regulator.git repo...

Changes in version 2:
- rewrote the patch subject/description;
- refreshed the patch.

Here's the link to version 1:
https://lore.kernel.org/all/[email protected]/

 drivers/regulator/of_regulator.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/regulator/of_regulator.c +0 -4
index c0cc6cc0afd8..d873b7e2dd90 100644
@@ -278,10 +278,6 @@ static int of_get_regulation_constraints(struct device *dev,
 		suspend_np = of_get_child_by_name(np, regulator_states[i]);
 		if (!suspend_np)
 			continue;
-		if (!suspend_state) {
-			of_node_put(suspend_np);
-			continue;
-		}
 
 		if (!of_property_read_u32(suspend_np, "regulator-mode",
 					  &pval)) {
Signature · 1 line
2.54.0