Power Supply Fixes for 5.19 cycle

Fixes for the 5.19 cycle:
  * power-supply core temperature interpolation regression fix for
    incorrect boundaries
  * ab8500 needs to destroy it's work queues in error paths
  * Fix old DT refcount leak in arm-versatile
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmLTSGEACgkQ2O7X88g7
 +pq5NA//YyzAb+DADUgXsPNuLGHHev6LgJe1tYVX7st7waduCqO3PFKd2ggjSkqy
 JO9RHQdwxzbmNy7ojAbvhoVElWxzy1dYoEBhzSHocjCXtHOK95tfbbvrZeAn3omF
 qrwWV10Qws5iYGUWXdCs66g43VBGLCd27Iw6LbWDLVQjG/Siy7i4QBnhIOzaQsE4
 UJFnnlB4G4Blj7sgxt4EDbNBs6AxKcLNIoIcBbd8gZSVBzpZY8t3hYlpzQAIa09/
 XYEXn5U7JSHmxsVvwL6u2UJCNSHEAgvpuQHAKh+dVV4FXV7acq+IKdEL5AZTPKYb
 YtQx4wc8jiL5UqC7cwLR46KRZP4jCQWATL3HGbZl4eC7GltWw6ft0hOj/vgxWO1W
 4iPtR71aokR3Hty3w6bJn5mj526zWDNKvnOkuwwxzaINXITpDhZZkunhtLgTHDhS
 atYqORUaC4DpcE9lg888CMu3219DqYd5R6ubSNxwn0cl/cUCdq66Tt4tFEFizHpo
 SFsvqcBaKv5zbDnuPgJVQvnjonD/5XzLl55wUJ1vL6vapNqvmPHypIbW7DhKX6X/
 jYNJOPeUbBTIOrWv3pYxtItDAECfnTF9oBKtZSkRRhrTx9uLugE63p0yoVYQJhGN
 g22HFJyv2ywvVZ4cMLfco3l2pyv/MWxZ2aG+9QJzEuCIU2CC9f0=
 =cL0y
 -----END PGP SIGNATURE-----

Merge tag 'for-v5.19-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply fixes from Sebastian Reichel:

 - power-supply core temperature interpolation regression fix for
   incorrect boundaries

 - ab8500 needs to destroy its work queues in error paths

 - Fix old DT refcount leak in arm-versatile

* tag 'for-v5.19-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power: supply: core: Fix boundary conditions in interpolation
  power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe
  power: supply: ab8500_fg: add missing destroy_workqueue in ab8500_fg_probe
This commit is contained in:
Linus Torvalds 2022-07-17 07:45:51 -07:00
commit 396df7005b
3 changed files with 21 additions and 13 deletions

View file

@ -146,6 +146,7 @@ static int __init versatile_reboot_probe(void)
versatile_reboot_type = (enum versatile_reboot)reboot_id->data;
syscon_regmap = syscon_node_to_regmap(np);
of_node_put(np);
if (IS_ERR(syscon_regmap))
return PTR_ERR(syscon_regmap);

View file

@ -3148,6 +3148,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
ret = ab8500_fg_init_hw_registers(di);
if (ret) {
dev_err(dev, "failed to initialize registers\n");
destroy_workqueue(di->fg_wq);
return ret;
}
@ -3159,6 +3160,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
di->fg_psy = devm_power_supply_register(dev, &ab8500_fg_desc, &psy_cfg);
if (IS_ERR(di->fg_psy)) {
dev_err(dev, "failed to register FG psy\n");
destroy_workqueue(di->fg_wq);
return PTR_ERR(di->fg_psy);
}
@ -3174,8 +3176,10 @@ static int ab8500_fg_probe(struct platform_device *pdev)
/* Register primary interrupt handlers */
for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq); i++) {
irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name);
if (irq < 0)
if (irq < 0) {
destroy_workqueue(di->fg_wq);
return irq;
}
ret = devm_request_threaded_irq(dev, irq, NULL,
ab8500_fg_irq[i].isr,
@ -3185,6 +3189,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
if (ret != 0) {
dev_err(dev, "failed to request %s IRQ %d: %d\n",
ab8500_fg_irq[i].name, irq, ret);
destroy_workqueue(di->fg_wq);
return ret;
}
dev_dbg(dev, "Requested %s IRQ %d: %d\n",
@ -3200,6 +3205,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
ret = ab8500_fg_sysfs_init(di);
if (ret) {
dev_err(dev, "failed to create sysfs entry\n");
destroy_workqueue(di->fg_wq);
return ret;
}
@ -3207,6 +3213,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
if (ret) {
dev_err(dev, "failed to create FG psy\n");
ab8500_fg_sysfs_exit(di);
destroy_workqueue(di->fg_wq);
return ret;
}

View file

@ -846,17 +846,17 @@ int power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *t
{
int i, high, low;
/* Break loop at table_len - 1 because that is the highest index */
for (i = 0; i < table_len - 1; i++)
for (i = 0; i < table_len; i++)
if (temp > table[i].temp)
break;
/* The library function will deal with high == low */
if ((i == 0) || (i == (table_len - 1)))
high = i;
if (i == 0)
high = low = i;
else if (i == table_len)
high = low = i - 1;
else
high = i - 1;
low = i;
high = (low = i) - 1;
return fixp_linear_interpolate(table[low].temp,
table[low].resistance,
@ -958,17 +958,17 @@ int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table,
{
int i, high, low;
/* Break loop at table_len - 1 because that is the highest index */
for (i = 0; i < table_len - 1; i++)
for (i = 0; i < table_len; i++)
if (ocv > table[i].ocv)
break;
/* The library function will deal with high == low */
if ((i == 0) || (i == (table_len - 1)))
high = i - 1;
if (i == 0)
high = low = i;
else if (i == table_len)
high = low = i - 1;
else
high = i; /* i.e. i == 0 */
low = i;
high = (low = i) - 1;
return fixp_linear_interpolate(table[low].ocv,
table[low].capacity,