Skip to contentSkip to conversation

regulator: max77693: Remove NULL test for rmatch[i].init_data

PATCH Applied Axel Lin 3 participants 3 messages Jun 29, 2013 – Jul 1, 2013

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: max77693: Remove NULL test for rmatch[i].init_data

The implementation in of_regulator_match() already ensures match->init_data is not NULL for all matched cases if the return value of of_regulator_match() > 0.

Thus remove NULL test for rmatch[i].init_data.

This patch also fixes the condition for loop iteration.
The for loop should iterate "matched" times rather than ARRAY_SIZE(regulators) because we only allocate "matched" number of entries for rdata. Though in most cases, "matched" == ARRAY_SIZE(regulators).

---
 drivers/regulator/max77693.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/regulator/max77693.c +1 -3
index d45a4dd..ce4b96c 100644
@@ -190,9 +190,7 @@ static int max77693_pmic_dt_parse_rdata(struct device *dev,
 
 	tmp = *rdata;
 
-	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
-		if (!rmatch[i].init_data)
-			continue;
+	for (i = 0; i < matched; i++) {
 		tmp->initdata = rmatch[i].init_data;
 		tmp->of_node = rmatch[i].of_node;
 		tmp->id = regulators[i].id;
Signature · 1 line
1.8.1.2
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Axel Lin

The implementation in of_regulator_match() already ensures match->init_data is not NULL for all matched cases if the return value of of_regulator_match() > 0.

Thus remove NULL test for rmatch[i].init_data.

This patch also fixes the condition for loop iteration.
The for loop should iterate "matched" times rather than ARRAY_SIZE(regulators) because we only allocate "matched" number of entries for rdata. Though in most cases, "matched" == ARRAY_SIZE(regulators).

---
 drivers/regulator/max77693.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/regulator/max77693.c +0 -0
index d45a4dd..ce4b96c 100644

drivers/regulator/max77693.c static int max77693_pmic_dt_parse_rdata(struct device *dev, · line 196

Quoted 10 lines
drivers/regulator/max77693.c +1 -3
@@ -190,9 +190,7 @@ static int max77693_pmic_dt_parse_rdata(struct device *dev,
 
 	tmp = *rdata;
 
-	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
-		if (!rmatch[i].init_data)
-			continue;
+	for (i = 0; i < matched; i++) {
 		tmp->initdata = rmatch[i].init_data;
 		tmp->of_node = rmatch[i].of_node;
 		tmp->id = regulators[i].id;

Looks good to me,

Thanks,
Jonghwa

maintainer Applied
#2 lore raw
In reply to Axel Lin
Quoted 2 lines · Axel Lin

The implementation in of_regulator_match() already ensures match->init_data is not NULL for all matched cases if the return value of of_regulator_match() > 0.

Applied, thanks.