Skip to contentSkip to conversation

pinctrl: intel: Use NOIRQ PM helper

PATCH In review Andy Shevchenko 4 participants 24 messages Oct 30, 2023 – Nov 13, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover pinctrl: intel: Use NOIRQ PM helper

Intel pin control drivers use NOIRQ variant of the PM callbacks. To make them smaller and less error prone against different kernel configurations (with possible defined but not used variables) switch to use NOIRQ PM helper.

Changelog v3:
- dropped applied patches
- dropped MediaTek patch for now
- split Intel patch to the series using suggection by Paul

Changelog v2:
- rewritten commit message in patch 1 (Rafael)
- converted non-Intel pin control drivers as well
- added couple of kinda related patches to use pm_ptr()

Andy Shevchenko (17):
pinctrl: intel: Provide Intel pin control wide PM ops structure
pinctrl: alderlake: Switch to use Intel pin control PM ops
pinctrl: broxton: Switch to use Intel pin control PM ops
pinctrl: cannonlake: Switch to use Intel pin control PM ops
pinctrl: cedarfork: Switch to use Intel pin control PM ops
pinctrl: denverton: Switch to use Intel pin control PM ops
pinctrl: elkhartlake: Switch to use Intel pin control PM ops
pinctrl: emmitsburg: Switch to use Intel pin control PM ops
pinctrl: geminilake: Switch to use Intel pin control PM ops
pinctrl: icelake: Switch to use Intel pin control PM ops
pinctrl: jasperlake: Switch to use Intel pin control PM ops
pinctrl: lakefield: Switch to use Intel pin control PM ops
pinctrl: lewisburg: Switch to use Intel pin control PM ops
pinctrl: meteorlake: Switch to use Intel pin control PM ops
pinctrl: sunrisepoint: Switch to use Intel pin control PM ops
pinctrl: tigerlake: Switch to use Intel pin control PM ops
pinctrl: intel: Make PM ops functions static

 drivers/pinctrl/intel/pinctrl-alderlake.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-broxton.c      |  5 ++---
 drivers/pinctrl/intel/pinctrl-cannonlake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-cedarfork.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-denverton.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-elkhartlake.c  |  5 ++---
 drivers/pinctrl/intel/pinctrl-emmitsburg.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-geminilake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-icelake.c      |  5 ++---
 drivers/pinctrl/intel/pinctrl-intel.c        | 14 +++++++-------
 drivers/pinctrl/intel/pinctrl-intel.h        | 11 +----------
 drivers/pinctrl/intel/pinctrl-jasperlake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-lakefield.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-lewisburg.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-meteorlake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-sunrisepoint.c |  5 ++---
 drivers/pinctrl/intel/pinctrl-tigerlake.c    |  5 ++---
 17 files changed, 38 insertions(+), 62 deletions(-)
Signature · 1 line
2.40.0.1.gaa8946217a0b
#1 lore raw

PATCH v3 1/17 pinctrl: intel: Provide Intel pin control wide PM ops structure

With the help of EXPORT_NS_GPL_DEV_PM_OPS() and NOIRQ_SYSTEM_SLEEP_PM_OPS() we may convert PM ops functions to become static. This also takes into account the PM configuration options such as CONFIG_PM and CONFIG_PM_SLEEP. Hence the first step is to provide a generic PM ops structure that can be used by drivers directly.

---
 drivers/pinctrl/intel/pinctrl-intel.c | 8 +++++---
 drivers/pinctrl/intel/pinctrl-intel.h | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +5 -3
index b19527a8728e..9fbdc7bfa65c 100644
@@ -899,7 +899,7 @@ static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned int offset,
  *
  * Return: a GPIO offset, or negative error code if translation can't be done.
  */
-static __maybe_unused int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin)
+static int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin)
 {
 	const struct intel_community *community;
 	const struct intel_padgroup *padgrp;
@@ -1682,7 +1682,6 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
 }
 EXPORT_SYMBOL_NS_GPL(intel_pinctrl_get_soc_data, PINCTRL_INTEL);
 
-#ifdef CONFIG_PM_SLEEP
 static bool __intel_gpio_is_direct_irq(u32 value)
 {
 	return (value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) &&
@@ -1883,7 +1882,10 @@ int intel_pinctrl_resume_noirq(struct device *dev)
 	return 0;
 }
 EXPORT_SYMBOL_GPL(intel_pinctrl_resume_noirq);
