Skip to content

Commit 8842bd0

Browse files
Hans de Goedesre
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 370643f commit 8842bd0

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

drivers/power/supply/ug3105_battery.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
struct ug3105_chip {
7070
struct i2c_client *client;
7171
struct power_supply *psy;
72-
struct power_supply_battery_info *info;
7372
struct delayed_work work;
7473
struct mutex lock;
7574
int ocv[UG3105_MOV_AVG_WINDOW]; /* micro-volt */
@@ -103,7 +102,8 @@ static int ug3105_read_word(struct i2c_client *client, u8 reg)
103102

104103
static int ug3105_get_status(struct ug3105_chip *chip)
105104
{
106-
int full = chip->info->constant_charge_voltage_max_uv - UG3105_FULL_BAT_HYST_UV;
105+
int full = chip->psy->battery_info->constant_charge_voltage_max_uv -
106+
UG3105_FULL_BAT_HYST_UV;
107107

108108
if (chip->curr > UG3105_CURR_HYST_UA)
109109
return POWER_SUPPLY_STATUS_CHARGING;
@@ -164,7 +164,7 @@ static int ug3105_get_capacity(struct ug3105_chip *chip)
164164
ocv_diff = ocv_capacity_tbl[i] - chip->ocv_avg;
165165
ocv_step = ocv_capacity_tbl[i] - ocv_capacity_tbl[i - 1];
166166
/* scale 0-110% down to 0-100% for LiPo HV */
167-
if (chip->info->constant_charge_voltage_max_uv >= 4300000)
167+
if (chip->psy->battery_info->constant_charge_voltage_max_uv >= 4300000)
168168
return (i * 500 - ocv_diff * 500 / ocv_step) / 110;
169169
else
170170
return i * 5 - ocv_diff * 5 / ocv_step;
@@ -401,12 +401,9 @@ static int ug3105_probe(struct i2c_client *client)
401401
if (IS_ERR(psy))
402402
return PTR_ERR(psy);
403403

404-
ret = power_supply_get_battery_info(psy, &chip->info);
405-
if (ret)
406-
return ret;
407-
408-
if (chip->info->factory_internal_resistance_uohm == -EINVAL ||
409-
chip->info->constant_charge_voltage_max_uv == -EINVAL) {
404+
if (!psy->battery_info ||
405+
psy->battery_info->factory_internal_resistance_uohm == -EINVAL ||
406+
psy->battery_info->constant_charge_voltage_max_uv == -EINVAL) {
410407
dev_err(dev, "error required properties are missing\n");
411408
return -ENODEV;
412409
}
@@ -422,7 +419,7 @@ static int ug3105_probe(struct i2c_client *client)
422419
chip->ua_per_unit = 8100000 / curr_sense_res_uohm;
423420

424421
/* Use provided internal resistance as start point (in milli-ohm) */
425-
chip->intern_res_avg = chip->info->factory_internal_resistance_uohm / 1000;
422+
chip->intern_res_avg = psy->battery_info->factory_internal_resistance_uohm / 1000;
426423
/* Also add it to the internal resistance moving average window */
427424
chip->intern_res[0] = chip->intern_res_avg;
428425
chip->intern_res_avg_index = 1;

0 commit comments

Comments
 (0)