cubieboard / Cubietruck_Plus-kernel-source

Other
6 stars 9 forks source link

Bug with battery online property in axp81x power_supply driver #3

Open alodos opened 8 years ago

alodos commented 8 years ago

You have a bug in drivers/power/axp_power/axp81x/axp81x-sply.c with calculation ONLINE battery property. It can be tested when switching from AC power to BATTERY (switch off power cable) and checking online properties with sysfs:

cat /sys/class/power_supply/ac/online
0
cat /sys/class/power_supply/battery/online
0

https://github.com/cubieboard/Cubietruck_Plus-kernel-source/blob/master/drivers/power/axp_power/axp81x/axp81x-sply.c#L144

    case POWER_SUPPLY_PROP_ONLINE:
    {
    /* in order to get hardware state, we must update charger state now.
     * by sunny at 2012-12-23 11:06:15.
     */
        axp_charger_update_state(charger);
        val->intval = charger->bat_current_direction;
        if (charger->bat_temp > 50 || -5 < charger->bat_temp)
            val->intval = 0;
        break;
    }

Compare this code with sources for axp22:

https://github.com/cubieboard/Cubietruck_Plus-kernel-source/blob/master/drivers/power/axp_power/axp22-sply.c#L777

    case POWER_SUPPLY_PROP_ONLINE:
    {
    /* in order to get hardware state, we must update charger state now.
     * by sunny at 2012-12-23 11:06:15.
     */
        axp_charger_update_state(charger);
        val->intval = charger->bat_current_direction;
        if (charger->bat_temp > 50 || -5 > charger->bat_temp)
            val->intval = 0;
        break;
    }
alodos commented 8 years ago

I've replace strange condition to old (used in axp2x drivers), works fine, now battery is online only if AC plugged off. Please look at my pull prequest #4