2012-06-23 21:17:08

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 0/21] ACPI / PM: Switch ACPI bus type and drivers to dev_pm_ops

Hi all,

The following patchset converts the ACPI bus type and all of the ACPI drivers
to the power management handling based on struct dev_pm_ops. It does that in
the following way:

(1) The (unused) pm_message_t argument is dropped from the ACPI driver suspend
callback throughout the tree (patch [1/21]).

(2) A struct dev_pm_ops object is defined for the ACPI bus type (patches
[2-3/21]) in such a way that
(a) driver callbacks from struct acpi_device_ops are executed for drivers
that provide them,
(b) driver callbacks from struct dev_pm_ops are executed for drivers that
provide them,
(c) 0 is returned for the remaining drivers.
Only suspend/resume, freeze/thaw, poweroff/restore bus type callbacks are
defined, because they are sufficient for the transition (they are removed
later on anyway).

(3) All ACPI drivers that use PM callbacks are converted to the PM handling
based on struct dev_pm_ops (patches [4-18/21]).

(4) The ACPI bus type is modified not to execute driver callbacks from
struct acpi_device_ops any more (patch [19/21]). This affects several
x86 platform drivers and the ACPI power meter driver too.

(5) The driver PM callbacks in struct acpi_device_ops are removed
(patch [20/21]).

(6) The ACPI bus type PM callbacks added in step (2) are dropped, because they
aren't necessary any more (the PM core will execute the driver callbacks
directly now).

As a result, the redundant bus type level of PM handling between ACPI drivers
and the PM core is eliminated and the ACPI drivers are now able to define
runtime PM callbacks, proper hibernation callbacks and late/early callbacks
for system suspend/resume.

The patchset has been tested on Toshiba Portege R500 and more testing is in
the works. If there are no objections, I'd like to push if for 3.6 through
the linux-pm tree.

If you want to give it a go, it's available from the pm-acpi branch of the
linux-pm tree. Please note, however, that this branch will be rebased, because
it is based on the linux-pm tree's linux-next branch at the moment.

Thanks,
Rafael


2012-06-23 21:18:23

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 14/21] sony-laptop: Use struct dev_pm_ops for power management

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

Make the sony-laptop driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

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

Index: linux/drivers/platform/x86/sony-laptop.c
===================================================================
--- linux.orig/drivers/platform/x86/sony-laptop.c
+++ linux/drivers/platform/x86/sony-laptop.c
@@ -1452,7 +1452,7 @@ static void sony_nc_function_resume(void
&result);
}

-static int sony_nc_resume(struct acpi_device *device)
+static int sony_nc_resume(struct device *dev)
{
struct sony_nc_value *item;
acpi_handle handle;
@@ -1484,6 +1484,8 @@ static int sony_nc_resume(struct acpi_de
return 0;
}

+static SIMPLE_DEV_PM_OPS(sony_nc_pm, NULL, sony_nc_resume);
+
static void sony_nc_rfkill_cleanup(void)
{
int i;
@@ -2728,9 +2730,9 @@ static struct acpi_driver sony_nc_driver
.ops = {
.add = sony_nc_add,
.remove = sony_nc_remove,
- .resume = sony_nc_resume,
.notify = sony_nc_notify,
},
+ .drv.pm = &sony_nc_pm,
};

/*********** SPIC (SNY6001) Device ***********/
@@ -4243,19 +4245,22 @@ err_free_resources:
return result;
}

-static int sony_pic_suspend(struct acpi_device *device)
+static int sony_pic_suspend(struct device *dev)
{
- if (sony_pic_disable(device))
+ if (sony_pic_disable(to_acpi_device(dev)))
return -ENXIO;
return 0;
}

-static int sony_pic_resume(struct acpi_device *device)
+static int sony_pic_resume(struct device *dev)
{
- sony_pic_enable(device, spic_dev.cur_ioport, spic_dev.cur_irq);
+ sony_pic_enable(to_acpi_device(dev),
+ spic_dev.cur_ioport, spic_dev.cur_irq);
return 0;
}

+static SIMPLE_DEV_PM_OPS(sony_pic_pm, sony_pic_suspend, sony_pic_resume);
+
static const struct acpi_device_id sony_pic_device_ids[] = {
{SONY_PIC_HID, 0},
{"", 0},
@@ -4269,9 +4274,8 @@ static struct acpi_driver sony_pic_drive
.ops = {
.add = sony_pic_add,
.remove = sony_pic_remove,
- .suspend = sony_pic_suspend,
- .resume = sony_pic_resume,
},
+ .drv.pm = &sony_pic_pm,
};

static struct dmi_system_id __initdata sonypi_dmi_table[] = {

2012-06-23 21:18:33

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 20/21] ACPI / PM: Drop legacy driver PM callbacks that are not used any more

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

Since the legacy ACPI driver PM callbacks included into
struct acpi_device_ops are not used any more, drop them.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
include/acpi/acpi_bus.h | 4 ----
1 file changed, 4 deletions(-)

Index: linux/include/acpi/acpi_bus.h
===================================================================
--- linux.orig/include/acpi/acpi_bus.h
+++ linux/include/acpi/acpi_bus.h
@@ -117,8 +117,6 @@ struct acpi_device;
typedef int (*acpi_op_add) (struct acpi_device * device);
typedef int (*acpi_op_remove) (struct acpi_device * device, int type);
typedef int (*acpi_op_start) (struct acpi_device * device);
-typedef int (*acpi_op_suspend) (struct acpi_device * device);
-typedef int (*acpi_op_resume) (struct acpi_device * device);
typedef int (*acpi_op_bind) (struct acpi_device * device);
typedef int (*acpi_op_unbind) (struct acpi_device * device);
typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
@@ -132,8 +130,6 @@ struct acpi_device_ops {
acpi_op_add add;
acpi_op_remove remove;
acpi_op_start start;
- acpi_op_suspend suspend;
- acpi_op_resume resume;
acpi_op_bind bind;
acpi_op_unbind unbind;
acpi_op_notify notify;

2012-06-23 21:18:31

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 21/21] ACPI / PM: Drop PM callbacks from the ACPI bus type

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

Since the ACPI bus type's PM callbacks only execute the driver ones
without doing anything else, they can be dropped, because the driver
callbacks will be executed by the PM core directly if bus type
(or other subsystem) callbacks are not present.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/scan.c | 51 ---------------------------------------------------
1 file changed, 51 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -290,56 +290,6 @@ static void acpi_device_release(struct d
kfree(acpi_dev);
}

-#define ACPI_DEV_PM_CALLBACK(dev, callback) \
-({ \
- struct device_driver *__drv = dev->driver; \
- int __ret = 0; \
- \
- if (__drv && __drv->pm && __drv->pm->callback) \
- __ret = __drv->pm->callback(dev); \
- \
- __ret; \
-})
-
-static int acpi_pm_suspend(struct device *dev)
-{
- return ACPI_DEV_PM_CALLBACK(dev, suspend);
-}
-
-static int acpi_pm_resume(struct device *dev)
-{
- return ACPI_DEV_PM_CALLBACK(dev, resume);
-}
-
-static int acpi_pm_freeze(struct device *dev)
-{
- return ACPI_DEV_PM_CALLBACK(dev, freeze);
-}
-
-static int acpi_pm_thaw(struct device *dev)
-{
- return ACPI_DEV_PM_CALLBACK(dev, thaw);
-}
-
-static int acpi_pm_poweroff(struct device *dev)
-{
- return ACPI_DEV_PM_CALLBACK(dev, poweroff);
-}
-
-static int acpi_pm_restore(struct device *dev)
-{
- return ACPI_DEV_PM_CALLBACK(dev, restore);
-}
-
-static const struct dev_pm_ops acpi_bus_pm = {
- .suspend = acpi_pm_suspend,
- .resume = acpi_pm_resume,
- .freeze = acpi_pm_freeze,
- .thaw = acpi_pm_thaw,
- .poweroff = acpi_pm_poweroff,
- .restore = acpi_pm_restore,
-};
-
static int acpi_bus_match(struct device *dev, struct device_driver *drv)
{
struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -475,7 +425,6 @@ struct bus_type acpi_bus_type = {
.probe = acpi_device_probe,
.remove = acpi_device_remove,
.uevent = acpi_device_uevent,
- .pm = &acpi_bus_pm,
};

static int acpi_device_register(struct acpi_device *device)

2012-06-23 21:18:22

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 10/21] ACPI: Use struct dev_pm_ops for power management in the power driver

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

