power: supply: axp288_fuel_gauge: Only read PWR_OP_MODE, FG_LOW_CAP_REG regs once
authorHans de Goede <hdegoede@redhat.com>
Sun, 1 Aug 2021 13:31:02 +0000 (15:31 +0200)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Thu, 5 Aug 2021 16:54:52 +0000 (18:54 +0200)
commitc371d4491ba6356d5e437bd8cc8a72797f3e93bd
tree36334d7facd1a4515e3ab2a81cd54e1d853c1fa9
parent7eef3e663834476946ecd4a43b4e1a2cb2bc9884
power: supply: axp288_fuel_gauge: Only read PWR_OP_MODE, FG_LOW_CAP_REG regs once

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: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/axp288_fuel_gauge.c