[PATCH v4 02/11] power: supply: max17042_battery: Separate MAX17055 initialization
Vincent Cloutier <[email protected]>
| Newsgroups | org.kernel.vger.linux-pm,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Vincent Cloutier <[email protected]> MAX17055 uses ModelCfg.Refresh instead of the characterization-data flow used by the other supported gauges. Move its existing initialization steps into a dedicated helper without changing behavior. This isolates the chip-specific path for subsequent EZ Config changes. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier <[email protected]> --- drivers/power/supply/max17042_battery.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index d409d2f0d383..70c5d5ce945d 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -847,18 +847,24 @@ static inline void max17042_override_por_values(struct max17042_chip *chip) max17042_override_por(map, MAX17055_ModelCfg, config->model_cfg); } +static void max17055_init_chip(struct max17042_chip *chip) +{ + max17042_override_por_values(chip); + + regmap_write_bits(chip->regmap, MAX17055_ModelCfg, + MAX17055_MODELCFG_REFRESH_BIT, + MAX17055_MODELCFG_REFRESH_BIT); +} + static int max17042_init_chip(struct max17042_chip *chip) { struct regmap *map = chip->regmap; int ret; - max17042_override_por_values(chip); - - if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055) { - regmap_write_bits(map, MAX17055_ModelCfg, - MAX17055_MODELCFG_REFRESH_BIT, - MAX17055_MODELCFG_REFRESH_BIT); - } + if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055) + max17055_init_chip(chip); + else + max17042_override_por_values(chip); /* After Power up, the MAX17042 requires 500mS in order * to perform signal debouncing and initial SOC reporting -- 2.55.0