From: Chris Lapa <[email protected]>

Separated the check out into its own function to make its functionality
easier to understand.

Signed-off-by: Chris Lapa <[email protected]>
---
 drivers/power/supply/bq27xxx_battery.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c 
b/drivers/power/supply/bq27xxx_battery.c
index c92c809..e647bd1 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -956,14 +956,22 @@ static int bq27xxx_battery_read_pwr_avg(struct 
bq27xxx_device_info *di)
 }
 
 /*
- * Returns true if a battery over temperature condition is detected
+ * Returns true if the device has multiple over temperature flags
  */
-static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
+static inline bool bq27xxx_has_multiple_overtemp_flags(const struct 
bq27xxx_device_info *di)
 {
-       if (di->chip == BQ275XX || di->chip == BQ27500 || di->chip == BQ27510G1
+       return di->chip == BQ275XX || di->chip == BQ27500 || di->chip == 
BQ27510G1
                        || di->chip == BQ27510G2 || di->chip == BQ27510G3 || 
di->chip == BQ27541
                        || di->chip == BQ27520G1 || di->chip == BQ27520G2 || 
di->chip == BQ27520G3
-                       || di->chip == BQ27520G4 || di->chip == BQ27545)
+                       || di->chip == BQ27520G4 || di->chip == BQ27545;
+}
+
+/*
+ * Returns true if a battery over temperature condition is detected
+ */
+static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
+{
+       if (bq27xxx_has_multiple_overtemp_flags(di))
                return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
        if (di->chip == BQ27530 || di->chip == BQ27421)
                return flags & BQ27XXX_FLAG_OT;
-- 
2.1.4

Reply via email to