lkml.org 
[lkml]   [2016]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 10/11] power: supply: bq275xx: cleanup over temperature flag check.
Date
From: Chris Lapa <chris@lapa.com.au>

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

Signed-off-by: Chris Lapa <chris@lapa.com.au>
---
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
\
 
 \ /
  Last update: 2016-12-23 01:06    [W:0.679 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site