]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
power: supply: max17042_battery: Use modern PM ops to clear up warning
authorNathan Chancellor <nathan@kernel.org>
Fri, 5 Jun 2026 05:52:28 +0000 (22:52 -0700)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Fri, 5 Jun 2026 19:45:25 +0000 (21:45 +0200)
When building for a platform that does not have power management, such
as s390, there is an unused function warning, as
max17042_suspend_soc_alerts() is only used in max17042_suspend(), which
is under a CONFIG_PM_SLEEP #ifdef.

  drivers/power/supply/max17042_battery.c:957:13: error: 'max17042_suspend_soc_alerts' defined but not used [-Werror=unused-function]
    957 | static void max17042_suspend_soc_alerts(struct max17042_chip *chip)
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Use the modern DEFINE_SIMPLE_DEV_PM_OPS(), which allows the compiler to
see the functions as used while allowing it to eliminate them as unused
during the optimization phase. Use pm_ptr() to allow the compiler to
drop max17042_pm_ops when there is no PM support.

Fixes: 601885ffb5e9 ("power: supply: max17042_battery: Keep only critical alerts during suspend")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://patch.msgid.link/20260604-max17042_battery-fix-unused-suspend_soc_alerts-v1-1-3562a68e6f36@kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/max17042_battery.c

index 0fb46c1c203fa991ef1a2177121fa8ae88de49b9..639dacdb9b31ce7a0e34aaa2110c2630d9a2373c 100644 (file)
@@ -1296,7 +1296,6 @@ static int max17042_platform_probe(struct platform_device *pdev)
        return max17042_probe(i2c, dev, irq, id->driver_data);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int max17042_suspend(struct device *dev)
 {
        struct max17042_chip *chip = dev_get_drvdata(dev);
@@ -1327,10 +1326,9 @@ static int max17042_resume(struct device *dev)
 
        return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(max17042_pm_ops, max17042_suspend,
-                       max17042_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(max17042_pm_ops, max17042_suspend,
+                               max17042_resume);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id max17042_acpi_match[] = {
@@ -1397,7 +1395,7 @@ static struct i2c_driver max17042_i2c_driver = {
                .name   = "max17042",
                .acpi_match_table = ACPI_PTR(max17042_acpi_match),
                .of_match_table = of_match_ptr(max17042_dt_match),
-               .pm     = &max17042_pm_ops,
+               .pm     = pm_ptr(&max17042_pm_ops),
        },
        .probe          = max17042_i2c_probe,
        .id_table       = max17042_id,
@@ -1407,7 +1405,7 @@ static struct platform_driver max17042_platform_driver = {
        .driver = {
                .name   = "max17042",
                .acpi_match_table = ACPI_PTR(max17042_acpi_match),
-               .pm     = &max17042_pm_ops,
+               .pm     = pm_ptr(&max17042_pm_ops),
        },
        .probe          = max17042_platform_probe,
        .id_table       = max17042_platform_id,