2012-06-17 20:25:41

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 0/5] 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


2012-06-17 20:25:54

by Rafael J. Wysocki

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

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.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/platform/x86/thinkpad_acpi.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

Index: linux/drivers/platform/x86/thinkpad_acpi.c
===================================================================
--- linux.orig/drivers/platform/x86/thinkpad_acpi.c
+++ 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,
};

2012-06-17 20:26:04

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 5/5] intel_ips: Remove empty legacy PM callbacks

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.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/platform/x86/intel_ips.c | 17 -----------------
1 file changed, 17 deletions(-)

Index: linux/drivers/platform/x86/intel_ips.c
===================================================================
--- linux.orig/drivers/platform/x86/intel_ips.c
+++ 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,
};

2012-06-17 20:25:40

by Rafael J. Wysocki

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

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.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/platform/x86/acer-wmi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

Index: linux/drivers/platform/x86/acer-wmi.c
===================================================================
--- linux.orig/drivers/platform/x86/acer-wmi.c
+++ 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,
};

2012-06-17 20:26:36

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 4/5] intel_mid_thermal: Use struct dev_pm_ops for power management

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.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/platform/x86/intel_mid_thermal.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

Index: linux/drivers/platform/x86/intel_mid_thermal.c
===================================================================
--- linux.orig/drivers/platform/x86/intel_mid_thermal.c
+++ 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,
};

2012-06-17 20:26:50

by Rafael J. Wysocki

[permalink] [raw]
Subject: [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.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/platform/x86/thinkpad_acpi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

Index: linux/drivers/platform/x86/thinkpad_acpi.c
===================================================================
--- linux.orig/drivers/platform/x86/thinkpad_acpi.c
+++ 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;

2012-06-18 06:03:23

by R, Durgadoss

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

Thanks Rafael for the patch.

> -----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
>
> 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.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>

Reviewed-by: Durgadoss R <[email protected]>

Thanks,
Durga
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2012-06-18 06:57:10

by joeyli

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

於 日,2012-06-17 於 22:28 +0200,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.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>

Patch good to me!

Tested on Acer TravelMate 4750

Tested-by: Lee, Chun-Yi <[email protected]>


Thanks a lot!
Joey Lee

> ---
> drivers/platform/x86/acer-wmi.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> Index: linux/drivers/platform/x86/acer-wmi.c
> ===================================================================
> --- linux.orig/drivers/platform/x86/acer-wmi.c
> +++ 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,
> };
>
>
>

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

On Sun, 17 Jun 2012, Rafael J. Wysocki wrote:
> 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.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>

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.

Acked-by: Henrique de Moraes Holschuh <[email protected]>

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

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

On Sun, 17 Jun 2012, Rafael J. Wysocki wrote:
> 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.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>

Acked-by: Henrique de Moraes Holschuh <[email protected]>

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

2012-06-24 19:56:08

by Rafael J. Wysocki

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

On Sunday, June 24, 2012, Henrique de Moraes Holschuh wrote:
> On Sun, 17 Jun 2012, Rafael J. Wysocki wrote:
> > 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.
> >
> > Signed-off-by: Rafael J. Wysocki <[email protected]>
>
> Acked-by: Henrique de Moraes Holschuh <[email protected]>

Thanks (and for the other patch too)!

Rafael