Skip to content

Commit

Permalink
mfd: stmfx: Remove #ifdef guards for PM related functions
Browse files Browse the repository at this point in the history
Use the new DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros
to handle the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Lee Jones <lee@kernel.org>
  • Loading branch information
pcercuei authored and lag-linaro committed Dec 7, 2022
1 parent 69bbab9 commit 4d8a6ae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 2 additions & 4 deletions drivers/mfd/stmfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ static void stmfx_remove(struct i2c_client *client)
stmfx_chip_exit(client);
}

#ifdef CONFIG_PM_SLEEP
static int stmfx_suspend(struct device *dev)
{
struct stmfx *stmfx = dev_get_drvdata(dev);
Expand Down Expand Up @@ -539,9 +538,8 @@ static int stmfx_resume(struct device *dev)

return 0;
}
#endif

static SIMPLE_DEV_PM_OPS(stmfx_dev_pm_ops, stmfx_suspend, stmfx_resume);
static DEFINE_SIMPLE_DEV_PM_OPS(stmfx_dev_pm_ops, stmfx_suspend, stmfx_resume);

static const struct of_device_id stmfx_of_match[] = {
{ .compatible = "st,stmfx-0300", },
Expand All @@ -553,7 +551,7 @@ static struct i2c_driver stmfx_driver = {
.driver = {
.name = "stmfx-core",
.of_match_table = stmfx_of_match,
.pm = &stmfx_dev_pm_ops,
.pm = pm_sleep_ptr(&stmfx_dev_pm_ops),
},
.probe_new = stmfx_probe,
.remove = stmfx_remove,
Expand Down
2 changes: 0 additions & 2 deletions include/linux/mfd/stmfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ struct stmfx {
struct irq_domain *irq_domain;
struct mutex lock; /* IRQ bus lock */
u8 irq_src;
#ifdef CONFIG_PM
u8 bkp_sysctrl;
u8 bkp_irqoutpin;
#endif
};

int stmfx_function_enable(struct stmfx *stmfx, u32 func);
Expand Down

0 comments on commit 4d8a6ae

Please sign in to comment.