Skip to content

Commit c799314

Browse files
committed
Merge tag 'for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel: "Not much from the power-supply subsystem this time around, since I was busy most of the cycle. This also contains some fixes that I originally planned to send for 5.18. Apart from this there is nothing noteworthy. Power-supply core: - init power_supply_info struct to zero Drivers: - bq27xxx: expose data for uncalibrated battery - bq24190-charger: use pm_runtime_resume_and_get - ab8500_fg: allocate wq in probe - axp288_fuel_gauge: drop BIOS version from 'T3 MRD' quirk - axp288_fuel_gauge: modify 'T3 MRD' quirk to also fix 'One Mix 1'" * tag 'for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: power: supply: bq24190_charger: using pm_runtime_resume_and_get instead of pm_runtime_get_sync power: supply: bq27xxx: expose battery data when CI=1 power: supply: ab8500_fg: Allocate wq in probe power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1 power: supply: core: Initialize struct to zero
2 parents 96752be + da50aad commit c799314

File tree

5 files changed

+95
-90
lines changed

5 files changed

+95
-90
lines changed

drivers/power/supply/ab8500_fg.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,13 +3037,6 @@ static int ab8500_fg_bind(struct device *dev, struct device *master,
30373037
{
30383038
struct ab8500_fg *di = dev_get_drvdata(dev);
30393039

3040-
/* Create a work queue for running the FG algorithm */
3041-
di->fg_wq = alloc_ordered_workqueue("ab8500_fg_wq", WQ_MEM_RECLAIM);
3042-
if (di->fg_wq == NULL) {
3043-
dev_err(dev, "failed to create work queue\n");
3044-
return -ENOMEM;
3045-
}
3046-
30473040
di->bat_cap.max_mah_design = di->bm->bi->charge_full_design_uah;
30483041
di->bat_cap.max_mah = di->bat_cap.max_mah_design;
30493042
di->vbat_nom_uv = di->bm->bi->voltage_max_design_uv;
@@ -3067,8 +3060,7 @@ static void ab8500_fg_unbind(struct device *dev, struct device *master,
30673060
if (ret)
30683061
dev_err(dev, "failed to disable coulomb counter\n");
30693062

3070-
destroy_workqueue(di->fg_wq);
3071-
flush_scheduled_work();
3063+
flush_workqueue(di->fg_wq);
30723064
}
30733065

30743066
static const struct component_ops ab8500_fg_component_ops = {
@@ -3117,6 +3109,13 @@ static int ab8500_fg_probe(struct platform_device *pdev)
31173109
ab8500_fg_charge_state_to(di, AB8500_FG_CHARGE_INIT);
31183110
ab8500_fg_discharge_state_to(di, AB8500_FG_DISCHARGE_INIT);
31193111

3112+
/* Create a work queue for running the FG algorithm */
3113+
di->fg_wq = alloc_ordered_workqueue("ab8500_fg_wq", WQ_MEM_RECLAIM);
3114+
if (di->fg_wq == NULL) {
3115+
dev_err(dev, "failed to create work queue\n");
3116+
return -ENOMEM;
3117+
}
3118+
31203119
/* Init work for running the fg algorithm instantly */
31213120
INIT_WORK(&di->fg_work, ab8500_fg_instant_work);
31223121

@@ -3227,6 +3226,8 @@ static int ab8500_fg_remove(struct platform_device *pdev)
32273226
{
32283227
struct ab8500_fg *di = platform_get_drvdata(pdev);
32293228

3229+
destroy_workqueue(di->fg_wq);
3230+
flush_scheduled_work();
32303231
component_del(&pdev->dev, &ab8500_fg_component_ops);
32313232
list_del(&di->node);
32323233
ab8500_fg_sysfs_exit(di);

drivers/power/supply/axp288_fuel_gauge.c

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
#define AXP288_REG_UPDATE_INTERVAL (60 * HZ)
9191
#define AXP288_FG_INTR_NUM 6
9292

93+
#define AXP288_QUIRK_NO_BATTERY BIT(0)
94+
9395
static bool no_current_sense_res;
9496
module_param(no_current_sense_res, bool, 0444);
9597
MODULE_PARM_DESC(no_current_sense_res, "No (or broken) current sense resistor");
@@ -524,7 +526,7 @@ static struct power_supply_desc fuel_gauge_desc = {
524526
* detection reports one despite it not being there.
525527
* Please keep this listed sorted alphabetically.
526528
*/
527-
static const struct dmi_system_id axp288_no_battery_list[] = {
529+
static const struct dmi_system_id axp288_quirks[] = {
528530
{
529531
/* ACEPC T8 Cherry Trail Z8350 mini PC */
530532
.matches = {
@@ -534,6 +536,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
534536
/* also match on somewhat unique bios-version */
535537
DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
536538
},
539+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
537540
},
538541
{
539542
/* ACEPC T11 Cherry Trail Z8350 mini PC */
@@ -544,48 +547,70 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
544547
/* also match on somewhat unique bios-version */
545548
DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
546549
},
550+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
547551
},
548552
{
549553
/* Intel Cherry Trail Compute Stick, Windows version */
550554
.matches = {
551555
DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
552556
DMI_MATCH(DMI_PRODUCT_NAME, "STK1AW32SC"),
553557
},
558+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
554559
},
555560
{
556561
/* Intel Cherry Trail Compute Stick, version without an OS */
557562
.matches = {
558563
DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
559564
DMI_MATCH(DMI_PRODUCT_NAME, "STK1A32SC"),
560565
},
566+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
561567
},
562568
{
563569
/* Meegopad T02 */
564570
.matches = {
565571
DMI_MATCH(DMI_PRODUCT_NAME, "MEEGOPAD T02"),
566572
},
573+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
567574
},
568575
{ /* Mele PCG03 Mini PC */
569576
.matches = {
570577
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"),
571578
DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"),
572579
},
580+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
573581
},
574582
{
575583
/* Minix Neo Z83-4 mini PC */
576584
.matches = {
577585
DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
578586
DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
579-
}
587+
},
588+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
580589
},
581590
{
582-
/* Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks */
591+
/*
592+
* One Mix 1, this uses the "T3 MRD" boardname used by
593+
* generic mini PCs, but it is a mini laptop so it does
594+
* actually have a battery!
595+
*/
596+
.matches = {
597+
DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
598+
DMI_MATCH(DMI_BIOS_DATE, "06/14/2018"),
599+
},
600+
.driver_data = NULL,
601+
},
602+
{
603+
/*
604+
* Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks
605+
* This entry must be last because it is generic, this allows
606+
* adding more specifuc quirks overriding this generic entry.
607+
*/
583608
.matches = {
584609
DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
585610
DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
586611
DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
587-
DMI_MATCH(DMI_BIOS_VERSION, "5.11"),
588612
},
613+
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
589614
},
590615
{}
591616
};
@@ -665,7 +690,9 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
665690
[BAT_D_CURR] = "axp288-chrg-d-curr",
666691
[BAT_VOLT] = "axp288-batt-volt",
667692
};
693+
const struct dmi_system_id *dmi_id;
668694
struct device *dev = &pdev->dev;
695+
unsigned long quirks = 0;
669696
int i, pirq, ret;
670697

671698
/*
@@ -675,7 +702,11 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
675702
if (!acpi_quirk_skip_acpi_ac_and_battery())
676703
return -ENODEV;
677704

678-
if (dmi_check_system(axp288_no_battery_list))
705+
dmi_id = dmi_first_match(axp288_quirks);
706+
if (dmi_id)
707+
quirks = (unsigned long)dmi_id->driver_data;
708+
709+
if (quirks & AXP288_QUIRK_NO_BATTERY)
679710
return -ENODEV;
680711

681712
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);

drivers/power/supply/bq24190_charger.c

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,9 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
455455
if (!info)
456456
return -EINVAL;
457457

458-
ret = pm_runtime_get_sync(bdi->dev);
459-
if (ret < 0) {
460-
pm_runtime_put_noidle(bdi->dev);
458+
ret = pm_runtime_resume_and_get(bdi->dev);
459+
if (ret < 0)
461460
return ret;
462-
}
463461

464462
ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v);
465463
if (ret)
@@ -490,11 +488,9 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
490488
if (ret < 0)
491489
return ret;
492490

493-
ret = pm_runtime_get_sync(bdi->dev);
494-
if (ret < 0) {
495-
pm_runtime_put_noidle(bdi->dev);
491+
ret = pm_runtime_resume_and_get(bdi->dev);
492+
if (ret < 0)
496493
return ret;
497-
}
498494

499495
ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
500496
if (ret)
@@ -512,10 +508,9 @@ static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
512508
union power_supply_propval val = { .intval = bdi->charge_type };
513509
int ret;
514510

515-
ret = pm_runtime_get_sync(bdi->dev);
511+
ret = pm_runtime_resume_and_get(bdi->dev);
516512
if (ret < 0) {
517513
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
518-
pm_runtime_put_noidle(bdi->dev);
519514
return ret;
520515
}
521516

@@ -551,10 +546,9 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
551546
int ret;
552547
u8 val;
553548

554-
ret = pm_runtime_get_sync(bdi->dev);
549+
ret = pm_runtime_resume_and_get(bdi->dev);
555550
if (ret < 0) {
556551
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
557-
pm_runtime_put_noidle(bdi->dev);
558552
return ret;
559553
}
560554

@@ -1128,11 +1122,9 @@ static int bq24190_charger_get_property(struct power_supply *psy,
11281122

11291123
dev_dbg(bdi->dev, "prop: %d\n", psp);
11301124

1131-
ret = pm_runtime_get_sync(bdi->dev);
1132-
if (ret < 0) {
1133-
pm_runtime_put_noidle(bdi->dev);
1125+
ret = pm_runtime_resume_and_get(bdi->dev);
1126+
if (ret < 0)
11341127
return ret;
1135-
}
11361128

11371129
switch (psp) {
11381130
case POWER_SUPPLY_PROP_CHARGE_TYPE:
@@ -1204,11 +1196,9 @@ static int bq24190_charger_set_property(struct power_supply *psy,
12041196

12051197
dev_dbg(bdi->dev, "prop: %d\n", psp);
12061198

1207-
ret = pm_runtime_get_sync(bdi->dev);
1208-
if (ret < 0) {
1209-
pm_runtime_put_noidle(bdi->dev);
1199+
ret = pm_runtime_resume_and_get(bdi->dev);
1200+
if (ret < 0)
12101201
return ret;
1211-
}
12121202

12131203
switch (psp) {
12141204
case POWER_SUPPLY_PROP_ONLINE:
@@ -1477,11 +1467,9 @@ static int bq24190_battery_get_property(struct power_supply *psy,
14771467
dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
14781468
dev_dbg(bdi->dev, "prop: %d\n", psp);
14791469

1480-
ret = pm_runtime_get_sync(bdi->dev);
1481-
if (ret < 0) {
1482-
pm_runtime_put_noidle(bdi->dev);
1470+
ret = pm_runtime_resume_and_get(bdi->dev);
1471+
if (ret < 0)
14831472
return ret;
1484-
}
14851473

14861474
switch (psp) {
14871475
case POWER_SUPPLY_PROP_STATUS:
@@ -1525,11 +1513,9 @@ static int bq24190_battery_set_property(struct power_supply *psy,
15251513
dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
15261514
dev_dbg(bdi->dev, "prop: %d\n", psp);
15271515

1528-
ret = pm_runtime_get_sync(bdi->dev);
1529-
if (ret < 0) {
1530-
pm_runtime_put_noidle(bdi->dev);
1516+
ret = pm_runtime_resume_and_get(bdi->dev);
1517+
if (ret < 0)
15311518
return ret;
1532-
}
15331519

15341520
switch (psp) {
15351521
case POWER_SUPPLY_PROP_ONLINE:
@@ -1683,10 +1669,9 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
16831669
int error;
16841670

16851671
bdi->irq_event = true;
1686-
error = pm_runtime_get_sync(bdi->dev);
1672+
error = pm_runtime_resume_and_get(bdi->dev);
16871673
if (error < 0) {
16881674
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
1689-
pm_runtime_put_noidle(bdi->dev);
16901675
return IRQ_NONE;
16911676
}
16921677
bq24190_check_status(bdi);
@@ -1921,11 +1906,9 @@ static int bq24190_remove(struct i2c_client *client)
19211906
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
19221907
int error;
19231908

1924-
error = pm_runtime_get_sync(bdi->dev);
1925-
if (error < 0) {
1909+
error = pm_runtime_resume_and_get(bdi->dev);
1910+
if (error < 0)
19261911
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
1927-
pm_runtime_put_noidle(bdi->dev);
1928-
}
19291912

19301913
bq24190_register_reset(bdi);
19311914
if (bdi->battery)
@@ -1982,11 +1965,9 @@ static __maybe_unused int bq24190_pm_suspend(struct device *dev)
19821965
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
19831966
int error;
19841967

1985-
error = pm_runtime_get_sync(bdi->dev);
1986-
if (error < 0) {
1968+
error = pm_runtime_resume_and_get(bdi->dev);
1969+
if (error < 0)
19871970
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
1988-
pm_runtime_put_noidle(bdi->dev);
1989-
}
19901971

19911972
bq24190_register_reset(bdi);
19921973

@@ -2007,11 +1988,9 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)
20071988
bdi->f_reg = 0;
20081989
bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
20091990

2010-
error = pm_runtime_get_sync(bdi->dev);
2011-
if (error < 0) {
1991+
error = pm_runtime_resume_and_get(bdi->dev);
1992+
if (error < 0)
20121993
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
2013-
pm_runtime_put_noidle(bdi->dev);
2014-
}
20151994

20161995
bq24190_register_reset(bdi);
20171996
bq24190_set_config(bdi);

0 commit comments

Comments
 (0)