Skip to content

Commit 396df70

Browse files
committed
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
2 parents 972a278 + 093d27b commit 396df70

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

drivers/power/reset/arm-versatile-reboot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ static int __init versatile_reboot_probe(void)
146146
versatile_reboot_type = (enum versatile_reboot)reboot_id->data;
147147

148148
syscon_regmap = syscon_node_to_regmap(np);
149+
of_node_put(np);
149150
if (IS_ERR(syscon_regmap))
150151
return PTR_ERR(syscon_regmap);
151152

drivers/power/supply/ab8500_fg.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3148,6 +3148,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
31483148
ret = ab8500_fg_init_hw_registers(di);
31493149
if (ret) {
31503150
dev_err(dev, "failed to initialize registers\n");
3151+
destroy_workqueue(di->fg_wq);
31513152
return ret;
31523153
}
31533154

@@ -3159,6 +3160,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
31593160
di->fg_psy = devm_power_supply_register(dev, &ab8500_fg_desc, &psy_cfg);
31603161
if (IS_ERR(di->fg_psy)) {
31613162
dev_err(dev, "failed to register FG psy\n");
3163+
destroy_workqueue(di->fg_wq);
31623164
return PTR_ERR(di->fg_psy);
31633165
}
31643166

@@ -3174,8 +3176,10 @@ static int ab8500_fg_probe(struct platform_device *pdev)
31743176
/* Register primary interrupt handlers */
31753177
for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq); i++) {
31763178
irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name);
3177-
if (irq < 0)
3179+
if (irq < 0) {
3180+
destroy_workqueue(di->fg_wq);
31783181
return irq;
3182+
}
31793183

31803184
ret = devm_request_threaded_irq(dev, irq, NULL,
31813185
ab8500_fg_irq[i].isr,
@@ -3185,6 +3189,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
31853189
if (ret != 0) {
31863190
dev_err(dev, "failed to request %s IRQ %d: %d\n",
31873191
ab8500_fg_irq[i].name, irq, ret);
3192+
destroy_workqueue(di->fg_wq);
31883193
return ret;
31893194
}
31903195
dev_dbg(dev, "Requested %s IRQ %d: %d\n",
@@ -3200,13 +3205,15 @@ static int ab8500_fg_probe(struct platform_device *pdev)
32003205
ret = ab8500_fg_sysfs_init(di);
32013206
if (ret) {
32023207
dev_err(dev, "failed to create sysfs entry\n");
3208+
destroy_workqueue(di->fg_wq);
32033209
return ret;
32043210
}
32053211

32063212
ret = ab8500_fg_sysfs_psy_create_attrs(di);
32073213
if (ret) {
32083214
dev_err(dev, "failed to create FG psy\n");
32093215
ab8500_fg_sysfs_exit(di);
3216+
destroy_workqueue(di->fg_wq);
32103217
return ret;
32113218
}
32123219

drivers/power/supply/power_supply_core.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -846,17 +846,17 @@ int power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *t
846846
{
847847
int i, high, low;
848848

849-
/* Break loop at table_len - 1 because that is the highest index */
850-
for (i = 0; i < table_len - 1; i++)
849+
for (i = 0; i < table_len; i++)
851850
if (temp > table[i].temp)
852851
break;
853852

854853
/* The library function will deal with high == low */
855-
if ((i == 0) || (i == (table_len - 1)))
856-
high = i;
854+
if (i == 0)
855+
high = low = i;
856+
else if (i == table_len)
857+
high = low = i - 1;
857858
else
858-
high = i - 1;
859-
low = i;
859+
high = (low = i) - 1;
860860

861861
return fixp_linear_interpolate(table[low].temp,
862862
table[low].resistance,
@@ -958,17 +958,17 @@ int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table,
958958
{
959959
int i, high, low;
960960

961-
/* Break loop at table_len - 1 because that is the highest index */
962-
for (i = 0; i < table_len - 1; i++)
961+
for (i = 0; i < table_len; i++)
963962
if (ocv > table[i].ocv)
964963
break;
965964

966965
/* The library function will deal with high == low */
967-
if ((i == 0) || (i == (table_len - 1)))
968-
high = i - 1;
966+
if (i == 0)
967+
high = low = i;
968+
else if (i == table_len)
969+
high = low = i - 1;
969970
else
970-
high = i; /* i.e. i == 0 */
971-
low = i;
971+
high = (low = i) - 1;
972972

973973
return fixp_linear_interpolate(table[low].ocv,
974974
table[low].capacity,

0 commit comments

Comments
 (0)