From d5095005f091b71d4ad68d152465b52c91957eb8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 21 Jul 2009 21:02:57 +0200 Subject: bq27000: Return -ENODEV in bq27000_battery_get_property if the battery is not If the battery is not present hdq_read will always return an error. If the drivers knows that the battery is not present the correct thing to do is to return -ENODEV instead of passing the error on. Do this for all properties except POWER_SUPPLY_PROP_PRESENT. The power supply sysfs expects us to do so, else it won't generate a proper uevent file. Signed-off-by: Lars-Peter Clausen --- drivers/power/bq27000_battery.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/power/bq27000_battery.c b/drivers/power/bq27000_battery.c index 593cbe6f752..f1dcda3297d 100644 --- a/drivers/power/bq27000_battery.c +++ b/drivers/power/bq27000_battery.c @@ -186,6 +186,9 @@ static int bq27000_battery_get_property(struct power_supply *psy, int n; struct bq27000_device_info *di = container_of(psy, struct bq27000_device_info, bat); + if (di->regs.rsoc < 0 && psp != POWER_SUPPLY_PROP_PRESENT) + return -ENODEV; + switch (psp) { case POWER_SUPPLY_PROP_STATUS: val->intval = POWER_SUPPLY_STATUS_UNKNOWN; -- cgit v1.2.3