[PATCH 11/28] mfd: intel_soc_pmic: Remove #ifdef guards for PM related functions

Paul Cercueil posted 28 patches 3 years, 8 months ago
There is a newer version of this series
[PATCH 11/28] mfd: intel_soc_pmic: Remove #ifdef guards for PM related functions
Posted by Paul Cercueil 3 years, 8 months ago
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.

The advantage is then that these functions are now always compiled
independently of any Kconfig option, and thanks to that bugs and
regressions are easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Cc: Andy Shevchenko <andy@kernel.org>
---
 drivers/mfd/intel_soc_pmic_bxtwc.c | 7 +++----
 drivers/mfd/intel_soc_pmic_core.c  | 8 +++-----
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index bc069c4daa60..7110d91f7ace 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -586,7 +586,6 @@ static void bxtwc_shutdown(struct platform_device *pdev)
 	disable_irq(pmic->irq);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int bxtwc_suspend(struct device *dev)
 {
 	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
@@ -603,8 +602,8 @@ static int bxtwc_resume(struct device *dev)
 	enable_irq(pmic->irq);
 	return 0;
 }
-#endif
-static SIMPLE_DEV_PM_OPS(bxtwc_pm_ops, bxtwc_suspend, bxtwc_resume);
+
+static DEFINE_SIMPLE_DEV_PM_OPS(bxtwc_pm_ops, bxtwc_suspend, bxtwc_resume);
 
 static const struct acpi_device_id bxtwc_acpi_ids[] = {
 	{ "INT34D3", },
@@ -618,7 +617,7 @@ static struct platform_driver bxtwc_driver = {
 	.shutdown = bxtwc_shutdown,
 	.driver	= {
 		.name	= "BXTWC PMIC",
-		.pm     = &bxtwc_pm_ops,
+		.pm     = pm_sleep_ptr(&bxtwc_pm_ops),
 		.acpi_match_table = ACPI_PTR(bxtwc_acpi_ids),
 	},
 };
diff --git a/drivers/mfd/intel_soc_pmic_core.c b/drivers/mfd/intel_soc_pmic_core.c
index 5e8c94e008ed..96303aa87bc1 100644
--- a/drivers/mfd/intel_soc_pmic_core.c
+++ b/drivers/mfd/intel_soc_pmic_core.c
@@ -104,7 +104,6 @@ static void intel_soc_pmic_shutdown(struct i2c_client *i2c)
 	return;
 }
 