Make the ACPI power resource driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/power.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux/drivers/acpi/power.c
===================================================================
--- linux.orig/drivers/acpi/power.c
+++ linux/drivers/acpi/power.c
@@ -60,7 +60,6 @@ ACPI_MODULE_NAME("power");

static int acpi_power_add(struct acpi_device *device);
static int acpi_power_remove(struct acpi_device *device, int type);
-static int acpi_power_resume(struct acpi_device *device);

static const struct acpi_device_id power_device_ids[] = {
{ACPI_POWER_HID, 0},
@@ -68,6 +67,9 @@ static const struct acpi_device_id power
};
MODULE_DEVICE_TABLE(acpi, power_device_ids);

+static int acpi_power_resume(struct device *dev);
+static SIMPLE_DEV_PM_OPS(acpi_power_pm, NULL, acpi_power_resume);
+
static struct acpi_driver acpi_power_driver = {
.name = "power",
.class = ACPI_POWER_CLASS,
@@ -75,8 +77,8 @@ static struct acpi_driver acpi_power_dri
.ops = {
.add = acpi_power_add,
.remove = acpi_power_remove,
- .resume = acpi_power_resume,
},
+ .drv.pm = &acpi_power_pm,
};

/*
@@ -771,14 +773,16 @@ static int acpi_power_remove(struct acpi
return 0;
}

-static int acpi_power_resume(struct acpi_device *device)
+static int acpi_power_resume(struct device *dev)
{
int result = 0, state;
+ struct acpi_device *device;
struct acpi_power_resource *resource;

- if (!device)
+ if (!dev)
return -EINVAL;

+ device = to_acpi_device(dev);
resource = acpi_driver_data(device);
if (!resource)
return -EINVAL;

2012-06-23 21:19:10

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 17/21] xo15-ebook: Use struct dev_pm_ops for power management

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

Make the xo15-ebook driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

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

Index: linux/drivers/platform/x86/xo15-ebook.c
===================================================================
--- linux.orig/drivers/platform/x86/xo15-ebook.c
+++ linux/drivers/platform/x86/xo15-ebook.c
@@ -77,11 +77,13 @@ static void ebook_switch_notify(struct a
}
}

-static int ebook_switch_resume(struct acpi_device *device)
+static int ebook_switch_resume(struct device *dev)
{
- return ebook_send_state(device);
+ return ebook_send_state(to_acpi_device(dev));
}

+static SIMPLE_DEV_PM_OPS(ebook_switch_pm, NULL, ebook_switch_resume);
+
static int ebook_switch_add(struct acpi_device *device)
{
struct ebook_switch *button;
@@ -161,10 +163,10 @@ static struct acpi_driver xo15_ebook_dri
.ids = ebook_device_ids,
.ops = {
.add = ebook_switch_add,
- .resume = ebook_switch_resume,
.remove = ebook_switch_remove,
.notify = ebook_switch_notify,
},
+ .drv.pm = &ebook_switch_pm,
};

static int __init xo15_ebook_init(void)

2012-06-23 21:18:20

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 11/21] ACPI: Use struct dev_pm_ops for power management in the SBS driver

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

Make the ACPI Smart Battery System driver define its PM callbacks
through a struct dev_pm_ops object rather than by using legacy PM
hooks in struct acpi_device_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/sbs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

Index: linux/drivers/acpi/sbs.c
===================================================================
--- linux.orig/drivers/acpi/sbs.c
+++ linux/drivers/acpi/sbs.c
@@ -988,16 +988,18 @@ static void acpi_sbs_rmdirs(void)
#endif
}

-static int acpi_sbs_resume(struct acpi_device *device)
+static int acpi_sbs_resume(struct device *dev)
{
struct acpi_sbs *sbs;
- if (!device)
+ if (!dev)
return -EINVAL;
- sbs = device->driver_data;
+ sbs = to_acpi_device(dev)->driver_data;
acpi_sbs_callback(sbs);
return 0;
}

+static SIMPLE_DEV_PM_OPS(acpi_sbs_pm, NULL, acpi_sbs_resume);
+
static struct acpi_driver acpi_sbs_driver = {
.name = "sbs",
.class = ACPI_SBS_CLASS,
@@ -1005,8 +1007,8 @@ static struct acpi_driver acpi_sbs_drive
.ops = {
.add = acpi_sbs_add,
.remove = acpi_sbs_remove,
- .resume = acpi_sbs_resume,
},
+ .drv.pm = &acpi_sbs_pm,
};

static int __init acpi_sbs_init(void)

2012-06-23 21:19:45

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 19/21] ACPI / PM: Do not execute legacy driver PM callbacks

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

Since all ACPI drivers in the tree should have been switched
to power management handling based on struct dev_pm_ops,
modify the ACPI bus type driver so that is doesn't execute
legacy driver power management callbacks from the functions
pointed to by the members of the acpi_bus_pm structure.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/scan.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -290,51 +290,45 @@ static void acpi_device_release(struct d
kfree(acpi_dev);
}

-#define ACPI_DEV_PM_CALLBACK(dev, callback, legacy_cb) \
+#define ACPI_DEV_PM_CALLBACK(dev, callback) \
({ \
- struct acpi_device *__acpi_dev = to_acpi_device(dev); \
- struct acpi_driver *__acpi_drv = __acpi_dev->driver; \
struct device_driver *__drv = dev->driver; \
- int __ret; \
+ int __ret = 0; \
\
- if (__acpi_drv && __acpi_drv->ops.legacy_cb) \
- __ret = __acpi_drv->ops.legacy_cb(__acpi_dev); \
- else if (__drv && __drv->pm && __drv->pm->callback) \
+ if (__drv && __drv->pm && __drv->pm->callback) \
__ret = __drv->pm->callback(dev); \
- else \
- __ret = 0; \
\
__ret; \
})

static int acpi_pm_suspend(struct device *dev)
{
- return ACPI_DEV_PM_CALLBACK(dev, suspend, suspend);
+ return ACPI_DEV_PM_CALLBACK(dev, suspend);
}

static int acpi_pm_resume(struct device *dev)
{
- return ACPI_DEV_PM_CALLBACK(dev, resume, resume);
+ return ACPI_DEV_PM_CALLBACK(dev, resume);
}

static int acpi_pm_freeze(struct device *dev)
{
- return ACPI_DEV_PM_CALLBACK(dev, freeze, suspend);
+ return ACPI_DEV_PM_CALLBACK(dev, freeze);
}

static int acpi_pm_thaw(struct device *dev)
{
- return ACPI_DEV_PM_CALLBACK(dev, thaw, resume);
+ return ACPI_DEV_PM_CALLBACK(dev, thaw);
}

static int acpi_pm_poweroff(struct device *dev)
{
- return ACPI_DEV_PM_CALLBACK(dev, poweroff, suspend);
+ return ACPI_DEV_PM_CALLBACK(dev, poweroff);
}

static int acpi_pm_restore(struct device *dev)
{
- return ACPI_DEV_PM_CALLBACK(dev, restore, resume);
+ return ACPI_DEV_PM_CALLBACK(dev, restore);
}

static const struct dev_pm_ops acpi_bus_pm = {

2012-06-23 21:18:18

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 7/21] ACPI: Use struct dev_pm_ops for power management in the AC driver

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

Make the ACPI AC adapter driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/ac.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

Index: linux/drivers/acpi/ac.c
===================================================================
--- linux.orig/drivers/acpi/ac.c
+++ linux/drivers/acpi/ac.c
@@ -61,7 +61,6 @@ static int acpi_ac_open_fs(struct inode

static int acpi_ac_add(struct acpi_device *device);
static int acpi_ac_remove(struct acpi_device *device, int type);
-static int acpi_ac_resume(struct acpi_device *device);
static void acpi_ac_notify(struct acpi_device *device, u32 event);

static const struct acpi_device_id ac_device_ids[] = {
@@ -70,6 +69,9 @@ static const struct acpi_device_id ac_de
};
MODULE_DEVICE_TABLE(acpi, ac_device_ids);

+static int acpi_ac_resume(struct device *dev);
+static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
+
static struct acpi_driver acpi_ac_driver = {
.name = "ac",
.class = ACPI_AC_CLASS,
@@ -78,9 +80,9 @@ static struct acpi_driver acpi_ac_driver
.ops = {
.add = acpi_ac_add,
.remove = acpi_ac_remove,
- .resume = acpi_ac_resume,
.notify = acpi_ac_notify,
},
+ .drv.pm = &acpi_ac_pm,
};

struct acpi_ac {
@@ -309,13 +311,18 @@ static int acpi_ac_add(struct acpi_devic
return result;
}

-static int acpi_ac_resume(struct acpi_device *device)
+static int acpi_ac_resume(struct device *dev)
{
struct acpi_ac *ac;
unsigned old_state;
- if (!device || !acpi_driver_data(device))
+
+ if (!dev)
+ return -EINVAL;
+
+ ac = acpi_driver_data(to_acpi_device(dev));
+ if (!ac)
return -EINVAL;
- ac = acpi_driver_data(device);
+
old_state = ac->state;
if (acpi_ac_get_state(ac))
return 0;

2012-06-23 21:20:06

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 18/21] acpi_power_meter: Use struct dev_pm_ops for power management

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

Make the ACPI power meter driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/hwmon/acpi_power_meter.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

Index: linux/drivers/hwmon/acpi_power_meter.c
===================================================================
--- linux.orig/drivers/hwmon/acpi_power_meter.c
+++ linux/drivers/hwmon/acpi_power_meter.c
@@ -929,20 +929,25 @@ static int acpi_power_meter_remove(struc
return 0;
}

-static int acpi_power_meter_resume(struct acpi_device *device)
+static int acpi_power_meter_resume(struct device *dev)
{
struct acpi_power_meter_resource *resource;

- if (!device || !acpi_driver_data(device))
+ if (!dev)
+ return -EINVAL;
+
+ resource = acpi_driver_data(to_acpi_device(dev));
+ if (!resource)
return -EINVAL;

- resource = acpi_driver_data(device);
free_capabilities(resource);
read_capabilities(resource);

return 0;
}

+static SIMPLE_DEV_PM_OPS(acpi_power_meter_pm, NULL, acpi_power_meter_resume);
+
static struct acpi_driver acpi_power_meter_driver = {
.name = "power_meter",
.class = ACPI_POWER_METER_CLASS,
@@ -950,9 +955,9 @@ static struct acpi_driver acpi_power_met
.ops = {
.add = acpi_power_meter_add,
.remove = acpi_power_meter_remove,
- .resume = acpi_power_meter_resume,
.notify = acpi_power_meter_notify,
},
+ .drv.pm = &acpi_power_meter_pm,
};

/* Module init/exit routines */

