]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
power: supply: test-power: Test access to extended power supply
authorArmin Wolf <W_Armin@gmx.de>
Fri, 27 Jun 2025 20:51:23 +0000 (22:51 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 7 Jul 2025 12:19:49 +0000 (15:19 +0300)
Test that power supply extensions can access properties of their
power supply using power_supply_get_property_direct(). This both
ensures that the functionality works and serves as an example for
future driver developers.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250627205124.250433-2-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/power/supply/test_power.c

index 5bfdfcf6013b7f4119335f69cc017577a84f1c64..2c0e9ad820c0db23165758303a16bddac1a1634b 100644 (file)
@@ -259,6 +259,7 @@ static const struct power_supply_config test_power_configs[] = {
 static int test_power_battery_extmanufacture_year = 1234;
 static int test_power_battery_exttemp_max = 1000;
 static const enum power_supply_property test_power_battery_extprops[] = {
+       POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
        POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
        POWER_SUPPLY_PROP_TEMP_MAX,
 };
@@ -270,6 +271,9 @@ static int test_power_battery_extget_property(struct power_supply *psy,
                                              union power_supply_propval *val)
 {
        switch (psp) {
+       case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
+               return power_supply_get_property_direct(psy, POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
+                                                       val);
        case POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
                val->intval = test_power_battery_extmanufacture_year;
                break;