[PATCH] power: supply: max17042_battery: Use modern PM ops to clear up warning

Nathan Chancellor posted 1 patch 3 days ago
drivers/power/supply/max17042_battery.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
[PATCH] power: supply: max17042_battery: Use modern PM ops to clear up warning
Posted by Nathan Chancellor 3 days ago
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>
---
 drivers/power/supply/max17042_battery.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 0fb46c1c203f..639dacdb9b31 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -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,

---
base-commit: 7e541f6dbd05921d0bbb99646028cb9982535707
change-id: 20260604-max17042_battery-fix-unused-suspend_soc_alerts-32b08b348bc1

Best regards,
--  
Cheers,
Nathan
Re: [PATCH] power: supply: max17042_battery: Use modern PM ops to clear up warning
Posted by Sebastian Reichel 2 days, 9 hours ago
On Thu, 04 Jun 2026 22:52:28 -0700, Nathan Chancellor wrote:
> 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)
>         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> [...]

Applied, thanks!

[1/1] power: supply: max17042_battery: Use modern PM ops to clear up warning
      commit: 4acc0138c4f2fba453da5a5076ad2bba08a7463b

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>