From f05e30fd2ffd962e6f30dc0abd528b4182ecdf4b Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Sun, 26 Jul 2026 21:13:00 -0400 Subject: power: supply: max17042_battery: Separate MAX17055 initialization 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 Link: https://patch.msgid.link/20260727011319.621794-3-vincent.cloutier@icloud.com Signed-off-by: Sebastian Reichel --- 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 581699335a5f..16b7ef52419d 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -848,18 +848,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 -- cgit v1.2.3