Skip to content

Commit

Permalink
Merge tag 'for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/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
  • Loading branch information
Linus Torvalds committed Jun 1, 2022
2 parents 96752be + da50aad commit c799314
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 90 deletions.
19 changes: 10 additions & 9 deletions drivers/power/supply/ab8500_fg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3037,13 +3037,6 @@ static int ab8500_fg_bind(struct device *dev, struct device *master,
{
struct ab8500_fg *di = dev_get_drvdata(dev);

/* Create a work queue for running the FG algorithm */
di->fg_wq = alloc_ordered_workqueue("ab8500_fg_wq", WQ_MEM_RECLAIM);
if (di->fg_wq == NULL) {
dev_err(dev, "failed to create work queue\n");
return -ENOMEM;
}

di->bat_cap.max_mah_design = di->bm->bi->charge_full_design_uah;
di->bat_cap.max_mah = di->bat_cap.max_mah_design;
di->vbat_nom_uv = di->bm->bi->voltage_max_design_uv;
Expand All @@ -3067,8 +3060,7 @@ static void ab8500_fg_unbind(struct device *dev, struct device *master,
if (ret)
dev_err(dev, "failed to disable coulomb counter\n");

destroy_workqueue(di->fg_wq);
flush_scheduled_work();
flush_workqueue(di->fg_wq);
}

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

/* Create a work queue for running the FG algorithm */
di->fg_wq = alloc_ordered_workqueue("ab8500_fg_wq", WQ_MEM_RECLAIM);
if (di->fg_wq == NULL) {
dev_err(dev, "failed to create work queue\n");
return -ENOMEM;
}

/* Init work for running the fg algorithm instantly */
INIT_WORK(&di->fg_work, ab8500_fg_instant_work);

Expand Down Expand Up @@ -3227,6 +3226,8 @@ static int ab8500_fg_remove(struct platform_device *pdev)
{
struct ab8500_fg *di = platform_get_drvdata(pdev);

destroy_workqueue(di->fg_wq);
flush_scheduled_work();
component_del(&pdev->dev, &ab8500_fg_component_ops);
list_del(&di->node);
ab8500_fg_sysfs_exit(di);
Expand Down
41 changes: 36 additions & 5 deletions drivers/power/supply/axp288_fuel_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
#define AXP288_REG_UPDATE_INTERVAL (60 * HZ)
#define AXP288_FG_INTR_NUM 6

#define AXP288_QUIRK_NO_BATTERY BIT(0)

static bool no_current_sense_res;
module_param(no_current_sense_res, bool, 0444);
MODULE_PARM_DESC(no_current_sense_res, "No (or broken) current sense resistor");
Expand Down Expand Up @@ -524,7 +526,7 @@ static struct power_supply_desc fuel_gauge_desc = {
* detection reports one despite it not being there.
* Please keep this listed sorted alphabetically.
*/
static const struct dmi_system_id axp288_no_battery_list[] = {
static const struct dmi_system_id axp288_quirks[] = {
{
/* ACEPC T8 Cherry Trail Z8350 mini PC */
.matches = {
Expand All @@ -534,6 +536,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
/* also match on somewhat unique bios-version */
DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{
/* ACEPC T11 Cherry Trail Z8350 mini PC */
Expand All @@ -544,48 +547,70 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
/* also match on somewhat unique bios-version */
DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{
/* Intel Cherry Trail Compute Stick, Windows version */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
DMI_MATCH(DMI_PRODUCT_NAME, "STK1AW32SC"),
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{
/* Intel Cherry Trail Compute Stick, version without an OS */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
DMI_MATCH(DMI_PRODUCT_NAME, "STK1A32SC"),
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{
/* Meegopad T02 */
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "MEEGOPAD T02"),
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{ /* Mele PCG03 Mini PC */
.matches = {
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"),
DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"),
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{
/* Minix Neo Z83-4 mini PC */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
}
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{
/* Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks */
/*
* One Mix 1, this uses the "T3 MRD" boardname used by
* generic mini PCs, but it is a mini laptop so it does
* actually have a battery!
*/
.matches = {
DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
DMI_MATCH(DMI_BIOS_DATE, "06/14/2018"),
},
.driver_data = NULL,
},
{
/*
* Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks
* This entry must be last because it is generic, this allows
* adding more specifuc quirks overriding this generic entry.
*/
.matches = {
DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
DMI_MATCH(DMI_BIOS_VERSION, "5.11"),
},
.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
},
{}
};
Expand Down Expand Up @@ -665,7 +690,9 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
[BAT_D_CURR] = "axp288-chrg-d-curr",
[BAT_VOLT] = "axp288-batt-volt",
};
const struct dmi_system_id *dmi_id;
struct device *dev = &pdev->dev;
unsigned long quirks = 0;
int i, pirq, ret;

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

if (dmi_check_system(axp288_no_battery_list))
dmi_id = dmi_first_match(axp288_quirks);
if (dmi_id)
quirks = (unsigned long)dmi_id->driver_data;

if (quirks & AXP288_QUIRK_NO_BATTERY)
return -ENODEV;

info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
Expand Down
63 changes: 21 additions & 42 deletions drivers/power/supply/bq24190_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,9 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
if (!info)
return -EINVAL;

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}

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

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}

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

ret = pm_runtime_get_sync(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0) {
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
pm_runtime_put_noidle(bdi->dev);
return ret;
}

Expand Down Expand Up @@ -551,10 +546,9 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
int ret;
u8 val;

ret = pm_runtime_get_sync(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0) {
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
pm_runtime_put_noidle(bdi->dev);
return ret;
}

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

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

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}

switch (psp) {
case POWER_SUPPLY_PROP_CHARGE_TYPE:
Expand Down Expand Up @@ -1204,11 +1196,9 @@ static int bq24190_charger_set_property(struct power_supply *psy,

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

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}

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

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}

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

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}

switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
Expand Down Expand Up @@ -1683,10 +1669,9 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
int error;

bdi->irq_event = true;
error = pm_runtime_get_sync(bdi->dev);
error = pm_runtime_resume_and_get(bdi->dev);
if (error < 0) {
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
pm_runtime_put_noidle(bdi->dev);
return IRQ_NONE;
}
bq24190_check_status(bdi);
Expand Down Expand Up @@ -1921,11 +1906,9 @@ static int bq24190_remove(struct i2c_client *client)
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
int error;

error = pm_runtime_get_sync(bdi->dev);
if (error < 0) {
error = pm_runtime_resume_and_get(bdi->dev);
if (error < 0)
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
pm_runtime_put_noidle(bdi->dev);
}

bq24190_register_reset(bdi);
if (bdi->battery)
Expand Down Expand Up @@ -1982,11 +1965,9 @@ static __maybe_unused int bq24190_pm_suspend(struct device *dev)
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
int error;

error = pm_runtime_get_sync(bdi->dev);
if (error < 0) {
error = pm_runtime_resume_and_get(bdi->dev);
if (error < 0)
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
pm_runtime_put_noidle(bdi->dev);
}

bq24190_register_reset(bdi);

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

error = pm_runtime_get_sync(bdi->dev);
if (error < 0) {
error = pm_runtime_resume_and_get(bdi->dev);
if (error < 0)
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
pm_runtime_put_noidle(bdi->dev);
}

bq24190_register_reset(bdi);
bq24190_set_config(bdi);
Expand Down
Loading

0 comments on commit c799314

Please sign in to comment.