Skip to contentSkip to conversation

Power: Supply: sbs-charger: simplfied bool function

PATCH Superseded Daniel Perez 2 participants 2 messages Feb 14, 2017 Power supply

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Power: Supply: sbs-charger: simplfied bool function

Simplified the syntax of a simple bool return value function.

---
 drivers/power/supply/sbs-charger.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/power/supply/sbs-charger.c +1 -4
index 353765a..3e40553 100644
@@ -137,10 +137,7 @@ static enum power_supply_property sbs_properties[] = {
 
 static bool sbs_readable_reg(struct device *dev, unsigned int reg)
 {
-	if (reg < SBS_CHARGER_REG_SPEC_INFO)
-		return false;
-	else
-		return true;
+	return reg < SBS_CHARGER_REG_SPEC_INFO ? false : true;
 }
 
 static bool sbs_volatile_reg(struct device *dev, unsigned int reg)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · Daniel Perez

Simplified the syntax of a simple bool return value function.

---
 drivers/power/supply/sbs-charger.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/power/supply/sbs-charger.c +0 -0
index 353765a..3e40553 100644

drivers/power/supply/sbs-charger.c static enum power_supply_property sbs_properties[] = { · line 140

Quoted 8 lines
drivers/power/supply/sbs-charger.c +1 -4
@@ -137,10 +137,7 @@ static enum power_supply_property sbs_properties[] = {
 
 static bool sbs_readable_reg(struct device *dev, unsigned int reg)
 {
-	if (reg < SBS_CHARGER_REG_SPEC_INFO)
-		return false;
-	else
-		return true;
+	return reg < SBS_CHARGER_REG_SPEC_INFO ? false : true;

Any ternary with true false could be simplified.
Why not just

	return reg >= SBS_CHARGER_REG_SPEC_INFO;