2012-06-23 21:18:17

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 8/21] ACPI: Use struct dev_pm_ops for power management in the battery driver

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

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

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/battery.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

Index: linux/drivers/acpi/battery.c
===================================================================
--- linux.orig/drivers/acpi/battery.c
+++ linux/drivers/acpi/battery.c
@@ -1044,17 +1044,24 @@ static int acpi_battery_remove(struct ac
}

/* this is needed to learn about changes made in suspended state */
-static int acpi_battery_resume(struct acpi_device *device)
+static int acpi_battery_resume(struct device *dev)
{
struct acpi_battery *battery;
- if (!device)
+
+ if (!dev)
+ return -EINVAL;
+
+ battery = acpi_driver_data(to_acpi_device(dev));
+ if (!battery)
return -EINVAL;
- battery = acpi_driver_data(device);
+
battery->update_time = 0;
acpi_battery_update(battery);
return 0;
}

+static SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);
+
static struct acpi_driver acpi_battery_driver = {
.name = "battery",
.class = ACPI_BATTERY_CLASS,
@@ -1062,10 +1069,10 @@ static struct acpi_driver acpi_battery_d
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = {
.add = acpi_battery_add,
- .resume = acpi_battery_resume,
.remove = acpi_battery_remove,
.notify = acpi_battery_notify,
},
+ .drv.pm = &acpi_battery_pm,
};

static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)

2012-06-23 21:20:46

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 15/21] panasonic-laptop: Use struct dev_pm_ops for power management

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

Make the panasonic-laptop driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

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

Index: linux/drivers/platform/x86/panasonic-laptop.c
===================================================================
--- linux.orig/drivers/platform/x86/panasonic-laptop.c
+++ linux/drivers/platform/x86/panasonic-laptop.c
@@ -177,7 +177,6 @@ enum SINF_BITS { SINF_NUM_BATTERIES = 0,

static int acpi_pcc_hotkey_add(struct acpi_device *device);
static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type);
-static int acpi_pcc_hotkey_resume(struct acpi_device *device);
static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event);

static const struct acpi_device_id pcc_device_ids[] = {
@@ -189,6 +188,9 @@ static const struct acpi_device_id pcc_d
};
MODULE_DEVICE_TABLE(acpi, pcc_device_ids);

+static int acpi_pcc_hotkey_resume(struct device *dev);
+static SIMPLE_DEV_PM_OPS(acpi_pcc_hotkey_pm, NULL, acpi_pcc_hotkey_resume);
+
static struct acpi_driver acpi_pcc_driver = {
.name = ACPI_PCC_DRIVER_NAME,
.class = ACPI_PCC_CLASS,
@@ -196,9 +198,9 @@ static struct acpi_driver acpi_pcc_drive
.ops = {
.add = acpi_pcc_hotkey_add,
.remove = acpi_pcc_hotkey_remove,
- .resume = acpi_pcc_hotkey_resume,
.notify = acpi_pcc_hotkey_notify,
},
+ .drv.pm = &acpi_pcc_hotkey_pm,
};

static const struct key_entry panasonic_keymap[] = {
@@ -538,11 +540,15 @@ static void acpi_pcc_destroy_input(struc

/* kernel module interface */

-static int acpi_pcc_hotkey_resume(struct acpi_device *device)
+static int acpi_pcc_hotkey_resume(struct device *dev)
{
- struct pcc_acpi *pcc = acpi_driver_data(device);
+ struct pcc_acpi *pcc;
+
+ if (!dev)
+ return -EINVAL;

- if (device == NULL || pcc == NULL)
+ pcc = acpi_driver_data(to_acpi_device(dev));
+ if (!pcc)
return -EINVAL;

ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Sticky mode restore: %d\n",

2012-06-23 21:21:09

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 16/21] toshiba_bluetooth: Use struct dev_pm_ops for power management

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

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

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

Index: linux/drivers/platform/x86/toshiba_bluetooth.c
===================================================================
--- linux.orig/drivers/platform/x86/toshiba_bluetooth.c
+++ linux/drivers/platform/x86/toshiba_bluetooth.c
@@ -34,7 +34,6 @@ MODULE_LICENSE("GPL");
static int toshiba_bt_rfkill_add(struct acpi_device *device);
static int toshiba_bt_rfkill_remove(struct acpi_device *device, int type);
static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
-static int toshiba_bt_resume(struct acpi_device *device);

static const struct acpi_device_id bt_device_ids[] = {
{ "TOS6205", 0},
@@ -42,6 +41,9 @@ static const struct acpi_device_id bt_de
};
MODULE_DEVICE_TABLE(acpi, bt_device_ids);

+static int toshiba_bt_resume(struct device *dev);
+static SIMPLE_DEV_PM_OPS(toshiba_bt_pm, NULL, toshiba_bt_resume);
+
static struct acpi_driver toshiba_bt_rfkill_driver = {
.name = "Toshiba BT",
.class = "Toshiba",
@@ -50,9 +52,9 @@ static struct acpi_driver toshiba_bt_rfk
.add = toshiba_bt_rfkill_add,
.remove = toshiba_bt_rfkill_remove,
.notify = toshiba_bt_rfkill_notify,
- .resume = toshiba_bt_resume,
},
.owner = THIS_MODULE,
+ .drv.pm = &toshiba_bt_pm,
};


@@ -88,9 +90,9 @@ static void toshiba_bt_rfkill_notify(str
toshiba_bluetooth_enable(device->handle);
}

-static int toshiba_bt_resume(struct acpi_device *device)
+static int toshiba_bt_resume(struct device *dev)
{
- return toshiba_bluetooth_enable(device->handle);
+ return toshiba_bluetooth_enable(to_acpi_device(dev)->handle);
}

static int toshiba_bt_rfkill_add(struct acpi_device *device)

2012-06-23 21:18:15

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 9/21] ACPI: Use struct dev_pm_ops for power management in the button driver

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

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

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/button.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