-#endif
+
+EXPORT_NS_GPL_DEV_PM_OPS(intel_pinctrl_pm_ops, PINCTRL_INTEL) = {
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend_noirq, intel_pinctrl_resume_noirq)
+};
 
 MODULE_AUTHOR("Mathias Nyman <[email protected]>");
 MODULE_AUTHOR("Mika Westerberg <[email protected]>");
drivers/pinctrl/intel/pinctrl-intel.h +2 -2
index 2bb553598e8b..d3f511f97ed9 100644
@@ -255,10 +255,8 @@ struct intel_pinctrl {
 int intel_pinctrl_probe_by_hid(struct platform_device *pdev);
 int intel_pinctrl_probe_by_uid(struct platform_device *pdev);
 
-#ifdef CONFIG_PM_SLEEP
 int intel_pinctrl_suspend_noirq(struct device *dev);
 int intel_pinctrl_resume_noirq(struct device *dev);
-#endif
 
 #define INTEL_PINCTRL_PM_OPS(_name)					\
 const struct dev_pm_ops _name = {					\
@@ -266,6 +264,8 @@ const struct dev_pm_ops _name = {					\
 				      intel_pinctrl_resume_noirq)	\
 }
 
+extern const struct dev_pm_ops intel_pinctrl_pm_ops;
+
 struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin);
 
 int intel_get_groups_count(struct pinctrl_dev *pctldev);
Signature · 1 line
2.40.0.1.gaa8946217a0b
Reviewed-by on v3 1/17
#2 lore raw

Re: [PATCH v3 01/17] pinctrl: intel: Provide Intel pin control wide PM ops structure

Quoted 5 lines · On Mon, 30 Oct 2023 14:07:18 +0200 Andy Shevchenko…

With the help of EXPORT_NS_GPL_DEV_PM_OPS() and NOIRQ_SYSTEM_SLEEP_PM_OPS() we may convert PM ops functions to become static. This also takes into account the PM configuration options such as CONFIG_PM and CONFIG_PM_SLEEP. Hence the first step is to provide a generic PM ops structure that can be used by drivers directly.

It's a good thing to do, but if rolling a v3, should mention that the export moves into the namespace.

Quoted 2 lines

Other than that,
LGTM

Quoted 62 lines
---
 drivers/pinctrl/intel/pinctrl-intel.c | 8 +++++---
 drivers/pinctrl/intel/pinctrl-intel.h | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +5 -3
index b19527a8728e..9fbdc7bfa65c 100644
@@ -899,7 +899,7 @@ static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned int offset,
  *
  * Return: a GPIO offset, or negative error code if translation can't be done.
  */
-static __maybe_unused int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin)
+static int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin)
 {
 	const struct intel_community *community;
 	const struct intel_padgroup *padgrp;
@@ -1682,7 +1682,6 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
 }
 EXPORT_SYMBOL_NS_GPL(intel_pinctrl_get_soc_data, PINCTRL_INTEL);
 
-#ifdef CONFIG_PM_SLEEP
 static bool __intel_gpio_is_direct_irq(u32 value)
 {
 	return (value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) &&
@@ -1883,7 +1882,10 @@ int intel_pinctrl_resume_noirq(struct device *dev)
 	return 0;
 }
 EXPORT_SYMBOL_GPL(intel_pinctrl_resume_noirq);
-#endif
+
+EXPORT_NS_GPL_DEV_PM_OPS(intel_pinctrl_pm_ops, PINCTRL_INTEL) = {
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend_noirq, intel_pinctrl_resume_noirq)
+};
 
 MODULE_AUTHOR("Mathias Nyman <[email protected]>");
 MODULE_AUTHOR("Mika Westerberg <[email protected]>");
drivers/pinctrl/intel/pinctrl-intel.h +2 -2
index 2bb553598e8b..d3f511f97ed9 100644
@@ -255,10 +255,8 @@ struct intel_pinctrl {
 int intel_pinctrl_probe_by_hid(struct platform_device *pdev);
 int intel_pinctrl_probe_by_uid(struct platform_device *pdev);
 
-#ifdef CONFIG_PM_SLEEP
 int intel_pinctrl_suspend_noirq(struct device *dev);
 int intel_pinctrl_resume_noirq(struct device *dev);
-#endif
 
 #define INTEL_PINCTRL_PM_OPS(_name)					\
 const struct dev_pm_ops _name = {					\
@@ -266,6 +264,8 @@ const struct dev_pm_ops _name = {					\
 				      intel_pinctrl_resume_noirq)	\
 }
 
+extern const struct dev_pm_ops intel_pinctrl_pm_ops;
+
 struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin);
 
 int intel_get_groups_count(struct pinctrl_dev *pctldev);
