• Hans de Goede's avatar
    power: supply: axp288_fuel_gauge: Only read PWR_OP_MODE, FG_LOW_CAP_REG regs once · c371d449
    Hans de Goede authored
    Accessing registers on the AXP288 is quite expensive, so we should avoid
    doing unnecessary accesses.
    
    The FG_LOW_CAP_REG never changes underneath us, so we only need to read
    it once. Devices with an AXP288 do not have user-replace (let alone
    hot-swappable) batteries and the only bit we care about in the
    PWR_OP_MODE register is the CHRG_STAT_BAT_PRESENT bit, so we can get
    away with only reading the PWR_OP_MODE register once too.
    
    Note that the FG_LOW_CAP_REG is not marked volatile in the regmap, so we
    were effectively already reading it once. This change makes this explicit,
    this is done as preparation of a further patch which moves all remaining
    register accesses in fuel_gauge_get_property() out of that function.
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
    c371d449
axp288_fuel_gauge.c 18.8 KB