Index: linux/drivers/acpi/button.c
===================================================================
--- linux.orig/drivers/acpi/button.c
+++ linux/drivers/acpi/button.c
@@ -76,19 +76,21 @@ MODULE_DEVICE_TABLE(acpi, button_device_

static int acpi_button_add(struct acpi_device *device);
static int acpi_button_remove(struct acpi_device *device, int type);
-static int acpi_button_resume(struct acpi_device *device);
static void acpi_button_notify(struct acpi_device *device, u32 event);

+static int acpi_button_resume(struct device *dev);
+static SIMPLE_DEV_PM_OPS(acpi_button_pm, NULL, acpi_button_resume);
+
static struct acpi_driver acpi_button_driver = {
.name = "button",
.class = ACPI_BUTTON_CLASS,
.ids = button_device_ids,
.ops = {
.add = acpi_button_add,
- .resume = acpi_button_resume,
.remove = acpi_button_remove,
.notify = acpi_button_notify,
},
+ .drv.pm = &acpi_button_pm,
};

struct acpi_button {
@@ -308,8 +310,9 @@ static void acpi_button_notify(struct ac
}
}

-static int acpi_button_resume(struct acpi_device *device)
+static int acpi_button_resume(struct device *dev)
{
+ struct acpi_device *device = to_acpi_device(dev);
struct acpi_button *button = acpi_driver_data(device);

if (button->type == ACPI_BUTTON_TYPE_LID)

2012-06-23 21:18:13

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 12/21] toshiba_acpi: Use struct dev_pm_ops for power management

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

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

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

Index: linux/drivers/platform/x86/toshiba_acpi.c
===================================================================
--- linux.orig/drivers/platform/x86/toshiba_acpi.c
+++ linux/drivers/platform/x86/toshiba_acpi.c
@@ -1296,9 +1296,9 @@ static void toshiba_acpi_notify(struct a
}
}

-static int toshiba_acpi_suspend(struct acpi_device *acpi_dev)
+static int toshiba_acpi_suspend(struct device *device)
{
- struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
+ struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device));
u32 result;

if (dev->hotkey_dev)
@@ -1307,9 +1307,9 @@ static int toshiba_acpi_suspend(struct a
return 0;
}

-static int toshiba_acpi_resume(struct acpi_device *acpi_dev)
+static int toshiba_acpi_resume(struct device *device)
{
- struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
+ struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device));
u32 result;

if (dev->hotkey_dev)
@@ -1318,6 +1318,9 @@ static int toshiba_acpi_resume(struct ac
return 0;
}

+static SIMPLE_DEV_PM_OPS(toshiba_acpi_pm,
+ toshiba_acpi_suspend, toshiba_acpi_resume);
+
static struct acpi_driver toshiba_acpi_driver = {
.name = "Toshiba ACPI driver",
.owner = THIS_MODULE,
@@ -1327,9 +1330,8 @@ static struct acpi_driver toshiba_acpi_d
.add = toshiba_acpi_add,
.remove = toshiba_acpi_remove,
.notify = toshiba_acpi_notify,
- .suspend = toshiba_acpi_suspend,
- .resume = toshiba_acpi_resume,
},
+ .drv.pm = &toshiba_acpi_pm,
};

static int __init toshiba_acpi_init(void)

2012-06-23 21:18:11

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 5/21] ACPI: Use struct dev_pm_ops for power management in the thermal driver

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

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

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/thermal.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

Index: linux/drivers/acpi/thermal.c
===================================================================
--- linux.orig/drivers/acpi/thermal.c
+++ linux/drivers/acpi/thermal.c
@@ -98,7 +98,6 @@ MODULE_PARM_DESC(psv, "Disable or overri

static int acpi_thermal_add(struct acpi_device *device);
static int acpi_thermal_remove(struct acpi_device *device, int type);
-static int acpi_thermal_resume(struct acpi_device *device);
static void acpi_thermal_notify(struct acpi_device *device, u32 event);

static const struct acpi_device_id thermal_device_ids[] = {
@@ -107,6 +106,9 @@ static const struct acpi_device_id ther
};
MODULE_DEVICE_TABLE(acpi, thermal_device_ids);

+static int acpi_thermal_resume(struct device *dev);
+static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume);
+
static struct acpi_driver acpi_thermal_driver = {
.name = "thermal",
.class = ACPI_THERMAL_CLASS,
@@ -114,9 +116,9 @@ static struct acpi_driver acpi_thermal_d
.ops = {
.add = acpi_thermal_add,
.remove = acpi_thermal_remove,
- .resume = acpi_thermal_resume,
.notify = acpi_thermal_notify,
},
+ .drv.pm = &acpi_thermal_pm,
};

struct acpi_thermal_state {
@@ -1041,16 +1043,17 @@ static int acpi_thermal_remove(struct ac
return 0;
}

-static int acpi_thermal_resume(struct acpi_device *device)
+static int acpi_thermal_resume(struct device *dev)
{
- struct acpi_thermal *tz = NULL;
+ struct acpi_thermal *tz;
int i, j, power_state, result;

-
- if (!device || !acpi_driver_data(device))
+ if (!dev)
return -EINVAL;

- tz = acpi_driver_data(device);
+ tz = acpi_driver_data(to_acpi_device(dev));
+ if (!tz)
+ return -EINVAL;

for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
if (!(&tz->trips.active[i]))

2012-06-23 21:18:08

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 6/21] ACPI: Use struct dev_pm_ops for power management in processor driver

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

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

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/processor_driver.c | 6 ++++--
drivers/acpi/processor_idle.c | 4 ++--
include/acpi/processor.h | 4 ++--
3 files changed, 8 insertions(+), 6 deletions(-)

Index: linux/drivers/acpi/processor_driver.c
===================================================================
--- linux.orig/drivers/acpi/processor_driver.c
+++ linux/drivers/acpi/processor_driver.c
@@ -93,6 +93,9 @@ static const struct acpi_device_id proce
};
MODULE_DEVICE_TABLE(acpi, processor_device_ids);

+static SIMPLE_DEV_PM_OPS(acpi_processor_pm,
+ acpi_processor_suspend, acpi_processor_resume);
+
static struct acpi_driver acpi_processor_driver = {
.name = "processor",
.class = ACPI_PROCESSOR_CLASS,
@@ -100,10 +103,9 @@ static struct acpi_driver acpi_processor
.ops = {
.add = acpi_processor_add,
.remove = acpi_processor_remove,
- .suspend = acpi_processor_suspend,
- .resume = acpi_processor_resume,
.notify = acpi_processor_notify,
},
+ .drv.pm = &acpi_processor_pm,
};

#define INSTALL_NOTIFY_HANDLER 1
Index: linux/include/acpi/processor.h
===================================================================
--- linux.orig/include/acpi/processor.h
+++ linux/include/acpi/processor.h
@@ -334,8 +334,8 @@ int acpi_processor_cst_has_changed(struc
int acpi_processor_hotplug(struct acpi_processor *pr);
int acpi_processor_power_exit(struct acpi_processor *pr,
struct acpi_device *device);
-int acpi_processor_suspend(struct acpi_device * device);
-int acpi_processor_resume(struct acpi_device * device);
+int acpi_processor_suspend(struct device *dev);
+int acpi_processor_resume(struct device *dev);
extern struct cpuidle_driver acpi_idle_driver;

/* in processor_thermal.c */
Index: linux/drivers/acpi/processor_idle.c
===================================================================
--- linux.orig/drivers/acpi/processor_idle.c
+++ linux/drivers/acpi/processor_idle.c
@@ -241,7 +241,7 @@ static void acpi_idle_bm_rld_restore(voi
acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld);
}

