aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2021-09-30 12:38:30 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2021-09-30 12:38:30 +1000
commit96924eac5c79a6b73033c9b08741c93a22dd3b71 (patch)
treec81454f212fa21a7c869f688989ade13edd0279a
parent16a4829226da980eb46a94f2ec6b67e32855aefb (diff)
parent9ba533eb99bb2acf8b2268c6f48dcf73e1e47753 (diff)
downloaddevel-96924eac5c79a6b73033c9b08741c93a22dd3b71.tar.gz
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git
-rw-r--r--Documentation/ABI/testing/sysfs-class-power13
-rw-r--r--drivers/power/reset/ltc2952-poweroff.c4
-rw-r--r--drivers/power/supply/Kconfig21
-rw-r--r--drivers/power/supply/power_supply_core.c65
4 files changed, 64 insertions, 39 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index ca830c6cd8094b..f7904efc4cfa06 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -480,6 +480,19 @@ Description:
Valid values: Represented in microvolts
+What: /sys/class/power_supply/<supply_name>/cycle_count
+Date: January 2010
+Contact: linux-pm@vger.kernel.org
+Description:
+ Reports the number of full charge + discharge cycles the
+ battery has undergone.
+
+ Access: Read
+
+ Valid values:
+ Integer > 0: representing full cycles
+ Integer = 0: cycle_count info is not available
+
**USB Properties**
What: /sys/class/power_supply/<supply_name>/input_current_limit
diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c
index 8688c8ba8894c4..fbb344353fe40b 100644
--- a/drivers/power/reset/ltc2952-poweroff.c
+++ b/drivers/power/reset/ltc2952-poweroff.c
@@ -94,7 +94,6 @@ static struct ltc2952_poweroff *ltc2952_data;
*/
static enum hrtimer_restart ltc2952_poweroff_timer_wde(struct hrtimer *timer)
{
- ktime_t now;
int state;
struct ltc2952_poweroff *data = to_ltc2952(timer, timer_wde);
@@ -104,8 +103,7 @@ static enum hrtimer_restart ltc2952_poweroff_timer_wde(struct hrtimer *timer)
state = gpiod_get_value(data->gpio_watchdog);
gpiod_set_value(data->gpio_watchdog, !state);
- now = hrtimer_cb_get_time(timer);
- hrtimer_forward(timer, now, data->wde_interval);
+ hrtimer_forward_now(timer, data->wde_interval);
return HRTIMER_RESTART;
}
diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index fcc7534edcb2f9..ad93b3550d6d29 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -366,20 +366,22 @@ config AXP288_FUEL_GAUGE
over/under temperature.
config BATTERY_MAX17040
- tristate "Maxim MAX17040 Fuel Gauge"
+ tristate "Maxim MAX17040/17041/17043 family Fuel Gauge"
depends on I2C
select REGMAP_I2C
help
- Maxim models with ModelGauge are fuel-gauge systems for lithium-ion
- (Li+) batteries in handheld and portable equipment, including
- max17040, max17041, max17043, max17044, max17048, max17049, max17058,
- max17059. It is also included in some batteries like max77836.
+ Driver supports Maxim fuel-gauge systems for lithium-ion (Li+)
+ batteries used mainly in handheld and portable equipment.
+ Supported devices: max17040, max17041, max17043, max17044, max17048,
+ max17049, max17058, max17059, max77836.
Driver supports reporting SOC (State of Charge, i.e capacity),
voltage and configurable low-SOC wakeup interrupt.
+ Driver can be build as a module (max17040_battery).
+
config BATTERY_MAX17042
- tristate "Maxim MAX17042/17047/17050/8997/8966 Fuel Gauge"
+ tristate "Maxim MAX17042/17047/17050/8997/8966 family Fuel Gauge"
depends on I2C
select REGMAP_I2C
help
@@ -387,8 +389,11 @@ config BATTERY_MAX17042
in handheld and portable equipment. The MAX17042 is configured
to operate with a single lithium cell. MAX8997 and MAX8966 are
multi-function devices that include fuel gauages that are compatible
- with MAX17042. This driver also supports max17047/50 chips which are
- improved version of max17042.
+ with MAX17042.
+ Supported devices: max8966, max8997, max17042, max17047, max17050,
+ max17055, max77693, max77849.
+
+ Driver can be build as a module (max17042_battery).
config BATTERY_MAX1721X
tristate "MAX17211/MAX17215 standalone gas-gauge"
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 0c2132c7f5d40f..75575ea45f21dd 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -975,26 +975,41 @@ static struct thermal_zone_device_ops psy_tzd_ops = {
.get_temp = power_supply_read_temp,
};
+static bool psy_has_property(const struct power_supply_desc *psy_desc,
+ enum power_supply_property psp)
+{
+ bool found = false;
+ int i;
+
+ for (i = 0; i < psy_desc->num_properties; i++) {
+ if (psy_desc->properties[i] == psp) {
+ found = true;
+ break;
+ }
+ }
+
+ return found;
+}
+
static int psy_register_thermal(struct power_supply *psy)
{
- int i, ret;
+ int ret;
if (psy->desc->no_thermal)
return 0;
/* Register battery zone device psy reports temperature */
- for (i = 0; i < psy->desc->num_properties; i++) {
- if (psy->desc->properties[i] == POWER_SUPPLY_PROP_TEMP) {
- psy->tzd = thermal_zone_device_register(psy->desc->name,
- 0, 0, psy, &psy_tzd_ops, NULL, 0, 0);
- if (IS_ERR(psy->tzd))
- return PTR_ERR(psy->tzd);
- ret = thermal_zone_device_enable(psy->tzd);
- if (ret)
- thermal_zone_device_unregister(psy->tzd);
- return ret;
- }
+ if (psy_has_property(psy->desc, POWER_SUPPLY_PROP_TEMP)) {
+ psy->tzd = thermal_zone_device_register(psy->desc->name,
+ 0, 0, psy, &psy_tzd_ops, NULL, 0, 0);
+ if (IS_ERR(psy->tzd))
+ return PTR_ERR(psy->tzd);
+ ret = thermal_zone_device_enable(psy->tzd);
+ if (ret)
+ thermal_zone_device_unregister(psy->tzd);
+ return ret;
}
+
return 0;
}
@@ -1065,18 +1080,14 @@ static const struct thermal_cooling_device_ops psy_tcd_ops = {
static int psy_register_cooler(struct power_supply *psy)
{
- int i;
-
/* Register for cooling device if psy can control charging */
- for (i = 0; i < psy->desc->num_properties; i++) {
- if (psy->desc->properties[i] ==
- POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT) {
- psy->tcd = thermal_cooling_device_register(
- (char *)psy->desc->name,
- psy, &psy_tcd_ops);
- return PTR_ERR_OR_ZERO(psy->tcd);
- }
+ if (psy_has_property(psy->desc, POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT)) {
+ psy->tcd = thermal_cooling_device_register(
+ (char *)psy->desc->name,
+ psy, &psy_tcd_ops);
+ return PTR_ERR_OR_ZERO(psy->tcd);
}
+
return 0;
}
@@ -1114,7 +1125,7 @@ __power_supply_register(struct device *parent,
{
struct device *dev;
struct power_supply *psy;
- int i, rc;
+ int rc;
if (!parent)
pr_warn("%s: Expected proper parent device for '%s'\n",
@@ -1123,11 +1134,9 @@ __power_supply_register(struct device *parent,
if (!desc || !desc->name || !desc->properties || !desc->num_properties)
return ERR_PTR(-EINVAL);
- for (i = 0; i < desc->num_properties; ++i) {
- if ((desc->properties[i] == POWER_SUPPLY_PROP_USB_TYPE) &&
- (!desc->usb_types || !desc->num_usb_types))
- return ERR_PTR(-EINVAL);
- }
+ if (psy_has_property(desc, POWER_SUPPLY_PROP_USB_TYPE) &&
+ (!desc->usb_types || !desc->num_usb_types))
+ return ERR_PTR(-EINVAL);
psy = kzalloc(sizeof(*psy), GFP_KERNEL);
if (!psy)