[PATCH] power_supply: MAX8997 Charger: Provide status field with moreinformation

From: Donggeun Kim
Date: Mon Jul 18 2011 - 04:23:24 EST


This patch provides additional three values for STATUS property.

Signed-off-by: Donggeun Kim <dg77.kim@xxxxxxxxxxx>
Signed-off-by: MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>
Signed-off-by: KyungMin Park <kyungmin.park@xxxxxxxxxxx>
---
drivers/power/max8997_charger.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/power/max8997_charger.c b/drivers/power/max8997_charger.c
index 7106b49..790b325 100644
--- a/drivers/power/max8997_charger.c
+++ b/drivers/power/max8997_charger.c
@@ -55,8 +55,17 @@ static int max8997_battery_get_property(struct power_supply *psy,
ret = max8997_read_reg(i2c, MAX8997_REG_STATUS4, &reg);
if (ret)
return ret;
+
if ((reg & (1 << 0)) == 0x1)
val->intval = POWER_SUPPLY_STATUS_FULL;
+ else if ((reg & (1 << 1)) && !(reg & (1 << 2)) &&
+ (reg & (1 << 3)) && (reg & (3 << 4)) &&
+ !(reg & (1 << 6)))
+ val->intval = POWER_SUPPLY_STATUS_CHARGING;
+ else if ((reg & (1 << 1)) && !(reg & (1 << 6)))
+ val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+ else
+ val->intval = POWER_SUPPLY_STATUS_DISCHARGING;

break;
case POWER_SUPPLY_PROP_PRESENT:
--
1.7.4.1

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