-int acpi_processor_suspend(struct acpi_device * device)
+int acpi_processor_suspend(struct device *dev)
{
if (acpi_idle_suspend == 1)
return 0;
@@ -251,7 +251,7 @@ int acpi_processor_suspend(struct acpi_d
return 0;
}

-int acpi_processor_resume(struct acpi_device * device)
+int acpi_processor_resume(struct device *dev)
{
if (acpi_idle_suspend == 0)
return 0;

2012-06-23 21:18:06

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 4/21] ACPI: Use struct dev_pm_ops for power management in the fan driver

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

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

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/fan.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

Index: linux/drivers/acpi/fan.c
===================================================================
--- linux.orig/drivers/acpi/fan.c
+++ linux/drivers/acpi/fan.c
@@ -46,8 +46,6 @@ MODULE_LICENSE("GPL");

static int acpi_fan_add(struct acpi_device *device);
static int acpi_fan_remove(struct acpi_device *device, int type);
-static int acpi_fan_suspend(struct acpi_device *device);
-static int acpi_fan_resume(struct acpi_device *device);

static const struct acpi_device_id fan_device_ids[] = {
{"PNP0C0B", 0},
@@ -55,6 +53,10 @@ static const struct acpi_device_id fan_d
};
MODULE_DEVICE_TABLE(acpi, fan_device_ids);

+static int acpi_fan_suspend(struct device *dev);
+static int acpi_fan_resume(struct device *dev);
+static SIMPLE_DEV_PM_OPS(acpi_fan_pm, acpi_fan_suspend, acpi_fan_resume);
+
static struct acpi_driver acpi_fan_driver = {
.name = "fan",
.class = ACPI_FAN_CLASS,
@@ -62,9 +64,8 @@ static struct acpi_driver acpi_fan_drive
.ops = {
.add = acpi_fan_add,
.remove = acpi_fan_remove,
- .suspend = acpi_fan_suspend,
- .resume = acpi_fan_resume,
},
+ .drv.pm = &acpi_fan_pm,
};

/* thermal cooling device callbacks */
@@ -183,24 +184,24 @@ static int acpi_fan_remove(struct acpi_d
return 0;
}

-static int acpi_fan_suspend(struct acpi_device *device)
+static int acpi_fan_suspend(struct device *dev)
{
- if (!device)
+ if (!dev)
return -EINVAL;

- acpi_bus_set_power(device->handle, ACPI_STATE_D0);
+ acpi_bus_set_power(to_acpi_device(dev)->handle, ACPI_STATE_D0);

return AE_OK;
}

-static int acpi_fan_resume(struct acpi_device *device)
+static int acpi_fan_resume(struct device *dev)
{
int result;

- if (!device)
+ if (!dev)
return -EINVAL;

- result = acpi_bus_update_power(device->handle, NULL);
+ result = acpi_bus_update_power(to_acpi_device(dev)->handle, NULL);
if (result)
printk(KERN_ERR PREFIX "Error updating fan power state\n");

2012-06-23 21:18:04

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 2/21] ACPI / PM: Make acpi_bus_type use struct dev_pm_ops for PM handling

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

Make the acpi_bus_type bus type define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct bus_type.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/scan.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -290,7 +290,7 @@ static void acpi_device_release(struct d
kfree(acpi_dev);
}

-static int acpi_device_suspend(struct device *dev, pm_message_t state)
+static int acpi_device_suspend(struct device *dev)
{
struct acpi_device *acpi_dev = to_acpi_device(dev);
struct acpi_driver *acpi_drv = acpi_dev->driver;
@@ -310,6 +310,8 @@ static int acpi_device_resume(struct dev
return 0;
}

+static SIMPLE_DEV_PM_OPS(acpi_bus_pm, acpi_device_suspend, acpi_device_resume);
+
static int acpi_bus_match(struct device *dev, struct device_driver *drv)
{
struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -441,12 +443,11 @@ static int acpi_device_remove(struct dev

struct bus_type acpi_bus_type = {
.name = "acpi",
- .suspend = acpi_device_suspend,
- .resume = acpi_device_resume,
.match = acpi_bus_match,
.probe = acpi_device_probe,
.remove = acpi_device_remove,
.uevent = acpi_device_uevent,
+ .pm = &acpi_bus_pm,
};

static int acpi_device_register(struct acpi_device *device)

2012-06-23 21:18:00

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 1/21] ACPI / PM: Drop pm_message_t argument from device suspend callback

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

None of the drivers implementing the ACPI device suspend callback
uses the pm_message_t argument of it, so this argument may be dropped
entirely from that callback. This will simplify switching the ACPI
bus type to PM handling based on struct dev_pm_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/fan.c | 4 ++--
drivers/acpi/processor_idle.c | 2 +-
drivers/acpi/scan.c | 2 +-
drivers/char/sonypi.c | 2 +-
drivers/platform/x86/hp_accel.c | 2 +-
drivers/platform/x86/sony-laptop.c | 2 +-
drivers/platform/x86/toshiba_acpi.c | 3 +--
include/acpi/acpi_bus.h | 3 +--
include/acpi/processor.h | 2 +-
9 files changed, 10 insertions(+), 12 deletions(-)

Index: linux/include/acpi/acpi_bus.h
===================================================================
--- linux.orig/include/acpi/acpi_bus.h
+++ linux/include/acpi/acpi_bus.h
@@ -117,8 +117,7 @@ struct acpi_device;
typedef int (*acpi_op_add) (struct acpi_device * device);
typedef int (*acpi_op_remove) (struct acpi_device * device, int type);
typedef int (*acpi_op_start) (struct acpi_device * device);
-typedef int (*acpi_op_suspend) (struct acpi_device * device,
- pm_message_t state);
+typedef int (*acpi_op_suspend) (struct acpi_device * device);
typedef int (*acpi_op_resume) (struct acpi_device * device);
typedef int (*acpi_op_bind) (struct acpi_device * device);
typedef int (*acpi_op_unbind) (struct acpi_device * device);
Index: linux/drivers/acpi/fan.c
===================================================================
--- linux.orig/drivers/acpi/fan.c
+++ linux/drivers/acpi/fan.c
@@ -46,7 +46,7 @@ MODULE_LICENSE("GPL");

static int acpi_fan_add(struct acpi_device *device);
static int acpi_fan_remove(struct acpi_device *device, int type);
-static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
+static int acpi_fan_suspend(struct acpi_device *device);
static int acpi_fan_resume(struct acpi_device *device);

static const struct acpi_device_id fan_device_ids[] = {
@@ -183,7 +183,7 @@ static int acpi_fan_remove(struct acpi_d
return 0;
}

-static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state)
+static int acpi_fan_suspend(struct acpi_device *device)
{
if (!device)
return -EINVAL;
Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -296,7 +296,7 @@ static int acpi_device_suspend(struct de
struct acpi_driver *acpi_drv = acpi_dev->driver;

if (acpi_drv && acpi_drv->ops.suspend)
- return acpi_drv->ops.suspend(acpi_dev, state);
+ return acpi_drv->ops.suspend(acpi_dev);
return 0;
}

Index: linux/drivers/acpi/processor_idle.c
===================================================================
--- linux.orig/drivers/acpi/processor_idle.c
+++ linux/drivers/acpi/processor_idle.c
@@ -241,7 +241,7 @@ static void acpi_idle_bm_rld_restore(voi
acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld);
}

-int acpi_processor_suspend(struct acpi_device * device, pm_message_t state)
+int acpi_processor_suspend(struct acpi_device * device)
{
if (acpi_idle_suspend == 1)
return 0;
Index: linux/drivers/platform/x86/toshiba_acpi.c
===================================================================
--- linux.orig/drivers/platform/x86/toshiba_acpi.c
+++ linux/drivers/platform/x86/toshiba_acpi.c
@@ -1296,8 +1296,7 @@ static void toshiba_acpi_notify(struct a
}
}

-static int toshiba_acpi_suspend(struct acpi_device *acpi_dev,
- pm_message_t state)
+static int toshiba_acpi_suspend(struct acpi_device *acpi_dev)
{
struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
u32 result;
Index: linux/drivers/platform/x86/hp_accel.c
===================================================================
--- linux.orig/drivers/platform/x86/hp_accel.c
+++ linux/drivers/platform/x86/hp_accel.c
@@ -353,7 +353,7 @@ static int lis3lv02d_remove(struct acpi_


#ifdef CONFIG_PM
-static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state)
+static int lis3lv02d_suspend(struct acpi_device *device)
{
/* make sure the device is off when we suspend */
lis3lv02d_poweroff(&lis3_dev);
Index: linux/drivers/platform/x86/sony-laptop.c
===================================================================
--- linux.orig/drivers/platform/x86/sony-laptop.c
+++ linux/drivers/platform/x86/sony-laptop.c
@@ -4243,7 +4243,7 @@ err_free_resources:
return result;
}

-static int sony_pic_suspend(struct acpi_device *device, pm_message_t state)
+static int sony_pic_suspend(struct acpi_device *device)
{
if (sony_pic_disable(device))
return -ENXIO;
Index: linux/include/acpi/processor.h
===================================================================
--- linux.orig/include/acpi/processor.h
+++ linux/include/acpi/processor.h
@@ -334,7 +334,7 @@ int acpi_processor_cst_has_changed(struc
int acpi_processor_hotplug(struct acpi_processor *pr);
int acpi_processor_power_exit(struct acpi_processor *pr,
struct acpi_device *device);
-int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
+int acpi_processor_suspend(struct acpi_device * device);
int acpi_processor_resume(struct acpi_device * device);
extern struct cpuidle_driver acpi_idle_driver;

2012-06-23 21:17:57

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 3/21] ACPI / PM: Make acpi_bus_type use driver struct dev_pm_ops callbacks

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

Modify acpi_bus_type so that it executes PM callbacks provided
by drivers through their struct dev_pm_ops objects, if present,
while still allowing the legacy ACPI PM callbacks to take precedence.
This will make it possible to convert ACPI drivers one by one to
handling PM through struct dev_pm_ops instead of the legacy way.

The code added by this change is temporary and will be removed
when all of the drivers in question have been switched over to
the PM handling based on struct dev_pm_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/scan.c | 60 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 47 insertions(+), 13 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -290,27 +290,61 @@ static void acpi_device_release(struct d
kfree(acpi_dev);
}

-static int acpi_device_suspend(struct device *dev)
+#define ACPI_DEV_PM_CALLBACK(dev, callback, legacy_cb) \
+({ \
+ struct acpi_device *__acpi_dev = to_acpi_device(dev); \
+ struct acpi_driver *__acpi_drv = __acpi_dev->driver; \
+ struct device_driver *__drv = dev->driver; \
+ int __ret; \
+ \
+ if (__acpi_drv && __acpi_drv->ops.legacy_cb) \
+ __ret = __acpi_drv->ops.legacy_cb(__acpi_dev); \
+ else if (__drv && __drv->pm && __drv->pm->callback) \
+ __ret = __drv->pm->callback(dev); \
+ else \
+ __ret = 0; \
+ \
+ __ret; \
+})
+
+static int acpi_pm_suspend(struct device *dev)
{
- struct acpi_device *acpi_dev = to_acpi_device(dev);
- struct acpi_driver *acpi_drv = acpi_dev->driver;
+ return ACPI_DEV_PM_CALLBACK(dev, suspend, suspend);
+}

- if (acpi_drv && acpi_drv->ops.suspend)
- return acpi_drv->ops.suspend(acpi_dev);
- return 0;
+static int acpi_pm_resume(struct device *dev)
+{
+ return ACPI_DEV_PM_CALLBACK(dev, resume, resume);
}

-static int acpi_device_resume(struct device *dev)
+static int acpi_pm_freeze(struct device *dev)
{
- struct acpi_device *acpi_dev = to_acpi_device(dev);
- struct acpi_driver *acpi_drv = acpi_dev->driver;
+ return ACPI_DEV_PM_CALLBACK(dev, freeze, suspend);
+}

- if (acpi_drv && acpi_drv->ops.resume)
- return acpi_drv->ops.resume(acpi_dev);
- return 0;
+static int acpi_pm_thaw(struct device *dev)
+{
+ return ACPI_DEV_PM_CALLBACK(dev, thaw, resume);
+}
+
+static int acpi_pm_poweroff(struct device *dev)
+{
+ return ACPI_DEV_PM_CALLBACK(dev, poweroff, suspend);
+}
+
+static int acpi_pm_restore(struct device *dev)
+{
+ return ACPI_DEV_PM_CALLBACK(dev, restore, resume);
}

-static SIMPLE_DEV_PM_OPS(acpi_bus_pm, acpi_device_suspend, acpi_device_resume);
+static const struct dev_pm_ops acpi_bus_pm = {
+ .suspend = acpi_pm_suspend,
+ .resume = acpi_pm_resume,
+ .freeze = acpi_pm_freeze,
+ .thaw = acpi_pm_thaw,
+ .poweroff = acpi_pm_poweroff,
+ .restore = acpi_pm_restore,
+};

static int acpi_bus_match(struct device *dev, struct device_driver *drv)
{

2012-06-23 21:23:21

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 13/21] hp_accel: Use struct dev_pm_ops for power management

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

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

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

Index: linux/drivers/platform/x86/hp_accel.c
===================================================================
--- linux.orig/drivers/platform/x86/hp_accel.c
+++ linux/drivers/platform/x86/hp_accel.c
@@ -353,20 +353,22 @@ static int lis3lv02d_remove(struct acpi_


#ifdef CONFIG_PM
-static int lis3lv02d_suspend(struct acpi_device *device)
+static int lis3lv02d_suspend(struct device *dev)
{
/* make sure the device is off when we suspend */
lis3lv02d_poweroff(&lis3_dev);
return 0;
}

-static int lis3lv02d_resume(struct acpi_device *device)
+static int lis3lv02d_resume(struct device *dev)
{
return lis3lv02d_poweron(&lis3_dev);
}
+
+static SIMPLE_DEV_PM_OPS(hp_accel_pm, lis3lv02d_suspend, lis3lv02d_resume);
+#define HP_ACCEL_PM (&hp_accel_pm)
#else
-#define lis3lv02d_suspend NULL
-#define lis3lv02d_resume NULL
+#define HP_ACCEL_PM NULL
#endif

/* For the HP MDPS aka 3D Driveguard */
@@ -377,9 +379,8 @@ static struct acpi_driver lis3lv02d_driv
.ops = {
.add = lis3lv02d_add,
.remove = lis3lv02d_remove,
- .suspend = lis3lv02d_suspend,
- .resume = lis3lv02d_resume,
- }
+ },
+ .drv.pm = HP_ACCEL_PM,
};

static int __init lis3lv02d_init_module(void)

2012-06-24 12:40:07

by Vikram Dhillon

[permalink] [raw]
Subject: Re: [PATCH 16/21] toshiba_bluetooth: Use struct dev_pm_ops for power management

On Sat, Jun 23, 2012 at 5:18 PM, Rafael J. Wysocki <[email protected]> wrote:
> From: Rafael J. Wysocki <[email protected]>
>
> Make the toshiba_bluetooth driver define its PM callbacks through
> a struct dev_pm_ops object rather than by using legacy PM hooks
> in struct acpi_device_ops.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>
> ---
> ?drivers/platform/x86/toshiba_bluetooth.c | ? 10 ++++++----
> ?1 file changed, 6 insertions(+), 4 deletions(-)
>
> Index: linux/drivers/platform/x86/toshiba_bluetooth.c
> ===================================================================
> --- linux.orig/drivers/platform/x86/toshiba_bluetooth.c
> +++ linux/drivers/platform/x86/toshiba_bluetooth.c
> @@ -34,7 +34,6 @@ MODULE_LICENSE("GPL");
> ?static int toshiba_bt_rfkill_add(struct acpi_device *device);
> ?static int toshiba_bt_rfkill_remove(struct acpi_device *device, int type);
> ?static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
> -static int toshiba_bt_resume(struct acpi_device *device);
>
> ?static const struct acpi_device_id bt_device_ids[] = {
> ? ? ? ?{ "TOS6205", 0},
> @@ -42,6 +41,9 @@ static const struct acpi_device_id bt_de
> ?};
> ?MODULE_DEVICE_TABLE(acpi, bt_device_ids);
>
> +static int toshiba_bt_resume(struct device *dev);
> +static SIMPLE_DEV_PM_OPS(toshiba_bt_pm, NULL, toshiba_bt_resume);
> +
> ?static struct acpi_driver toshiba_bt_rfkill_driver = {
> ? ? ? ?.name = ? ? ? ? "Toshiba BT",
> ? ? ? ?.class = ? ? ? ?"Toshiba",
> @@ -50,9 +52,9 @@ static struct acpi_driver toshiba_bt_rfk
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?.add = ? ? ? ? ?toshiba_bt_rfkill_add,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?.remove = ? ? ? toshiba_bt_rfkill_remove,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?.notify = ? ? ? toshiba_bt_rfkill_notify,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? .resume = ? ? ? toshiba_bt_resume,
> ? ? ? ? ? ? ? ? ? ? ? ?},
> ? ? ? ?.owner = ? ? ? ?THIS_MODULE,
> + ? ? ? .drv.pm = ? ? ? &toshiba_bt_pm,
> ?};
>
>
> @@ -88,9 +90,9 @@ static void toshiba_bt_rfkill_notify(str
> ? ? ? ?toshiba_bluetooth_enable(device->handle);
> ?}
>
> -static int toshiba_bt_resume(struct acpi_device *device)
> +static int toshiba_bt_resume(struct device *dev)
> ?{
> - ? ? ? return toshiba_bluetooth_enable(device->handle);
> + ? ? ? return toshiba_bluetooth_enable(to_acpi_device(dev)->handle);
> ?}
>
> ?static int toshiba_bt_rfkill_add(struct acpi_device *device)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at ?http://www.tux.org/lkml/

Looks good, will look into the other struct patch (#11) tomorrow.

Reviewed-by: Vikram Dhillon <[email protected]>

2012-06-24 19:55:11

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 16/21] toshiba_bluetooth: Use struct dev_pm_ops for power management

On Sunday, June 24, 2012, Vikram Dhillon wrote:
> On Sat, Jun 23, 2012 at 5:18 PM, Rafael J. Wysocki <[email protected]> wrote:
> > From: Rafael J. Wysocki <[email protected]>
> >
> > Make the toshiba_bluetooth driver define its PM callbacks through
> > a struct dev_pm_ops object rather than by using legacy PM hooks
> > in struct acpi_device_ops.
> >
> > Signed-off-by: Rafael J. Wysocki <[email protected]>
> > ---
> > drivers/platform/x86/toshiba_bluetooth.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > Index: linux/drivers/platform/x86/toshiba_bluetooth.c
> > ===================================================================
> > --- linux.orig/drivers/platform/x86/toshiba_bluetooth.c
> > +++ linux/drivers/platform/x86/toshiba_bluetooth.c
> > @@ -34,7 +34,6 @@ MODULE_LICENSE("GPL");
> > static int toshiba_bt_rfkill_add(struct acpi_device *device);
> > static int toshiba_bt_rfkill_remove(struct acpi_device *device, int type);
> > static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
> > -static int toshiba_bt_resume(struct acpi_device *device);
> >
> > static const struct acpi_device_id bt_device_ids[] = {
> > { "TOS6205", 0},
> > @@ -42,6 +41,9 @@ static const struct acpi_device_id bt_de
> > };
> > MODULE_DEVICE_TABLE(acpi, bt_device_ids);
> >
> > +static int toshiba_bt_resume(struct device *dev);
> > +static SIMPLE_DEV_PM_OPS(toshiba_bt_pm, NULL, toshiba_bt_resume);
> > +
> > static struct acpi_driver toshiba_bt_rfkill_driver = {
> > .name = "Toshiba BT",
> > .class = "Toshiba",
> > @@ -50,9 +52,9 @@ static struct acpi_driver toshiba_bt_rfk
> > .add = toshiba_bt_rfkill_add,
> > .remove = toshiba_bt_rfkill_remove,
> > .notify = toshiba_bt_rfkill_notify,
> > - .resume = toshiba_bt_resume,
> > },
> > .owner = THIS_MODULE,
> > + .drv.pm = &toshiba_bt_pm,
> > };
> >
> >
> > @@ -88,9 +90,9 @@ static void toshiba_bt_rfkill_notify(str
> > toshiba_bluetooth_enable(device->handle);
> > }
> >
> > -static int toshiba_bt_resume(struct acpi_device *device)
> > +static int toshiba_bt_resume(struct device *dev)
> > {
> > - return toshiba_bluetooth_enable(device->handle);
> > + return toshiba_bluetooth_enable(to_acpi_device(dev)->handle);
> > }
> >
> > static int toshiba_bt_rfkill_add(struct acpi_device *device)
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
>
> Looks good, will look into the other struct patch (#11) tomorrow.
>
> Reviewed-by: Vikram Dhillon <[email protected]>

Thanks a lot!

Rafael

2012-06-24 20:01:01

by Éric Piel

[permalink] [raw]
Subject: Re: [PATCH 13/21] hp_accel: Use struct dev_pm_ops for power management

On 23-06-12 23:16, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <[email protected]>
>
> Make the hp_accel driver define its PM callbacks through
> a struct dev_pm_ops object rather than by using legacy PM hooks
> in struct acpi_device_ops.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>
Hello,
Looks fine from my point of view.

Reviewed-by: Éric Piel <[email protected]>

Éric

> ---
> drivers/platform/x86/hp_accel.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> Index: linux/drivers/platform/x86/hp_accel.c
> ===================================================================
> --- linux.orig/drivers/platform/x86/hp_accel.c
> +++ linux/drivers/platform/x86/hp_accel.c
> @@ -353,20 +353,22 @@ static int lis3lv02d_remove(struct acpi_
>
>
> #ifdef CONFIG_PM
> -static int lis3lv02d_suspend(struct acpi_device *device)
> +static int lis3lv02d_suspend(struct device *dev)
> {
> /* make sure the device is off when we suspend */
> lis3lv02d_poweroff(&lis3_dev);
> return 0;
> }
>
> -static int lis3lv02d_resume(struct acpi_device *device)
> +static int lis3lv02d_resume(struct device *dev)
> {
> return lis3lv02d_poweron(&lis3_dev);
> }
> +
> +static SIMPLE_DEV_PM_OPS(hp_accel_pm, lis3lv02d_suspend, lis3lv02d_resume);
> +#define HP_ACCEL_PM (&hp_accel_pm)
> #else
> -#define lis3lv02d_suspend NULL
> -#define lis3lv02d_resume NULL
> +#define HP_ACCEL_PM NULL
> #endif
>
> /* For the HP MDPS aka 3D Driveguard */
> @@ -377,9 +379,8 @@ static struct acpi_driver lis3lv02d_driv
> .ops = {
> .add = lis3lv02d_add,
> .remove = lis3lv02d_remove,
> - .suspend = lis3lv02d_suspend,
> - .resume = lis3lv02d_resume,
> - }
> + },
> + .drv.pm = HP_ACCEL_PM,
> };
>
> static int __init lis3lv02d_init_module(void)
>

2012-06-24 20:08:40

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 13/21] hp_accel: Use struct dev_pm_ops for power management

On Sunday, June 24, 2012, Éric Piel wrote:
> On 23-06-12 23:16, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <[email protected]>
> >
> > Make the hp_accel driver define its PM callbacks through
> > a struct dev_pm_ops object rather than by using legacy PM hooks
> > in struct acpi_device_ops.
> >
> > Signed-off-by: Rafael J. Wysocki <[email protected]>
> Hello,
> Looks fine from my point of view.
>
> Reviewed-by: Éric Piel <[email protected]>

Thanks a lot!

Rafael


> > ---
> > drivers/platform/x86/hp_accel.c | 15 ++++++++-------
> > 1 file changed, 8 insertions(+), 7 deletions(-)
> >
> > Index: linux/drivers/platform/x86/hp_accel.c
> > ===================================================================
> > --- linux.orig/drivers/platform/x86/hp_accel.c
> > +++ linux/drivers/platform/x86/hp_accel.c
> > @@ -353,20 +353,22 @@ static int lis3lv02d_remove(struct acpi_
> >
> >
> > #ifdef CONFIG_PM
> > -static int lis3lv02d_suspend(struct acpi_device *device)
> > +static int lis3lv02d_suspend(struct device *dev)
> > {
> > /* make sure the device is off when we suspend */
> > lis3lv02d_poweroff(&lis3_dev);
> > return 0;
> > }
> >
> > -static int lis3lv02d_resume(struct acpi_device *device)
> > +static int lis3lv02d_resume(struct device *dev)
> > {
> > return lis3lv02d_poweron(&lis3_dev);
> > }
> > +
> > +static SIMPLE_DEV_PM_OPS(hp_accel_pm, lis3lv02d_suspend, lis3lv02d_resume);
> > +#define HP_ACCEL_PM (&hp_accel_pm)
> > #else
> > -#define lis3lv02d_suspend NULL
> > -#define lis3lv02d_resume NULL
> > +#define HP_ACCEL_PM NULL
> > #endif
> >
> > /* For the HP MDPS aka 3D Driveguard */
> > @@ -377,9 +379,8 @@ static struct acpi_driver lis3lv02d_driv
> > .ops = {
> > .add = lis3lv02d_add,
> > .remove = lis3lv02d_remove,
> > - .suspend = lis3lv02d_suspend,
> > - .resume = lis3lv02d_resume,
> > - }
> > + },
> > + .drv.pm = HP_ACCEL_PM,
> > };
> >
> > static int __init lis3lv02d_init_module(void)
> >
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>