#3 lore raw

Re: [PATCH v3 01/17] pinctrl: intel: Provide Intel pin control wide PM ops structure

Quoted 13 lines · On Mon, 30 Oct 2023 19:41:12 +0000 Jonathan Cameron…
Quoted 5 lines · On Mon, 30 Oct 2023 14:07:18 +0200 Andy Shevchenko…

With the help of EXPORT_NS_GPL_DEV_PM_OPS() and NOIRQ_SYSTEM_SLEEP_PM_OPS() we may convert PM ops functions to become static. This also takes into account the PM configuration options such as CONFIG_PM and CONFIG_PM_SLEEP. Hence the first step is to provide a generic PM ops structure that can be used by drivers directly.

It's a good thing to do, but if rolling a v3, should mention that the export moves into the namespace.

Quoted 1 line
Quoted 6 lines
Quoted 1 line

Other than that,
LGTM

Actually looking at usecase, why isn't the absence of an EXPORT in the !CONFIG_PM_SLEEP path not a problem for bisection of this series given you haven't yet protected the users?

Jonathan

Quoted 63 lines
Quoted 62 lines
---
 drivers/pinctrl/intel/pinctrl-intel.c | 8 +++++---
 drivers/pinctrl/intel/pinctrl-intel.h | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +5 -3
index b19527a8728e..9fbdc7bfa65c 100644
@@ -899,7 +899,7 @@ static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned int offset,
  *
  * Return: a GPIO offset, or negative error code if translation can't be done.
  */
-static __maybe_unused int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin)
+static int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin)
 {
 	const struct intel_community *community;
 	const struct intel_padgroup *padgrp;
@@ -1682,7 +1682,6 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
 }
 EXPORT_SYMBOL_NS_GPL(intel_pinctrl_get_soc_data, PINCTRL_INTEL);
 
-#ifdef CONFIG_PM_SLEEP
 static bool __intel_gpio_is_direct_irq(u32 value)
 {
 	return (value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) &&
@@ -1883,7 +1882,10 @@ int intel_pinctrl_resume_noirq(struct device *dev)
 	return 0;
 }
 EXPORT_SYMBOL_GPL(intel_pinctrl_resume_noirq);
-#endif
+
+EXPORT_NS_GPL_DEV_PM_OPS(intel_pinctrl_pm_ops, PINCTRL_INTEL) = {
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend_noirq, intel_pinctrl_resume_noirq)
+};
 
 MODULE_AUTHOR("Mathias Nyman <[email protected]>");
 MODULE_AUTHOR("Mika Westerberg <[email protected]>");
drivers/pinctrl/intel/pinctrl-intel.h +2 -2
index 2bb553598e8b..d3f511f97ed9 100644
@@ -255,10 +255,8 @@ struct intel_pinctrl {
 int intel_pinctrl_probe_by_hid(struct platform_device *pdev);
 int intel_pinctrl_probe_by_uid(struct platform_device *pdev);
 
-#ifdef CONFIG_PM_SLEEP
 int intel_pinctrl_suspend_noirq(struct device *dev);
 int intel_pinctrl_resume_noirq(struct device *dev);
-#endif
 
 #define INTEL_PINCTRL_PM_OPS(_name)					\
 const struct dev_pm_ops _name = {					\
@@ -266,6 +264,8 @@ const struct dev_pm_ops _name = {					\
 				      intel_pinctrl_resume_noirq)	\
 }
 
+extern const struct dev_pm_ops intel_pinctrl_pm_ops;
+
 struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin);
 
 int intel_get_groups_count(struct pinctrl_dev *pctldev);  
#4 lore raw

Re: [PATCH v3 01/17] pinctrl: intel: Provide Intel pin control wide PM ops structure

Quoted 2 lines · Jonathan Cameron

On Mon, 30 Oct 2023 19:41:12 +0000
Jonathan Cameron <[email protected]> wrote:

...

Quoted 3 lines

Actually looking at usecase, why isn't the absence of an EXPORT in the !CONFIG_PM_SLEEP path not a problem for bisection of this series given you haven't yet protected the users?

