diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2021-11-20 18:53:15 +0300 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2021-11-22 19:16:25 +0300 |
commit | e5dff305ab5c539320f1e30db44604e9977c3504 (patch) | |
tree | b2d11da4a72355054eeba88380fbf72343d1b6fc /drivers/power/supply/ab8500_fg.c | |
parent | d8d26ac12e182f2e7f2697b09fabe817b4238c2c (diff) | |
download | linux-e5dff305ab5c539320f1e30db44604e9977c3504.tar.xz |
power: supply: ab8500: Use only one battery type
The code was going through hoops and loops to detect what
battery is connected and check the resistance for this battery
etc.
Skip this trouble: we will support one battery (currently
"unknown") then we will find the connected battery in the
device tree using a compatible string. The battery resistance
may be used to double-check that the right battery is
connected.
Convert the array of battery types into one battery type so
we can next move over the properties of this one type into
the standard struct power_supply_battery_info.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply/ab8500_fg.c')
-rw-r--r-- | drivers/power/supply/ab8500_fg.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 05fe9724ba50..2013db0118ee 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -857,8 +857,8 @@ static int ab8500_fg_volt_to_capacity(struct ab8500_fg *di, int voltage) const struct ab8500_v_to_cap *tbl; int cap = 0; - tbl = di->bm->bat_type[di->bm->batt_id].v_to_cap_tbl; - tbl_size = di->bm->bat_type[di->bm->batt_id].n_v_cap_tbl_elements; + tbl = di->bm->bat_type->v_to_cap_tbl; + tbl_size = di->bm->bat_type->n_v_cap_tbl_elements; for (i = 0; i < tbl_size; ++i) { if (voltage > tbl[i].voltage) @@ -910,8 +910,8 @@ static int ab8500_fg_battery_resistance(struct ab8500_fg *di) const struct batres_vs_temp *tbl; int resist = 0; - tbl = di->bm->bat_type[di->bm->batt_id].batres_tbl; - tbl_size = di->bm->bat_type[di->bm->batt_id].n_batres_tbl_elements; + tbl = di->bm->bat_type->batres_tbl; + tbl_size = di->bm->bat_type->n_batres_tbl_elements; for (i = 0; i < tbl_size; ++i) { if (di->bat_temp / 10 > tbl[i].temp) @@ -2234,10 +2234,11 @@ static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) switch (ext->desc->type) { case POWER_SUPPLY_TYPE_BATTERY: if (!di->flags.batt_id_received && - di->bm->batt_id != BATTERY_UNKNOWN) { + (di->bm->bat_type->name != + POWER_SUPPLY_TECHNOLOGY_UNKNOWN)) { const struct ab8500_battery_type *b; - b = &(di->bm->bat_type[di->bm->batt_id]); + b = di->bm->bat_type; di->flags.batt_id_received = true; @@ -3078,11 +3079,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) psy_cfg.drv_data = di; di->bat_cap.max_mah_design = MILLI_TO_MICRO * - di->bm->bat_type[di->bm->batt_id].charge_full_design; + di->bm->bat_type->charge_full_design; di->bat_cap.max_mah = di->bat_cap.max_mah_design; - di->vbat_nom = di->bm->bat_type[di->bm->batt_id].nominal_voltage; + di->vbat_nom = di->bm->bat_type->nominal_voltage; di->init_capacity = true; |