2012-06-28 22:06:28

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH missing/21] classmate-laptop: Use struct dev_pm_ops for power management

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

Make the classmate-laptop driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---

Hi all,

I overlooked the classmate-laptop driver in the ACPI conversion to PM
handling based on struct dev_pm_ops, so this one should go after [17/21] and
the next patches should be renumbered.

Thanks,
Rafael


---
drivers/platform/x86/classmate-laptop.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

Index: linux/drivers/platform/x86/classmate-laptop.c
===================================================================
--- linux.orig/drivers/platform/x86/classmate-laptop.c
+++ linux/drivers/platform/x86/classmate-laptop.c
@@ -362,15 +362,18 @@ static int cmpc_tablet_remove(struct acp
return cmpc_remove_acpi_notify_device(acpi);
}

-static int cmpc_tablet_resume(struct acpi_device *acpi)
+static int cmpc_tablet_resume(struct device *dev)
{
- struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+ struct input_dev *inputdev = dev_get_drvdata(dev);
+
unsigned long long val = 0;
- if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val)))
+ if (ACPI_SUCCESS(cmpc_get_tablet(to_acpi_device(dev)->handle, &val)))
input_report_switch(inputdev, SW_TABLET_MODE, !val);
return 0;
}

+static SIMPLE_DEV_PM_OPS(cmpc_tabled_pm, NULL, cmpc_tablet_resume);
+
static const struct acpi_device_id cmpc_tablet_device_ids[] = {
{CMPC_TABLET_HID, 0},
{"", 0}
@@ -384,9 +387,9 @@ static struct acpi_driver cmpc_tablet_ac
.ops = {
.add = cmpc_tablet_add,
.remove = cmpc_tablet_remove,
- .resume = cmpc_tablet_resume,
.notify = cmpc_tablet_handler,
- }
+ },
+ .drv.pm = &cmpc_tabled_pm,
};

