Message ID | 20230705204314.89800-1-paul@crapouillou.net |
---|---|
Headers | show |
Series | i2c: Use new PM macros | expand |
On Wed, 5 Jul 2023 22:42:52 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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. > > Note that the use of the UNIVERSAL_DEV_PM_OPS() macro was likely to be > wrong, as it sets the same callbacks for the runtime-PM and system > suspend/resume. This patch does not change this behaviour, but I suspect > that it should be changed to use DEFINE_RUNTIME_DEV_PM_OPS() instead, as > the current documentation for UNIVERSAL_DEV_PM_OPS() suggests. I'd be tempted to leave this one alone because it'll be much harder to spot that it's an ex UNIVERSAL_DEV_PM_OPS() that needs some thinking about after this change. > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > > --- > Cc: Elie Morisse <syniurge@gmail.com> > Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com> > --- > drivers/i2c/busses/i2c-amd-mp2-pci.c | 14 +++++--------- > drivers/i2c/busses/i2c-amd-mp2-plat.c | 8 ++------ > drivers/i2c/busses/i2c-amd-mp2.h | 2 -- > 3 files changed, 7 insertions(+), 17 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c > index 143165300949..114fe329279a 100644 > --- a/drivers/i2c/busses/i2c-amd-mp2-pci.c > +++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c > @@ -382,7 +382,6 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev) > amd_mp2_clear_reg(privdata); > } > > -#ifdef CONFIG_PM > static int amd_mp2_pci_suspend(struct device *dev) > { > struct pci_dev *pci_dev = to_pci_dev(dev); > @@ -434,9 +433,10 @@ static int amd_mp2_pci_resume(struct device *dev) > return ret; > } > > -static UNIVERSAL_DEV_PM_OPS(amd_mp2_pci_pm_ops, amd_mp2_pci_suspend, > - amd_mp2_pci_resume, NULL); > -#endif /* CONFIG_PM */ > +static const struct dev_pm_ops amd_mp2_pci_pm_ops = { > + SYSTEM_SLEEP_PM_OPS(amd_mp2_pci_suspend, amd_mp2_pci_resume) > + RUNTIME_PM_OPS(amd_mp2_pci_suspend, amd_mp2_pci_resume, NULL) > +}; > > static const struct pci_device_id amd_mp2_pci_tbl[] = { > {PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2)}, > @@ -449,11 +449,7 @@ static struct pci_driver amd_mp2_pci_driver = { > .id_table = amd_mp2_pci_tbl, > .probe = amd_mp2_pci_probe, > .remove = amd_mp2_pci_remove, > -#ifdef CONFIG_PM > - .driver = { > - .pm = &amd_mp2_pci_pm_ops, > - }, > -#endif > + .driver.pm = pm_ptr(&amd_mp2_pci_pm_ops), > }; > module_pci_driver(amd_mp2_pci_driver); > > diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c b/drivers/i2c/busses/i2c-amd-mp2-plat.c > index 112fe2bc5662..4c677aeaca29 100644 > --- a/drivers/i2c/busses/i2c-amd-mp2-plat.c > +++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c > @@ -183,7 +183,6 @@ static const struct i2c_algorithm i2c_amd_algorithm = { > .functionality = i2c_amd_func, > }; > > -#ifdef CONFIG_PM > static int i2c_amd_suspend(struct amd_i2c_common *i2c_common) > { > struct amd_i2c_dev *i2c_dev = amd_i2c_dev_common(i2c_common); > @@ -198,7 +197,6 @@ static int i2c_amd_resume(struct amd_i2c_common *i2c_common) > > return i2c_amd_enable_set(i2c_dev, true); > } > -#endif > > static const u32 supported_speeds[] = { > I2C_MAX_HIGH_SPEED_MODE_FREQ, > @@ -276,10 +274,8 @@ static int i2c_amd_probe(struct platform_device *pdev) > platform_set_drvdata(pdev, i2c_dev); > > i2c_dev->common.cmd_completion = &i2c_amd_cmd_completion; > -#ifdef CONFIG_PM > - i2c_dev->common.suspend = &i2c_amd_suspend; > - i2c_dev->common.resume = &i2c_amd_resume; > -#endif > + i2c_dev->common.suspend = pm_ptr(&i2c_amd_suspend); > + i2c_dev->common.resume = pm_ptr(&i2c_amd_resume); > > /* Register the adapter */ > amd_mp2_pm_runtime_get(mp2_dev); > diff --git a/drivers/i2c/busses/i2c-amd-mp2.h b/drivers/i2c/busses/i2c-amd-mp2.h > index 018a42de8b1e..40f3cdcc60aa 100644 > --- a/drivers/i2c/busses/i2c-amd-mp2.h > +++ b/drivers/i2c/busses/i2c-amd-mp2.h > @@ -160,10 +160,8 @@ struct amd_i2c_common { > enum speed_enum i2c_speed; > u8 *dma_buf; > dma_addr_t dma_addr; > -#ifdef CONFIG_PM > int (*suspend)(struct amd_i2c_common *i2c_common); > int (*resume)(struct amd_i2c_common *i2c_common); > -#endif /* CONFIG_PM */ > }; > > /**
On Wed, 5 Jul 2023 22:42:54 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
On Wed, 5 Jul 2023 22:42:56 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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. > > Note that the behaviour is slightly different than before; the original > code wrapped the suspend/resume with #ifdef CONFIG_PM guards, which > resulted in these functions being compiled in but never used when > CONFIG_PM_SLEEP was disabled. > > Now, those functions are only compiled in when CONFIG_PM_SLEEP is > enabled. > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> Slightly odd combination of callbacks in this driver, but your change looks good to me. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:42:58 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:43:00 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:43:02 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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. > > Note that the driver should most likely be updated to use the > platform_driver.driver.pm.{suspend,resume} callbacks. Agreed. In this particular case I'd be tempted to do that first so that we don't introduce pm_ptr() usage for these hooks. Look at the platform device core, I suspect they should be pm_sleep_ptr() but not 100% sure. Jonathan > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > --- > drivers/i2c/busses/i2c-kempld.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-kempld.c b/drivers/i2c/busses/i2c-kempld.c > index 281058e3ea46..cb61e7b9202c 100644 > --- a/drivers/i2c/busses/i2c-kempld.c > +++ b/drivers/i2c/busses/i2c-kempld.c > @@ -350,7 +350,6 @@ static void kempld_i2c_remove(struct platform_device *pdev) > i2c_del_adapter(&i2c->adap); > } > > -#ifdef CONFIG_PM > static int kempld_i2c_suspend(struct platform_device *pdev, pm_message_t state) > { > struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); > @@ -377,10 +376,6 @@ static int kempld_i2c_resume(struct platform_device *pdev) > > return 0; > } > -#else > -#define kempld_i2c_suspend NULL > -#define kempld_i2c_resume NULL > -#endif > > static struct platform_driver kempld_i2c_driver = { > .driver = { > @@ -388,8 +383,8 @@ static struct platform_driver kempld_i2c_driver = { > }, > .probe = kempld_i2c_probe, > .remove_new = kempld_i2c_remove, > - .suspend = kempld_i2c_suspend, > - .resume = kempld_i2c_resume, > + .suspend = pm_ptr(kempld_i2c_suspend), > + .resume = pm_ptr(kempld_i2c_resume), > }; > > module_platform_driver(kempld_i2c_driver);
On Wed, 5 Jul 2023 22:43:04 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:43:06 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:43:08 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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. > > Note that the behaviour is slightly different than before; the original > code wrapped the suspend/resume with #ifdef CONFIG_PM guards, which > resulted in these functions being compiled in but never used when > CONFIG_PM_SLEEP was disabled. > > Now, those functions are only compiled in when CONFIG_PM_SLEEP is > enabled. > > Also note that pm_sleep_ptr() has not been applied to each callback > in the dev_pm_ops structure because the pm_sleep_ptr() at the usage site > is sufficient. > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:45:17 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:45:19 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On Wed, 5 Jul 2023 22:45:21 +0200 Paul Cercueil <paul@crapouillou.net> wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
On 7/5/2023 1:42 PM, Paul Cercueil wrote: > Use the new PM macros for the suspend and resume functions to be > automatically dropped by the compiler when CONFIG_PM or > CONFIG_PM_SLEEP are 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> > > --- > Cc: Ray Jui <rjui@broadcom.com> > Cc: Scott Branden <sbranden@broadcom.com> > Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com> > Cc: linux-arm-kernel@lists.infradead.org > --- > drivers/i2c/busses/i2c-bcm-iproc.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c > index 2d8342fdc25d..8a3e2208475c 100644 > --- a/drivers/i2c/busses/i2c-bcm-iproc.c > +++ b/drivers/i2c/busses/i2c-bcm-iproc.c > @@ -1125,8 +1125,6 @@ static void bcm_iproc_i2c_remove(struct platform_device *pdev) > bcm_iproc_i2c_enable_disable(iproc_i2c, false); > } > > -#ifdef CONFIG_PM_SLEEP > - > static int bcm_iproc_i2c_suspend(struct device *dev) > { > struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev); > @@ -1177,12 +1175,6 @@ static const struct dev_pm_ops bcm_iproc_i2c_pm_ops = { > .resume_early = &bcm_iproc_i2c_resume > }; > > -#define BCM_IPROC_I2C_PM_OPS (&bcm_iproc_i2c_pm_ops) > -#else > -#define BCM_IPROC_I2C_PM_OPS NULL > -#endif /* CONFIG_PM_SLEEP */ > - > - > static int bcm_iproc_i2c_reg_slave(struct i2c_client *slave) > { > struct bcm_iproc_i2c_dev *iproc_i2c = i2c_get_adapdata(slave->adapter); > @@ -1255,7 +1247,7 @@ static struct platform_driver bcm_iproc_i2c_driver = { > .driver = { > .name = "bcm-iproc-i2c", > .of_match_table = bcm_iproc_i2c_of_match, > - .pm = BCM_IPROC_I2C_PM_OPS, > + .pm = pm_sleep_ptr(&bcm_iproc_i2c_pm_ops), > }, > .probe = bcm_iproc_i2c_probe, > .remove_new = bcm_iproc_i2c_remove, Thanks. Acked-by: Ray Jui <ray.jui@broadcom.com>
Hi Jonathan, Le jeudi 06 juillet 2023 à 10:09 +0800, Jonathan Cameron a écrit : > On Wed, 5 Jul 2023 22:42:52 +0200 > Paul Cercueil <paul@crapouillou.net> wrote: > > > Use the new PM macros for the suspend and resume functions to be > > automatically dropped by the compiler when CONFIG_PM or > > CONFIG_PM_SLEEP are 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. > > > > Note that the use of the UNIVERSAL_DEV_PM_OPS() macro was likely to > > be > > wrong, as it sets the same callbacks for the runtime-PM and system > > suspend/resume. This patch does not change this behaviour, but I > > suspect > > that it should be changed to use DEFINE_RUNTIME_DEV_PM_OPS() > > instead, as > > the current documentation for UNIVERSAL_DEV_PM_OPS() suggests. > > I'd be tempted to leave this one alone because it'll be much harder > to spot that it's an ex UNIVERSAL_DEV_PM_OPS() that needs some > thinking > about after this change. Ok, that's a good point. Cheers, -Paul > > > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > > > > --- > > Cc: Elie Morisse <syniurge@gmail.com> > > Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com> > > --- > > drivers/i2c/busses/i2c-amd-mp2-pci.c | 14 +++++--------- > > drivers/i2c/busses/i2c-amd-mp2-plat.c | 8 ++------ > > drivers/i2c/busses/i2c-amd-mp2.h | 2 -- > > 3 files changed, 7 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c > > b/drivers/i2c/busses/i2c-amd-mp2-pci.c > > index 143165300949..114fe329279a 100644 > > --- a/drivers/i2c/busses/i2c-amd-mp2-pci.c > > +++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c > > @@ -382,7 +382,6 @@ static void amd_mp2_pci_remove(struct pci_dev > > *pci_dev) > > amd_mp2_clear_reg(privdata); > > } > > > > -#ifdef CONFIG_PM > > static int amd_mp2_pci_suspend(struct device *dev) > > { > > struct pci_dev *pci_dev = to_pci_dev(dev); > > @@ -434,9 +433,10 @@ static int amd_mp2_pci_resume(struct device > > *dev) > > return ret; > > } > > > > -static UNIVERSAL_DEV_PM_OPS(amd_mp2_pci_pm_ops, > > amd_mp2_pci_suspend, > > - amd_mp2_pci_resume, NULL); > > -#endif /* CONFIG_PM */ > > +static const struct dev_pm_ops amd_mp2_pci_pm_ops = { > > + SYSTEM_SLEEP_PM_OPS(amd_mp2_pci_suspend, > > amd_mp2_pci_resume) > > + RUNTIME_PM_OPS(amd_mp2_pci_suspend, amd_mp2_pci_resume, > > NULL) > > +}; > > > > static const struct pci_device_id amd_mp2_pci_tbl[] = { > > {PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2)}, > > @@ -449,11 +449,7 @@ static struct pci_driver amd_mp2_pci_driver = > > { > > .id_table = amd_mp2_pci_tbl, > > .probe = amd_mp2_pci_probe, > > .remove = amd_mp2_pci_remove, > > -#ifdef CONFIG_PM > > - .driver = { > > - .pm = &amd_mp2_pci_pm_ops, > > - }, > > -#endif > > + .driver.pm = pm_ptr(&amd_mp2_pci_pm_ops), > > }; > > module_pci_driver(amd_mp2_pci_driver); > > > > diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c > > b/drivers/i2c/busses/i2c-amd-mp2-plat.c > > index 112fe2bc5662..4c677aeaca29 100644 > > --- a/drivers/i2c/busses/i2c-amd-mp2-plat.c > > +++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c > > @@ -183,7 +183,6 @@ static const struct i2c_algorithm > > i2c_amd_algorithm = { > > .functionality = i2c_amd_func, > > }; > > > > -#ifdef CONFIG_PM > > static int i2c_amd_suspend(struct amd_i2c_common *i2c_common) > > { > > struct amd_i2c_dev *i2c_dev = > > amd_i2c_dev_common(i2c_common); > > @@ -198,7 +197,6 @@ static int i2c_amd_resume(struct amd_i2c_common > > *i2c_common) > > > > return i2c_amd_enable_set(i2c_dev, true); > > } > > -#endif > > > > static const u32 supported_speeds[] = { > > I2C_MAX_HIGH_SPEED_MODE_FREQ, > > @@ -276,10 +274,8 @@ static int i2c_amd_probe(struct > > platform_device *pdev) > > platform_set_drvdata(pdev, i2c_dev); > > > > i2c_dev->common.cmd_completion = &i2c_amd_cmd_completion; > > -#ifdef CONFIG_PM > > - i2c_dev->common.suspend = &i2c_amd_suspend; > > - i2c_dev->common.resume = &i2c_amd_resume; > > -#endif > > + i2c_dev->common.suspend = pm_ptr(&i2c_amd_suspend); > > + i2c_dev->common.resume = pm_ptr(&i2c_amd_resume); > > > > /* Register the adapter */ > > amd_mp2_pm_runtime_get(mp2_dev); > > diff --git a/drivers/i2c/busses/i2c-amd-mp2.h > > b/drivers/i2c/busses/i2c-amd-mp2.h > > index 018a42de8b1e..40f3cdcc60aa 100644 > > --- a/drivers/i2c/busses/i2c-amd-mp2.h > > +++ b/drivers/i2c/busses/i2c-amd-mp2.h > > @@ -160,10 +160,8 @@ struct amd_i2c_common { > > enum speed_enum i2c_speed; > > u8 *dma_buf; > > dma_addr_t dma_addr; > > -#ifdef CONFIG_PM > > int (*suspend)(struct amd_i2c_common *i2c_common); > > int (*resume)(struct amd_i2c_common *i2c_common); > > -#endif /* CONFIG_PM */ > > }; > > > > /** >
Hi Jonathan, Le jeudi 06 juillet 2023 à 10:37 +0800, Jonathan Cameron a écrit : > On Wed, 5 Jul 2023 22:43:02 +0200 > Paul Cercueil <paul@crapouillou.net> wrote: > > > Use the new PM macros for the suspend and resume functions to be > > automatically dropped by the compiler when CONFIG_PM or > > CONFIG_PM_SLEEP are 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. > > > > Note that the driver should most likely be updated to use the > > platform_driver.driver.pm.{suspend,resume} callbacks. > > Agreed. In this particular case I'd be tempted to do that first > so that we don't introduce pm_ptr() usage for these hooks. > Look at the platform device core, I suspect they should be > pm_sleep_ptr() > but not 100% sure. Ok, I'll just convert it then, the diff won't be much bigger. Cheers, -Paul > Jonathan > > > > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > > --- > > drivers/i2c/busses/i2c-kempld.c | 9 ++------- > > 1 file changed, 2 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-kempld.c > > b/drivers/i2c/busses/i2c-kempld.c > > index 281058e3ea46..cb61e7b9202c 100644 > > --- a/drivers/i2c/busses/i2c-kempld.c > > +++ b/drivers/i2c/busses/i2c-kempld.c > > @@ -350,7 +350,6 @@ static void kempld_i2c_remove(struct > > platform_device *pdev) > > i2c_del_adapter(&i2c->adap); > > } > > > > -#ifdef CONFIG_PM > > static int kempld_i2c_suspend(struct platform_device *pdev, > > pm_message_t state) > > { > > struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); > > @@ -377,10 +376,6 @@ static int kempld_i2c_resume(struct > > platform_device *pdev) > > > > return 0; > > } > > -#else > > -#define kempld_i2c_suspend NULL > > -#define kempld_i2c_resume NULL > > -#endif > > > > static struct platform_driver kempld_i2c_driver = { > > .driver = { > > @@ -388,8 +383,8 @@ static struct platform_driver kempld_i2c_driver > > = { > > }, > > .probe = kempld_i2c_probe, > > .remove_new = kempld_i2c_remove, > > - .suspend = kempld_i2c_suspend, > > - .resume = kempld_i2c_resume, > > + .suspend = pm_ptr(kempld_i2c_suspend), > > + .resume = pm_ptr(kempld_i2c_resume), > > }; > > > > module_platform_driver(kempld_i2c_driver); >