Skip to contentSkip to conversation

regulator: twl-regulator: Simplify the code matching regulator id

PATCH Applied Axel Lin 2 participants 2 messages Apr 9, 2012 – Apr 10, 2012

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: twl-regulator: Simplify the code matching regulator id

This patch makes the code easier to read.

Also add checking the case when no desc id is matched. This is required because if no desc id is matched, the poiner info is pointed to twl_of_match[i].data which may be not NULL. Checking info is NULL or not latter does not catch the error.

---
 drivers/regulator/twl-regulator.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/regulator/twl-regulator.c +5 -3
index 9cdfc38..964946f 100644
@@ -1207,10 +1207,12 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
 		initdata = pdev->dev.platform_data;
 		for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
 			info = twl_of_match[i].data;
-			if (!info || info->desc.id != id)
-				continue;
-			break;
+			if (info && info->desc.id == id)
+				break;
 		}
+		if (i == ARRAY_SIZE(twl_of_match))
+			return -ENODEV;
+
 		drvdata = initdata->driver_data;
 		if (!drvdata)
 			return -EINVAL;
Signature · 1 line
1.7.5.4
Applied
#1 lore raw
Quoted 6 lines · Axel Lin

This patch makes the code easier to read.

Also add checking the case when no desc id is matched. This is required because if no desc id is matched, the poiner info is pointed to twl_of_match[i].data which may be not NULL. Checking info is NULL or not latter does not catch the error.

Applied, thanks.