2012-06-28 22:20:45

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH missing 2/21] fujitsu-tablet: Use struct dev_pm_ops for power management

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

Make the fujitsu-tablet driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct acpi_device_ops.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---

Hi all,

Another driver overlooked during the ACPI conversion to PM handling based on
struct dev_pm_ops, sorry about that.

This one should go after the classmate-laptop patch I've just posted.

Thanks,
Rafael

---
drivers/platform/x86/fujitsu-tablet.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

Index: linux/drivers/platform/x86/fujitsu-tablet.c
===================================================================
--- linux.orig/drivers/platform/x86/fujitsu-tablet.c
+++ linux/drivers/platform/x86/fujitsu-tablet.c
@@ -440,12 +440,14 @@ static int __devexit acpi_fujitsu_remove
return 0;
}

-static int acpi_fujitsu_resume(struct acpi_device *adev)
+static int acpi_fujitsu_resume(struct device *dev)
{
fujitsu_reset();
return 0;
}

+static SIMPLE_DEV_PM_OPS(acpi_fujitsu_pm, NULL, acpi_fujitsu_resume);
+
static struct acpi_driver acpi_fujitsu_driver = {
.name = MODULENAME,
.class = "hotkey",
@@ -453,8 +455,8 @@ static struct acpi_driver acpi_fujitsu_d
.ops = {
.add = acpi_fujitsu_add,
.remove = acpi_fujitsu_remove,
- .resume = acpi_fujitsu_resume,
- }
+ },
+ .drv.pm = &acpi_fujitsu_pm,
};