I'm not sure I got the issue you are trying to point out.
Between first and last patches the main driver exports two things: the PM ops functions, which are _always_ been exported and PM ops structure, which is exported only when CONFIG_PM_SLEEP=y. Every converted user has pm_sleep_ptr() guard added so it shouldn't be a problem. What exactly did I miss?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

PATCH v3 2/17 pinctrl: alderlake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-alderlake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-alderlake.c +2 -3
index 4a37dc273d63..7d9948e5f422 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -733,14 +734,12 @@ static const struct acpi_device_id adl_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, adl_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(adl_pinctrl_pm_ops);
-
 static struct platform_driver adl_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "alderlake-pinctrl",
 		.acpi_match_table = adl_pinctrl_acpi_match,
-		.pm = &adl_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(adl_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#6 lore raw

PATCH v3 3/17 pinctrl: broxton: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-broxton.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-broxton.c +2 -3
index 3118c7c8842f..d99541676630 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -1000,14 +1001,12 @@ static const struct platform_device_id bxt_pinctrl_platform_ids[] = {
 };
 MODULE_DEVICE_TABLE(platform, bxt_pinctrl_platform_ids);
 
-static INTEL_PINCTRL_PM_OPS(bxt_pinctrl_pm_ops);
-
 static struct platform_driver bxt_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_uid,
 	.driver = {
 		.name = "broxton-pinctrl",
 		.acpi_match_table = bxt_pinctrl_acpi_match,
-		.pm = &bxt_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 	.id_table = bxt_pinctrl_platform_ids,
 };
Signature · 1 line
2.40.0.1.gaa8946217a0b
#7 lore raw

PATCH v3 4/17 pinctrl: cannonlake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-cannonlake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-cannonlake.c +2 -3
index 95976abfb785..1aa09f950be1 100644
@@ -10,6 +10,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -824,14 +825,12 @@ static const struct acpi_device_id cnl_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, cnl_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(cnl_pinctrl_pm_ops);
-
 static struct platform_driver cnl_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "cannonlake-pinctrl",
 		.acpi_match_table = cnl_pinctrl_acpi_match,
-		.pm = &cnl_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(cnl_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#8 lore raw

PATCH v3 5/17 pinctrl: cedarfork: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-cedarfork.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-cedarfork.c +2 -3
index a20465eb2dc6..48af8930dd1f 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -319,8 +320,6 @@ static const struct intel_pinctrl_soc_data cdf_soc_data = {
 	.ncommunities = ARRAY_SIZE(cdf_communities),
 };
 
-static INTEL_PINCTRL_PM_OPS(cdf_pinctrl_pm_ops);
-
 static const struct acpi_device_id cdf_pinctrl_acpi_match[] = {
 	{ "INTC3001", (kernel_ulong_t)&cdf_soc_data },
 	{ }
@@ -332,7 +331,7 @@ static struct platform_driver cdf_pinctrl_driver = {
 	.driver = {
 		.name = "cedarfork-pinctrl",
 		.acpi_match_table = cdf_pinctrl_acpi_match,
-		.pm = &cdf_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 
Signature · 1 line
2.40.0.1.gaa8946217a0b
#9 lore raw

PATCH v3 6/17 pinctrl: denverton: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-denverton.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-denverton.c +2 -3
index 562a4f9188e4..666507f54f27 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -249,8 +250,6 @@ static const struct intel_pinctrl_soc_data dnv_soc_data = {
 	.ncommunities = ARRAY_SIZE(dnv_communities),
 };
 
-static INTEL_PINCTRL_PM_OPS(dnv_pinctrl_pm_ops);
-
 static const struct acpi_device_id dnv_pinctrl_acpi_match[] = {
 	{ "INTC3000", (kernel_ulong_t)&dnv_soc_data },
 	{ }
@@ -268,7 +267,7 @@ static struct platform_driver dnv_pinctrl_driver = {
 	.driver = {
 		.name = "denverton-pinctrl",
 		.acpi_match_table = dnv_pinctrl_acpi_match,
-		.pm = &dnv_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 	.id_table = dnv_pinctrl_platform_ids,
 };
Signature · 1 line
2.40.0.1.gaa8946217a0b
#10 lore raw

PATCH v3 7/17 pinctrl: elkhartlake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-elkhartlake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-elkhartlake.c +2 -3
index 81581ab85316..1678634ebc06 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -485,14 +486,12 @@ static const struct acpi_device_id ehl_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, ehl_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(ehl_pinctrl_pm_ops);
-
 static struct platform_driver ehl_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_uid,
 	.driver = {
 		.name = "elkhartlake-pinctrl",
 		.acpi_match_table = ehl_pinctrl_acpi_match,
-		.pm = &ehl_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(ehl_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#11 lore raw

PATCH v3 8/17 pinctrl: emmitsburg: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-emmitsburg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-emmitsburg.c +2 -3
index 099ec8351d5f..e4798d32492c 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -358,14 +359,12 @@ static const struct acpi_device_id ebg_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, ebg_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(ebg_pinctrl_pm_ops);
-
 static struct platform_driver ebg_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "emmitsburg-pinctrl",
 		.acpi_match_table = ebg_pinctrl_acpi_match,
-		.pm = &ebg_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(ebg_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#12 lore raw

PATCH v3 9/17 pinctrl: geminilake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-geminilake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-geminilake.c +2 -3
index 9effa06b61e9..6dcf0ac2059f 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -447,14 +448,12 @@ static const struct acpi_device_id glk_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, glk_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(glk_pinctrl_pm_ops);
-
 static struct platform_driver glk_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_uid,
 	.driver = {
 		.name = "geminilake-pinctrl",
 		.acpi_match_table = glk_pinctrl_acpi_match,
-		.pm = &glk_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 
Signature · 1 line
2.40.0.1.gaa8946217a0b
#13 lore raw

PATCH v3 10/17 pinctrl: icelake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-icelake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-icelake.c +2 -3
index 300e1538c8d0..fe3042de891a 100644
@@ -10,6 +10,7 @@
 #include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -668,8 +669,6 @@ static const struct intel_pinctrl_soc_data icln_soc_data = {
 	.ncommunities = ARRAY_SIZE(icln_communities),
 };
 
-static INTEL_PINCTRL_PM_OPS(icl_pinctrl_pm_ops);
-
 static const struct acpi_device_id icl_pinctrl_acpi_match[] = {
 	{ "INT3455", (kernel_ulong_t)&icllp_soc_data },
 	{ "INT34C3", (kernel_ulong_t)&icln_soc_data },
@@ -682,7 +681,7 @@ static struct platform_driver icl_pinctrl_driver = {
 	.driver = {
 		.name = "icelake-pinctrl",
 		.acpi_match_table = icl_pinctrl_acpi_match,
-		.pm = &icl_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(icl_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#14 lore raw

PATCH v3 11/17 pinctrl: jasperlake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-jasperlake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-jasperlake.c +2 -3
index 50f137deed9c..3525480428ea 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -326,14 +327,12 @@ static const struct acpi_device_id jsl_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, jsl_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(jsl_pinctrl_pm_ops);
-
 static struct platform_driver jsl_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "jasperlake-pinctrl",
 		.acpi_match_table = jsl_pinctrl_acpi_match,
-		.pm = &jsl_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(jsl_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#15 lore raw

PATCH v3 12/17 pinctrl: lakefield: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-lakefield.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-lakefield.c +2 -3
index 0b94e11b78ac..adef85db82ca 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -347,14 +348,12 @@ static const struct acpi_device_id lkf_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, lkf_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(lkf_pinctrl_pm_ops);
-
 static struct platform_driver lkf_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "lakefield-pinctrl",
 		.acpi_match_table = lkf_pinctrl_acpi_match,
-		.pm = &lkf_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(lkf_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#16 lore raw

PATCH v3 13/17 pinctrl: lewisburg: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-lewisburg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-lewisburg.c +2 -3
index aa725a5d62b9..a304d30ea9ed 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -301,8 +302,6 @@ static const struct intel_pinctrl_soc_data lbg_soc_data = {
 	.ncommunities = ARRAY_SIZE(lbg_communities),
 };
 
-static INTEL_PINCTRL_PM_OPS(lbg_pinctrl_pm_ops);
-
 static const struct acpi_device_id lbg_pinctrl_acpi_match[] = {
 	{ "INT3536", (kernel_ulong_t)&lbg_soc_data },
 	{ }
@@ -314,7 +313,7 @@ static struct platform_driver lbg_pinctrl_driver = {
 	.driver = {
 		.name = "lewisburg-pinctrl",
 		.acpi_match_table = lbg_pinctrl_acpi_match,
-		.pm = &lbg_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(lbg_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#17 lore raw

PATCH v3 14/17 pinctrl: meteorlake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-meteorlake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-meteorlake.c +2 -3
index 7ced2b402dce..cc44890c6699 100644
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -589,14 +590,12 @@ static const struct acpi_device_id mtl_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, mtl_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(mtl_pinctrl_pm_ops);
-
 static struct platform_driver mtl_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "meteorlake-pinctrl",
 		.acpi_match_table = mtl_pinctrl_acpi_match,
-		.pm = &mtl_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(mtl_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#18 lore raw

PATCH v3 15/17 pinctrl: sunrisepoint: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-sunrisepoint.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-sunrisepoint.c +2 -3
index b7a40ab0bca8..55df9d2cfb1b 100644
@@ -10,6 +10,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -579,14 +580,12 @@ static const struct acpi_device_id spt_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, spt_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(spt_pinctrl_pm_ops);
-
 static struct platform_driver spt_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "sunrisepoint-pinctrl",
 		.acpi_match_table = spt_pinctrl_acpi_match,
-		.pm = &spt_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 
Signature · 1 line
2.40.0.1.gaa8946217a0b
#19 lore raw

PATCH v3 16/17 pinctrl: tigerlake: Switch to use Intel pin control PM ops

In reply to Andy Shevchenko

The main driver conditionally exports the PM ops structure. Switch this driver to use it instead of customly wrapped one.

---
 drivers/pinctrl/intel/pinctrl-tigerlake.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-tigerlake.c +2 -3
index 4768a69a9258..80cd7a06fe5a 100644
@@ -10,6 +10,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <linux/pinctrl/pinctrl.h>
 
@@ -743,14 +744,12 @@ static const struct acpi_device_id tgl_pinctrl_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, tgl_pinctrl_acpi_match);
 
-static INTEL_PINCTRL_PM_OPS(tgl_pinctrl_pm_ops);
-
 static struct platform_driver tgl_pinctrl_driver = {
 	.probe = intel_pinctrl_probe_by_hid,
 	.driver = {
 		.name = "tigerlake-pinctrl",
 		.acpi_match_table = tgl_pinctrl_acpi_match,
-		.pm = &tgl_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&intel_pinctrl_pm_ops),
 	},
 };
 module_platform_driver(tgl_pinctrl_driver);
Signature · 1 line
2.40.0.1.gaa8946217a0b
#20 lore raw

PATCH v3 17/17 pinctrl: intel: Make PM ops functions static

In reply to Andy Shevchenko

No more users outside of the main module.

---
 drivers/pinctrl/intel/pinctrl-intel.c | 6 ++----
 drivers/pinctrl/intel/pinctrl-intel.h | 9 ---------
 2 files changed, 2 insertions(+), 13 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +2 -4
index 9fbdc7bfa65c..f1d8f7e0d9b7 100644
@@ -1727,7 +1727,7 @@ static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int
 	return false;
 }
 
-int intel_pinctrl_suspend_noirq(struct device *dev)
+static int intel_pinctrl_suspend_noirq(struct device *dev)
 {
 	struct intel_pinctrl *pctrl = dev_get_drvdata(dev);
 	struct intel_community_context *communities;
@@ -1770,7 +1770,6 @@ int intel_pinctrl_suspend_noirq(struct device *dev)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(intel_pinctrl_suspend_noirq);
 
 static bool intel_gpio_update_reg(void __iomem *reg, u32 mask, u32 value)
 {
@@ -1837,7 +1836,7 @@ static void intel_restore_padcfg(struct intel_pinctrl *pctrl, unsigned int pin,
 	dev_dbg(dev, "restored pin %u padcfg%u %#08x\n", pin, n, readl(padcfg));
 }
 
-int intel_pinctrl_resume_noirq(struct device *dev)
+static int intel_pinctrl_resume_noirq(struct device *dev)
 {
 	struct intel_pinctrl *pctrl = dev_get_drvdata(dev);
 	const struct intel_community_context *communities;
@@ -1881,7 +1880,6 @@ int intel_pinctrl_resume_noirq(struct device *dev)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(intel_pinctrl_resume_noirq);
 
 EXPORT_NS_GPL_DEV_PM_OPS(intel_pinctrl_pm_ops, PINCTRL_INTEL) = {
 	NOIRQ_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend_noirq, intel_pinctrl_resume_noirq)
drivers/pinctrl/intel/pinctrl-intel.h +0 -9
index d3f511f97ed9..e7d911a65584 100644
@@ -255,15 +255,6 @@ struct intel_pinctrl {
 int intel_pinctrl_probe_by_hid(struct platform_device *pdev);
 int intel_pinctrl_probe_by_uid(struct platform_device *pdev);
 
-int intel_pinctrl_suspend_noirq(struct device *dev);
-int intel_pinctrl_resume_noirq(struct device *dev);
-
-#define INTEL_PINCTRL_PM_OPS(_name)					\
-const struct dev_pm_ops _name = {					\
-	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend_noirq,	\
-				      intel_pinctrl_resume_noirq)	\
-}
-
 extern const struct dev_pm_ops intel_pinctrl_pm_ops;
 
 struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin);
Signature · 1 line
2.40.0.1.gaa8946217a0b
Acked-by on the v3 series
#21 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

Intel pin control drivers use NOIRQ variant of the PM callbacks. To make them smaller and less error prone against different kernel configurations (with possible defined but not used variables) switch to use NOIRQ PM helper.

Makes sense. The series:

Yours,
Linus Walleij

maintainer Acked-by on the v3 series
#22 lore raw
In reply to Andy Shevchenko

Hi Andy,

Quoted 44 lines · Andy Shevchenko

Intel pin control drivers use NOIRQ variant of the PM callbacks. To make them smaller and less error prone against different kernel configurations (with possible defined but not used variables) switch to use NOIRQ PM helper.

Changelog v3:
- dropped applied patches
- dropped MediaTek patch for now
- split Intel patch to the series using suggection by Paul

Changelog v2:
- rewritten commit message in patch 1 (Rafael)
- converted non-Intel pin control drivers as well
- added couple of kinda related patches to use pm_ptr()

Andy Shevchenko (17):
pinctrl: intel: Provide Intel pin control wide PM ops structure
pinctrl: alderlake: Switch to use Intel pin control PM ops
pinctrl: broxton: Switch to use Intel pin control PM ops
pinctrl: cannonlake: Switch to use Intel pin control PM ops
pinctrl: cedarfork: Switch to use Intel pin control PM ops
pinctrl: denverton: Switch to use Intel pin control PM ops
pinctrl: elkhartlake: Switch to use Intel pin control PM ops
pinctrl: emmitsburg: Switch to use Intel pin control PM ops
pinctrl: geminilake: Switch to use Intel pin control PM ops
pinctrl: icelake: Switch to use Intel pin control PM ops
pinctrl: jasperlake: Switch to use Intel pin control PM ops
pinctrl: lakefield: Switch to use Intel pin control PM ops
pinctrl: lewisburg: Switch to use Intel pin control PM ops
pinctrl: meteorlake: Switch to use Intel pin control PM ops
pinctrl: sunrisepoint: Switch to use Intel pin control PM ops
pinctrl: tigerlake: Switch to use Intel pin control PM ops
pinctrl: intel: Make PM ops functions static

 drivers/pinctrl/intel/pinctrl-alderlake.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-broxton.c      |  5 ++---
 drivers/pinctrl/intel/pinctrl-cannonlake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-cedarfork.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-denverton.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-elkhartlake.c  |  5 ++---
 drivers/pinctrl/intel/pinctrl-emmitsburg.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-geminilake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-icelake.c      |  5 ++---
 drivers/pinctrl/intel/pinctrl-intel.c        | 14 +++++++-------
Quoted 8 lines
 drivers/pinctrl/intel/pinctrl-intel.h        | 11 +----------
 drivers/pinctrl/intel/pinctrl-jasperlake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-lakefield.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-lewisburg.c    |  5 ++---
 drivers/pinctrl/intel/pinctrl-meteorlake.c   |  5 ++---
 drivers/pinctrl/intel/pinctrl-sunrisepoint.c |  5 ++---
 drivers/pinctrl/intel/pinctrl-tigerlake.c    |  5 ++---
 17 files changed, 38 insertions(+), 62 deletions(-)

Nice! For the series,

#23 lore raw
Quoted 5 lines · Mika Westerberg
Quoted 4 lines · Andy Shevchenko

Intel pin control drivers use NOIRQ variant of the PM callbacks. To make them smaller and less error prone against different kernel configurations (with possible defined but not used variables) switch to use NOIRQ PM helper.

...

Quoted 3 lines

Nice! For the series,

Pushed to my review and testing queue, thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko