Skip to contentSkip to conversation

platform / x86: Convert a few drivers to struct dev_pm_ops

PATCH In review Rafael J. Wysocki 4 participants 11 messages Jun 17, 2012 – Jun 24, 2012

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

cover platform / x86: Convert a few drivers to struct dev_pm_ops

Hi all,

The following series of patches converts a few drivers under platform/x86 to using struct dev_pm_ops objects for power management istead of legacy callbacks in struct platform_driver.

The ultimate goal of this will be to get rid of PM callbacks from the platform bus type, which are only necessary because a number of drivers still use the legacy hooks.

Admittedly, I don't have the hardware to test all of the changes, but hopefully they are simple enough.

Please let me know if there are any objections.

Thanks,
Rafael

#1 lore raw

PATCH 1/5 thinkpad_acpi: Drop pm_message_t arguments from suspend routines

From: Rafael J. Wysocki <[email protected]>

Multiple suspend routines in drivers/platform/x86/thinkpad_acpi.c use take pm_message_t arguments that aren't used by any of them. Make those routines take no arguments as that's what they should do.

---
 drivers/platform/x86/thinkpad_acpi.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +6 -6
Index: linux/drivers/platform/x86/thinkpad_acpi.c
===================================================================
@@ -277,7 +277,7 @@ struct ibm_struct {
 	int (*write) (char *);
 	void (*exit) (void);
 	void (*resume) (void);
-	void (*suspend) (pm_message_t state);
+	void (*suspend) (void);
 	void (*shutdown) (void);
 
 	struct list_head all_drivers;
@@ -931,7 +931,7 @@ static int tpacpi_suspend_handler(struct
 				 &tpacpi_all_drivers,
 				 all_drivers) {
 		if (ibm->suspend)
-			(ibm->suspend)(state);
+			(ibm->suspend)();
 	}
 
 	return 0;
@@ -3758,7 +3758,7 @@ static void hotkey_notify(struct ibm_str
 	}
 }
 
-static void hotkey_suspend(pm_message_t state)
+static void hotkey_suspend(void)
 {
 	/* Do these on suspend, we get the events on early resume! */
 	hotkey_wakeup_reason = TP_ACPI_WAKEUP_NONE;
@@ -6329,7 +6329,7 @@ static int __init brightness_init(struct
 	return 0;
 }
 
-static void brightness_suspend(pm_message_t state)
+static void brightness_suspend(void)
 {
 	tpacpi_brightness_checkpoint_nvram();
 }
@@ -6748,7 +6748,7 @@ static struct snd_kcontrol_new volume_al
 	.get = volume_alsa_mute_get,
 };
 
-static void volume_suspend(pm_message_t state)
+static void volume_suspend(void)
 {
 	tpacpi_volume_checkpoint_nvram();
 }
@@ -8107,7 +8107,7 @@ static void fan_exit(void)
 	flush_workqueue(tpacpi_wq);
 }
 
-static void fan_suspend(pm_message_t state)
+static void fan_suspend(void)
 {
 	int rc;
 
Acked-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] thinkpad_acpi: Drop pm_message_t arguments from suspend routines

Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Multiple suspend routines in drivers/platform/x86/thinkpad_acpi.c use take pm_message_t arguments that aren't used by any of them. Make those routines take no arguments as that's what they should do.

Someday it might be necessary for some of these routines to differentiate S3 from suspend-to-disk, but I will introduce a parameter when that day comes.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#3 lore raw

PATCH 2/5 thinkpad_acpi: Use struct dev_pm_ops instead of legacy PM routines

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Make the thinkpad_acpi driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.

---
 drivers/platform/x86/thinkpad_acpi.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +6 -5
Index: linux/drivers/platform/x86/thinkpad_acpi.c
===================================================================
@@ -922,8 +922,7 @@ static struct input_dev *tpacpi_inputdev
 static struct mutex tpacpi_inputdev_send_mutex;
 static LIST_HEAD(tpacpi_all_drivers);
 
-static int tpacpi_suspend_handler(struct platform_device *pdev,
-				  pm_message_t state)
+static int tpacpi_suspend_handler(struct device *dev)
 {
 	struct ibm_struct *ibm, *itmp;
 
@@ -937,7 +936,7 @@ static int tpacpi_suspend_handler(struct
 	return 0;
 }
 
-static int tpacpi_resume_handler(struct platform_device *pdev)
+static int tpacpi_resume_handler(struct device *dev)
 {
 	struct ibm_struct *ibm, *itmp;
 
@@ -951,6 +950,9 @@ static int tpacpi_resume_handler(struct
 	return 0;
 }
 
+static SIMPLE_DEV_PM_OPS(tpacpi_pm,
+			 tpacpi_suspend_handler, tpacpi_resume_handler);
+
 static void tpacpi_shutdown_handler(struct platform_device *pdev)
 {
 	struct ibm_struct *ibm, *itmp;
@@ -967,9 +969,8 @@ static struct platform_driver tpacpi_pdr
 	.driver = {
 		.name = TPACPI_DRVR_NAME,
 		.owner = THIS_MODULE,
+		.pm = &tpacpi_pm,
 	},
-	.suspend = tpacpi_suspend_handler,
-	.resume = tpacpi_resume_handler,
 	.shutdown = tpacpi_shutdown_handler,
 };
 
Acked-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] thinkpad_acpi: Use struct dev_pm_ops instead of legacy PM routines

Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Make the thinkpad_acpi driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#5 lore raw

Re: [PATCH 2/5] thinkpad_acpi: Use struct dev_pm_ops instead of legacy PM routines

Quoted 10 lines · Henrique de Moraes Holschuh
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Make the thinkpad_acpi driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.

Thanks (and for the other patch too)!

Rafael

#6 lore raw

PATCH 3/5 acer-wmi: Use struct dev_pm_ops for power management

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Make the acer-wmi driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.

---
 drivers/platform/x86/acer-wmi.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/x86/acer-wmi.c +5 -5
Index: linux/drivers/platform/x86/acer-wmi.c
===================================================================
@@ -1877,8 +1877,7 @@ static int acer_platform_remove(struct p
 	return 0;
 }
 
-static int acer_platform_suspend(struct platform_device *dev,
-pm_message_t state)
+static int acer_suspend(struct device *dev)
 {
 	u32 value;
 	struct acer_data *data = &interface->data;
@@ -1900,7 +1899,7 @@ pm_message_t state)
 	return 0;
 }
 
-static int acer_platform_resume(struct platform_device *device)
+static int acer_resume(struct device *dev)
 {
 	struct acer_data *data = &interface->data;
 
@@ -1916,6 +1915,8 @@ static int acer_platform_resume(struct p
 	return 0;
 }
 
+static SIMPLE_DEV_PM_OPS(acer_pm, acer_suspend, acer_resume);
+
 static void acer_platform_shutdown(struct platform_device *device)
 {
 	struct acer_data *data = &interface->data;
@@ -1931,11 +1932,10 @@ static struct platform_driver acer_platf
 	.driver = {
 		.name = "acer-wmi",
 		.owner = THIS_MODULE,
+		.pm = &acer_pm,
 	},
 	.probe = acer_platform_probe,
 	.remove = acer_platform_remove,
-	.suspend = acer_platform_suspend,
-	.resume = acer_platform_resume,
 	.shutdown = acer_platform_shutdown,
 };
 
maintainer Tested-by on v1 3/5
#7 lore raw

Re: [PATCH 3/5] acer-wmi: Use struct dev_pm_ops for power management

於 日,2012-06-17 於 22:28 +0200,Rafael J. Wysocki 提到:

Quoted 7 lines

From: Rafael J. Wysocki <[email protected]>

Make the acer-wmi driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.

Patch good to me!

Tested on Acer TravelMate 4750

Thanks a lot!
Joey Lee

Quoted 51 lines
---
 drivers/platform/x86/acer-wmi.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: linux/drivers/platform/x86/acer-wmi.c
===================================================================

drivers/platform/x86/acer-wmi.c +5 -5
@@ -1877,8 +1877,7 @@ static int acer_platform_remove(struct p
 	return 0;
 }
 
-static int acer_platform_suspend(struct platform_device *dev,
-pm_message_t state)
+static int acer_suspend(struct device *dev)
 {
 	u32 value;
 	struct acer_data *data = &interface->data;
@@ -1900,7 +1899,7 @@ pm_message_t state)
 	return 0;
 }
 
-static int acer_platform_resume(struct platform_device *device)
+static int acer_resume(struct device *dev)
 {
 	struct acer_data *data = &interface->data;
 
@@ -1916,6 +1915,8 @@ static int acer_platform_resume(struct p
 	return 0;
 }
 
+static SIMPLE_DEV_PM_OPS(acer_pm, acer_suspend, acer_resume);
+
 static void acer_platform_shutdown(struct platform_device *device)
 {
 	struct acer_data *data = &interface->data;
@@ -1931,11 +1932,10 @@ static struct platform_driver acer_platf
 	.driver = {
 		.name = "acer-wmi",
 		.owner = THIS_MODULE,
+		.pm = &acer_pm,
 	},
 	.probe = acer_platform_probe,
 	.remove = acer_platform_remove,
-	.suspend = acer_platform_suspend,
-	.resume = acer_platform_resume,
 	.shutdown = acer_platform_shutdown,
 };
 
#8 lore raw

PATCH 4/5 intel_mid_thermal: Use struct dev_pm_ops for power management

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Make the intel_mid_thermal driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.

---
 drivers/platform/x86/intel_mid_thermal.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/platform/x86/intel_mid_thermal.c +9 -7
Index: linux/drivers/platform/x86/intel_mid_thermal.c
===================================================================
@@ -418,23 +418,23 @@ static struct thermal_device_info *initi
 
 /**
  * mid_thermal_resume - resume routine
- * @pdev: platform device structure
+ * @dev: device structure
  *
  * mid thermal resume: re-initializes the adc. Can sleep.
  */
-static int mid_thermal_resume(struct platform_device *pdev)
+static int mid_thermal_resume(struct device *dev)
 {
-	return mid_initialize_adc(&pdev->dev);
+	return mid_initialize_adc(dev);
 }
 
 /**
  * mid_thermal_suspend - suspend routine
- * @pdev: platform device structure
+ * @dev: device structure
  *
  * mid thermal suspend implements the suspend functionality
  * by stopping the ADC. Can sleep.
  */
-static int mid_thermal_suspend(struct platform_device *pdev, pm_message_t mesg)
+static int mid_thermal_suspend(struct device *dev)
 {
 	/*
 	 * This just stops the ADC and does not disable it.
@@ -444,6 +444,9 @@ static int mid_thermal_suspend(struct pl
 	return configure_adc(0);
 }
 
+static SIMPLE_DEV_PM_OPS(mid_thermal_pm,
+			 mid_thermal_suspend, mid_thermal_resume);
+
 /**
  * read_curr_temp - reads the current temperature and stores in temp
  * @temp: holds the current temperature value after reading
@@ -557,10 +560,9 @@ static struct platform_driver mid_therma
 	.driver = {
 		.name = DRIVER_NAME,
 		.owner = THIS_MODULE,
+		.pm = &mid_thermal_pm,
 	},
 	.probe = mid_thermal_probe,
-	.suspend = mid_thermal_suspend,
-	.resume = mid_thermal_resume,
 	.remove = __devexit_p(mid_thermal_remove),
 	.id_table = therm_id_table,
 };
Reviewed-by on v1 4/5
#9 lore raw

RE: [PATCH 4/5] intel_mid_thermal: Use struct dev_pm_ops for power management

Thanks Rafael for the patch.

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Rafael J. Wysocki
Sent: Monday, June 18, 2012 2:00 AM
To: [email protected]
Cc: Henrique de Moraes Holschuh; LKML; Linux PM list; Matthew Garrett; Joey Lee
Subject: [PATCH 4/5] intel_mid_thermal: Use struct dev_pm_ops for power management

Quoted 7 lines

From: Rafael J. Wysocki <[email protected]>

Make the intel_mid_thermal driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.

Thanks,
Durga

#10 lore raw

PATCH 5/5 intel_ips: Remove empty legacy PM callbacks

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

The legacy PM callbacks provided by the Intel IPS driver are empty routines returning 0, so they can be safely dropped.

---
 drivers/platform/x86/intel_ips.c |   17 -----------------
 1 file changed, 17 deletions(-)
drivers/platform/x86/intel_ips.c +0 -17
Index: linux/drivers/platform/x86/intel_ips.c
===================================================================
@@ -1697,21 +1697,6 @@ static void ips_remove(struct pci_dev *d
 	dev_dbg(&dev->dev, "IPS driver removed\n");
 }
 
-#ifdef CONFIG_PM
-static int ips_suspend(struct pci_dev *dev, pm_message_t state)
-{
-	return 0;
-}
-
-static int ips_resume(struct pci_dev *dev)
-{
-	return 0;
-}
-#else
-#define ips_suspend NULL
-#define ips_resume NULL
-#endif /* CONFIG_PM */
-
 static void ips_shutdown(struct pci_dev *dev)
 {
 }
@@ -1721,8 +1706,6 @@ static struct pci_driver ips_pci_driver
 	.id_table = ips_id_table,
 	.probe = ips_probe,
 	.remove = ips_remove,
-	.suspend = ips_suspend,
-	.resume = ips_resume,
 	.shutdown = ips_shutdown,
 };