static int __init fujitsu_module_init(void)

Subject: Re: [PATCH missing/21] classmate-laptop: Use struct dev_pm_ops for power management

----- Original message -----
> From: Rafael J. Wysocki <[email protected]>
>
> Make the classmate-laptop driver define its PM callbacks through
> a struct dev_pm_ops object rather than by using legacy PM hooks
> in struct acpi_device_ops.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>
> ---
>
> Hi all,
>
> I overlooked the classmate-laptop driver in the ACPI conversion to PM
> handling based on struct dev_pm_ops, so this one should go after [17/21]
> and the next patches should be renumbered.
>
> Thanks,
> Rafael
>
>
> ---
>  drivers/platform/x86/classmate-laptop.c |    13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> Index: linux/drivers/platform/x86/classmate-laptop.c
> ===================================================================
> --- linux.orig/drivers/platform/x86/classmate-laptop.c
> +++ linux/drivers/platform/x86/classmate-laptop.c
> @@ -362,15 +362,18 @@ static int cmpc_tablet_remove(struct acp
>      return cmpc_remove_acpi_notify_device(acpi);
>  }

> -static int cmpc_tablet_resume(struct acpi_device *acpi)
> +static int cmpc_tablet_resume(struct device *dev)
>  {
> -    struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
> +    struct input_dev *inputdev = dev_get_drvdata(dev);
> +
>      unsigned long long val = 0;
> -    if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val)))
> +    if (ACPI_SUCCESS(cmpc_get_tablet(to_acpi_device(dev)->handle, &val)))
>          input_report_switch(inputdev, SW_TABLET_MODE, !val);
>      return 0;
>  }

> +static SIMPLE_DEV_PM_OPS(cmpc_tabled_pm, NULL, cmpc_tablet_resume);
> +
>  static const struct acpi_device_id cmpc_tablet_device_ids[] = {
>      {CMPC_TABLET_HID, 0},
>      {"", 0}
> @@ -384,9 +387,9 @@ static struct acpi_driver cmpc_tablet_ac
>      .ops = {
>          .add = cmpc_tablet_add,
>          .remove = cmpc_tablet_remove,
> -        .resume = cmpc_tablet_resume,
>          .notify = cmpc_tablet_handler,
> -    }
> +    },
> +    .drv.pm = &cmpc_tabled_pm,
>  };



Aside from the typo tabled,

Acked-by: Thadeu Lima de Souza Cascardo <[email protected]>

2012-06-29 21:46:34

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH missing/21] classmate-laptop: Use struct dev_pm_ops for power management

On Friday, June 29, 2012, Thadeu Cascardo wrote:
> ----- Original message -----
> > From: Rafael J. Wysocki <[email protected]>
> >
> > Make the classmate-laptop driver define its PM callbacks through
> > a struct dev_pm_ops object rather than by using legacy PM hooks
> > in struct acpi_device_ops.
> >
> > Signed-off-by: Rafael J. Wysocki <[email protected]>
> > ---
> >
> > Hi all,
> >
> > I overlooked the classmate-laptop driver in the ACPI conversion to PM
> > handling based on struct dev_pm_ops, so this one should go after [17/21]
> > and the next patches should be renumbered.
> >
> > Thanks,
> > Rafael
> >
> >
> > ---
> > drivers/platform/x86/classmate-laptop.c | 13 ++++++++-----
> > 1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > Index: linux/drivers/platform/x86/classmate-laptop.c
> > ===================================================================
> > --- linux.orig/drivers/platform/x86/classmate-laptop.c
> > +++ linux/drivers/platform/x86/classmate-laptop.c
> > @@ -362,15 +362,18 @@ static int cmpc_tablet_remove(struct acp
> > return cmpc_remove_acpi_notify_device(acpi);
> > }
> >
> > -static int cmpc_tablet_resume(struct acpi_device *acpi)
> > +static int cmpc_tablet_resume(struct device *dev)
> > {
> > - struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
> > + struct input_dev *inputdev = dev_get_drvdata(dev);
> > +
> > unsigned long long val = 0;
> > - if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val)))
> > + if (ACPI_SUCCESS(cmpc_get_tablet(to_acpi_device(dev)->handle, &val)))
> > input_report_switch(inputdev, SW_TABLET_MODE, !val);
> > return 0;
> > }
> >
> > +static SIMPLE_DEV_PM_OPS(cmpc_tabled_pm, NULL, cmpc_tablet_resume);
> > +
> > static const struct acpi_device_id cmpc_tablet_device_ids[] = {
> > {CMPC_TABLET_HID, 0},
> > {"", 0}
> > @@ -384,9 +387,9 @@ static struct acpi_driver cmpc_tablet_ac
> > .ops = {
> > .add = cmpc_tablet_add,
> > .remove = cmpc_tablet_remove,
> > - .resume = cmpc_tablet_resume,
> > .notify = cmpc_tablet_handler,
> > - }
> > + },
> > + .drv.pm = &cmpc_tabled_pm,
> > };
> >
> >
>
> Aside from the typo tabled,

Fixed now.

> Acked-by: Thadeu Lima de Souza Cascardo <[email protected]>

Thanks!