diff options
author | Hans de Goede <hansg@kernel.org> | 2025-06-08 22:40:08 +0200 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2025-06-22 02:08:44 +0200 |
commit | 8842bd00a74bf758fb1abf572ec1c7d70c09dedb (patch) | |
tree | 860aab33a68fbe223765f80dd3b1fa8583893c30 | |
parent | 370643f45aad93476b6489238ccb45a77b94da3f (diff) |
power: supply: ug3105_battery: Use psy->battery_info
For POWER_SUPPLY_TYPE_BATTERY power-supplies the core already
calls power_supply_get_battery_info() and stores the result in
psy->battery_info.
Use psy->battery_info instead of having the driver call
power_supply_get_battery_info() itself.
Signed-off-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20250608204010.37482-9-hansg@kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r-- | drivers/power/supply/ug3105_battery.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/power/supply/ug3105_battery.c b/drivers/power/supply/ug3105_battery.c index 38e23bdd4603..806f6892e189 100644 --- a/drivers/power/supply/ug3105_battery.c +++ b/drivers/power/supply/ug3105_battery.c @@ -69,7 +69,6 @@ struct ug3105_chip { struct i2c_client *client; struct power_supply *psy; - struct power_supply_battery_info *info; struct delayed_work work; struct mutex lock; int ocv[UG3105_MOV_AVG_WINDOW]; /* micro-volt */ @@ -103,7 +102,8 @@ static int ug3105_read_word(struct i2c_client *client, u8 reg) static int ug3105_get_status(struct ug3105_chip *chip) { - int full = chip->info->constant_charge_voltage_max_uv - UG3105_FULL_BAT_HYST_UV; + int full = chip->psy->battery_info->constant_charge_voltage_max_uv - + UG3105_FULL_BAT_HYST_UV; if (chip->curr > UG3105_CURR_HYST_UA) return POWER_SUPPLY_STATUS_CHARGING; @@ -164,7 +164,7 @@ static int ug3105_get_capacity(struct ug3105_chip *chip) ocv_diff = ocv_capacity_tbl[i] - chip->ocv_avg; ocv_step = ocv_capacity_tbl[i] - ocv_capacity_tbl[i - 1]; /* scale 0-110% down to 0-100% for LiPo HV */ - if (chip->info->constant_charge_voltage_max_uv >= 4300000) + if (chip->psy->battery_info->constant_charge_voltage_max_uv >= 4300000) return (i * 500 - ocv_diff * 500 / ocv_step) / 110; else return i * 5 - ocv_diff * 5 / ocv_step; @@ -401,12 +401,9 @@ static int ug3105_probe(struct i2c_client *client) if (IS_ERR(psy)) return PTR_ERR(psy); - ret = power_supply_get_battery_info(psy, &chip->info); - if (ret) - return ret; - - if (chip->info->factory_internal_resistance_uohm == -EINVAL || - chip->info->constant_charge_voltage_max_uv == -EINVAL) { + if (!psy->battery_info || + psy->battery_info->factory_internal_resistance_uohm == -EINVAL || + psy->battery_info->constant_charge_voltage_max_uv == -EINVAL) { dev_err(dev, "error required properties are missing\n"); return -ENODEV; } @@ -422,7 +419,7 @@ static int ug3105_probe(struct i2c_client *client) chip->ua_per_unit = 8100000 / curr_sense_res_uohm; /* Use provided internal resistance as start point (in milli-ohm) */ - chip->intern_res_avg = chip->info->factory_internal_resistance_uohm / 1000; + chip->intern_res_avg = psy->battery_info->factory_internal_resistance_uohm / 1000; /* Also add it to the internal resistance moving average window */ chip->intern_res[0] = chip->intern_res_avg; chip->intern_res_avg_index = 1; |