diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-08-30 20:47:32 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-08-30 20:47:32 +0200 |
commit | 4520dcbe0df41385288f24e61f322ee97063fa03 (patch) | |
tree | c82ce27a80a8e90d564d5cfad307a8a37657f104 /drivers/power/supply/ab8500_fg.c | |
parent | Merge tag 'spi-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/brooni... (diff) | |
parent | power: supply: core: Fix parsing of battery chemistry/technology (diff) | |
download | linux-4520dcbe0df41385288f24e61f322ee97063fa03.tar.xz linux-4520dcbe0df41385288f24e61f322ee97063fa03.zip |
Merge tag 'for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel:
"Battery/charger related:
- cros-peripheral-charger: new driver
- mt6360-charger: new driver
- simple-battery: support reading chemistry info
- max17042-battery: add max77849 support
- sbs-battery: add time_to_empty_now support
- smb347-charger: prepare USB OTG support
- rn5t618: add voltage_now support
- axp288: cleanup & optimizations
- max17042_battery: cleanups
- ab8500: cleanups
- misc minor cleanups and DT binding fixes
reset related:
- tps65086-restart: new driver
- linkstation-poweroff: support NETGEAR ReadyNAS Duo v2"
* tag 'for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (51 commits)
power: supply: core: Fix parsing of battery chemistry/technology
power: supply: max17042_battery: log SOC threshold using debug log level
power: supply: max17042_battery: more robust chip type checks
power: supply: max17042_battery: fix typo in MAx17042_TOFF
power: supply: max17042_battery: clean up MAX17055_V_empty
power: supply: smb347-charger: Implement USB VBUS regulator
power: supply: smb347-charger: Add missing pin control activation
power: supply: smb347-charger: Utilize generic regmap caching
power: supply: smb347-charger: Make smb347_set_writable() IRQ-safe
dt-bindings: power: supply: smb347-charger: Document USB VBUS regulator
power: reset: Add TPS65086 restart driver
dt-bindings: power: supply: max17042: describe interrupt
power: supply: max17042: remove duplicated STATUS bit defines
power: supply: max17042: handle fails of reading status register
power: supply: core: Parse battery chemistry/technology
dt-bindings: power: Extend battery bindings with chemistry
power: reset: linkstation-poweroff: add new device
power: reset: linkstation-poweroff: prepare for new devices
power: supply: bq24735: reorganize ChargeOption command macros
power: supply: rn5t618: Add voltage_now property
...
Diffstat (limited to 'drivers/power/supply/ab8500_fg.c')
-rw-r--r-- | drivers/power/supply/ab8500_fg.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index a6ebdb269fdd..05fe9724ba50 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -34,6 +34,7 @@ #include <linux/mfd/abx500/ab8500.h> #include <linux/iio/consumer.h> #include <linux/kernel.h> +#include <linux/fixp-arith.h> #include "ab8500-bm.h" @@ -56,9 +57,6 @@ /* FG constants */ #define BATT_OVV 0x01 -#define interpolate(x, x1, y1, x2, y2) \ - ((y1) + ((((y2) - (y1)) * ((x) - (x1))) / ((x2) - (x1)))); - /** * struct ab8500_fg_interrupts - ab8500 fg interrupts * @name: name of the interrupt @@ -227,7 +225,7 @@ struct ab8500_fg { struct ab8500_fg_avg_cap avg_cap; struct ab8500 *parent; struct iio_channel *main_bat_v; - struct abx500_bm_data *bm; + struct ab8500_bm_data *bm; struct power_supply *fg_psy; struct workqueue_struct *fg_wq; struct delayed_work fg_periodic_work; @@ -856,7 +854,7 @@ static int ab8500_fg_bat_voltage(struct ab8500_fg *di) static int ab8500_fg_volt_to_capacity(struct ab8500_fg *di, int voltage) { int i, tbl_size; - const struct abx500_v_to_cap *tbl; + const struct ab8500_v_to_cap *tbl; int cap = 0; tbl = di->bm->bat_type[di->bm->batt_id].v_to_cap_tbl; @@ -868,11 +866,12 @@ static int ab8500_fg_volt_to_capacity(struct ab8500_fg *di, int voltage) } if ((i > 0) && (i < tbl_size)) { - cap = interpolate(voltage, + cap = fixp_linear_interpolate( tbl[i].voltage, tbl[i].capacity * 10, tbl[i-1].voltage, - tbl[i-1].capacity * 10); + tbl[i-1].capacity * 10, + voltage); } else if (i == 0) { cap = 1000; } else { @@ -920,11 +919,12 @@ static int ab8500_fg_battery_resistance(struct ab8500_fg *di) } if ((i > 0) && (i < tbl_size)) { - resist = interpolate(di->bat_temp / 10, + resist = fixp_linear_interpolate( tbl[i].temp, tbl[i].resist, tbl[i-1].temp, - tbl[i-1].resist); + tbl[i-1].resist, + di->bat_temp / 10); } else if (i == 0) { resist = tbl[0].resist; } else { @@ -2235,7 +2235,7 @@ static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) case POWER_SUPPLY_TYPE_BATTERY: if (!di->flags.batt_id_received && di->bm->batt_id != BATTERY_UNKNOWN) { - const struct abx500_battery_type *b; + const struct ab8500_battery_type *b; b = &(di->bm->bat_type[di->bm->batt_id]); |