@@ -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;