lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 31 Aug 2012 09:24:37 +0000
From:	"Kim, Milo" <Milo.Kim@...com>
To:	Anton Vorontsov <anton.vorontsov@...aro.org>
CC:	David Woodhouse <dwmw2@...radead.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 09/22] lp8727_charger: use the definition rather than enum

 Enum lp8727_chg_state can be removed because only one charger status
 is used - EOC(End Of Charge).

 To check whether the EOC is reached or not, use simple comparison
 rather than shift-operation.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@...com>
---
 drivers/power/lp8727_charger.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c
index 1a5f4b2..32bf157 100644
--- a/drivers/power/lp8727_charger.c
+++ b/drivers/power/lp8727_charger.c
@@ -55,6 +55,7 @@
 #define CHGSTAT		(3 << 4)
 #define CHPORT		(1 << 6)
 #define DCPORT		(1 << 7)
+#define LP8727_STAT_EOC			0x30
 
 /* STATUS2 register */
 #define TEMP_STAT	(3 << 5)
@@ -69,13 +70,6 @@ enum lp8727_dev_id {
 	ID_MAX,
 };
 
-enum lp8727_chg_stat {
-	PRECHG,
-	CC,
-	CV,
-	EOC,
-};
-
 enum lp8727_die_temp {
 	LP8788_TEMP_75C,
 	LP8788_TEMP_95C,
@@ -348,10 +342,10 @@ static int lp8727_battery_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_STATUS:
 		if (lp8727_is_charger_attached(psy->name, pchg->devid)) {
 			lp8727_read_byte(pchg, STATUS1, &read);
-			if (((read & CHGSTAT) >> 4) == EOC)
-				val->intval = POWER_SUPPLY_STATUS_FULL;
-			else
-				val->intval = POWER_SUPPLY_STATUS_CHARGING;
+
+			val->intval = (read & CHGSTAT) == LP8727_STAT_EOC ?
+				POWER_SUPPLY_STATUS_FULL :
+				POWER_SUPPLY_STATUS_CHARGING;
 		} else {
 			val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
 		}
-- 
1.7.9.5


Best Regards,
Milo


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