-#if defined(CONFIG_PM_SLEEP)
 static int intel_soc_pmic_suspend(struct device *dev)
 {
 	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
@@ -122,10 +121,9 @@ static int intel_soc_pmic_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(intel_soc_pmic_pm_ops, intel_soc_pmic_suspend,
-			 intel_soc_pmic_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(intel_soc_pmic_pm_ops, intel_soc_pmic_suspend,
+				intel_soc_pmic_resume);
 
 static const struct i2c_device_id intel_soc_pmic_i2c_id[] = {
 	{ }
@@ -143,7 +141,7 @@ MODULE_DEVICE_TABLE(acpi, intel_soc_pmic_acpi_match);
 static struct i2c_driver intel_soc_pmic_i2c_driver = {
 	.driver = {
 		.name = "intel_soc_pmic_i2c",
-		.pm = &intel_soc_pmic_pm_ops,
+		.pm = pm_sleep_ptr(&intel_soc_pmic_pm_ops),
 		.acpi_match_table = ACPI_PTR(intel_soc_pmic_acpi_match),
 	},
 	.probe = intel_soc_pmic_i2c_probe,
-- 
2.35.1
Re: [PATCH 11/28] mfd: intel_soc_pmic: Remove #ifdef guards for PM related functions
Posted by Andy Shevchenko 3 years, 8 months ago
On Sun, Aug 7, 2022 at 4:53 PM Paul Cercueil <paul@crapouillou.net> wrote:
>
> 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.
>
> The advantage is then that these functions are now always compiled

is that

> independently of any Kconfig option, and thanks to that bugs and
> regressions are easier to catch.

...

>  drivers/mfd/intel_soc_pmic_bxtwc.c | 7 +++----
>  drivers/mfd/intel_soc_pmic_core.c  | 8 +++-----

1. These are two different drivers, the patch needs to be split.
2. The Broxton Whiskey Cove should have a similar change. Which base
have you used for your patch? Please, rebase on top of for-mfd-next.
3. The PMIC core actually is Crystal Cove driver and I have a pending
series for that and I guess you know about it. Have you seen what have
been done there?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH 11/28] mfd: intel_soc_pmic: Remove #ifdef guards for PM related functions
Posted by Paul Cercueil 3 years, 8 months ago

Le dim., août 7 2022 at 17:50:32 +0200, Andy Shevchenko 
<andy.shevchenko@gmail.com> a écrit :
> On Sun, Aug 7, 2022 at 4:53 PM Paul Cercueil <paul@crapouillou.net> 
> wrote:
>> 
>>  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.
>> 
>>  The advantage is then that these functions are now always compiled
> 
> is that

I think that what I wrote is proper English.

> 
>>  independently of any Kconfig option, and thanks to that bugs and
>>  regressions are easier to catch.
> 
> ...
> 
>>   drivers/mfd/intel_soc_pmic_bxtwc.c | 7 +++----
>>   drivers/mfd/intel_soc_pmic_core.c  | 8 +++-----
> 
> 1. These are two different drivers, the patch needs to be split.

Ok.

> 2. The Broxton Whiskey Cove should have a similar change. Which base
> have you used for your patch? Please, rebase on top of for-mfd-next.

That's based on v5.19.

> 3. The PMIC core actually is Crystal Cove driver and I have a pending
> series for that and I guess you know about it. Have you seen what have
> been done there?

No, I didn't know. I guess Lee can skip my patch 11/28 then.

Cheers,
-Paul
Re: [PATCH 11/28] mfd: intel_soc_pmic: Remove #ifdef guards for PM related functions
Posted by Andy Shevchenko 3 years, 8 months ago
On Sun, Aug 7, 2022 at 5:58 PM Paul Cercueil <paul@crapouillou.net> wrote:
> Le dim., août 7 2022 at 17:50:32 +0200, Andy Shevchenko
> <andy.shevchenko@gmail.com> a écrit :
> > On Sun, Aug 7, 2022 at 4:53 PM Paul Cercueil <paul@crapouillou.net>
> > wrote:

...

> >>  The advantage is then that these functions are now always compiled
> >
> > is that
>
> I think that what I wrote is proper English.

Okay, Google just shows 100x times less the above form in comparison
to one w/o "then".

> >>  independently of any Kconfig option, and thanks to that bugs and
> >>  regressions are easier to catch.

...

> > 3. The PMIC core actually is Crystal Cove driver and I have a pending
> > series for that and I guess you know about it. Have you seen what have
> > been done there?
>
> No, I didn't know. I guess Lee can skip my patch 11/28 then.

I probably memorized the name of a guy, who sent a patch against this
driver a week ago or so, wrongly. Sorry for that.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH 11/28] mfd: intel_soc_pmic: Remove #ifdef guards for PM related functions
Posted by Lee Jones 3 years, 8 months ago
On Mon, 08 Aug 2022, Andy Shevchenko wrote:

> On Sun, Aug 7, 2022 at 5:58 PM Paul Cercueil <paul@crapouillou.net> wrote:
> > Le dim., août 7 2022 at 17:50:32 +0200, Andy Shevchenko
> > <andy.shevchenko@gmail.com> a écrit :
> > > On Sun, Aug 7, 2022 at 4:53 PM Paul Cercueil <paul@crapouillou.net>
> > > wrote:
> 
> ...
> 
> > >>  The advantage is then that these functions are now always compiled
> > >
> > > is that
> >
> > I think that what I wrote is proper English.
> 
> Okay, Google just shows 100x times less the above form in comparison
> to one w/o "then".

> The advantage is then that these functions are now always compile
> independently of any Kconfig option, and thanks to that bugs and
> regressions are easier to catch.

 "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."

> > >>  independently of any Kconfig option, and thanks to that bugs and
> > >>  regressions are easier to catch.
> 
> ...
> 
> > > 3. The PMIC core actually is Crystal Cove driver and I have a pending
> > > series for that and I guess you know about it. Have you seen what have
> > > been done there?
> >
> > No, I didn't know. I guess Lee can skip my patch 11/28 then.
> 
> I probably memorized the name of a guy, who sent a patch against this
> driver a week ago or so, wrongly. Sorry for that.
> 

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog