linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] Hook acpi D-state method to pnp suspend/resume
@ 2007-06-01  2:37 Shaohua Li
  2007-06-07  1:55 ` Len Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Shaohua Li @ 2007-06-01  2:37 UTC (permalink / raw)
  To: linux acpi; +Cc: Adam Belay, Len Brown

Hook acpi D-state method to pnp suspend/resume, so we have a chance to poweroff the device.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>

Index: 2.6.22-rc2/include/linux/pnp.h
===================================================================
--- 2.6.22-rc2.orig/include/linux/pnp.h	2007-05-23 09:15:14.000000000 +0800
+++ 2.6.22-rc2/include/linux/pnp.h	2007-05-24 16:14:17.000000000 +0800
@@ -335,6 +335,10 @@ struct pnp_protocol {
 	int (*set)(struct pnp_dev *dev, struct pnp_resource_table *res);
 	int (*disable)(struct pnp_dev *dev);
 
+	/* protocol specific suspend/resume */
+	int (*suspend)(struct pnp_dev *dev, pm_message_t state);
+	int (*resume)(struct pnp_dev *dev);
+
 	/* used by pnp layer only (look but don't touch) */
 	unsigned char		number;		/* protocol number*/
 	struct device		dev;		/* link to driver model */
Index: 2.6.22-rc2/drivers/pnp/driver.c
===================================================================
--- 2.6.22-rc2.orig/drivers/pnp/driver.c	2007-05-23 09:15:14.000000000 +0800
+++ 2.6.22-rc2/drivers/pnp/driver.c	2007-05-24 16:15:29.000000000 +0800
@@ -167,6 +167,8 @@ static int pnp_bus_suspend(struct device
 	    		return error;
 	}
 
+	if (pnp_dev->protocol && pnp_dev->protocol->suspend)
+		pnp_dev->protocol->suspend(pnp_dev, state);
 	return 0;
 }
 
@@ -179,6 +181,9 @@ static int pnp_bus_resume(struct device 
 	if (!pnp_drv)
 		return 0;
 
+	if (pnp_dev->protocol && pnp_dev->protocol->resume)
+		pnp_dev->protocol->resume(pnp_dev);
+
 	if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) {
 		error = pnp_start_dev(pnp_dev);
 		if (error)
Index: 2.6.22-rc2/drivers/pnp/pnpacpi/core.c
===================================================================
--- 2.6.22-rc2.orig/drivers/pnp/pnpacpi/core.c	2007-05-23 09:15:14.000000000 +0800
+++ 2.6.22-rc2/drivers/pnp/pnpacpi/core.c	2007-06-01 10:35:13.000000000 +0800
@@ -119,11 +119,23 @@ static int pnpacpi_disable_resources(str
 	return ACPI_FAILURE(status) ? -ENODEV : 0;
 }
 
+static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
+{
+	return acpi_bus_set_power((acpi_handle)dev->data, 3);
+}
+
+static int pnpacpi_resume(struct pnp_dev *dev)
+{
+	return acpi_bus_set_power((acpi_handle)dev->data, 0);
+}
+
 static struct pnp_protocol pnpacpi_protocol = {
 	.name	= "Plug and Play ACPI",
 	.get	= pnpacpi_get_resources,
 	.set	= pnpacpi_set_resources,
 	.disable = pnpacpi_disable_resources,
+	.suspend = pnpacpi_suspend,
+	.resume = pnpacpi_resume,
 };
 
 static int __init pnpacpi_add_device(struct acpi_device *device)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Hook acpi D-state method to pnp suspend/resume
  2007-06-01  2:37 [patch] Hook acpi D-state method to pnp suspend/resume Shaohua Li
@ 2007-06-07  1:55 ` Len Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Len Brown @ 2007-06-07  1:55 UTC (permalink / raw)
  To: Shaohua Li; +Cc: linux acpi, Adam Belay

On Thursday 31 May 2007 22:37, Shaohua Li wrote:

I like this patch, it may save power while in S3...
I gather that it should also automatically expose the D-state controls
for these PNP devices in sysfs, which may come in very handy...

> +static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
> +{
> +       return acpi_bus_set_power((acpi_handle)dev->data, 3);
> +}
> +

This should usually work, but...
If the device is enabled as a wakeup device, this could
disable its wakeup capability.

So in that case, we need to check _S3W to make sure that
we are not putting the device in a D-state deeper than
it can still wake the system.

-Len
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-07  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-01  2:37 [patch] Hook acpi D-state method to pnp suspend/resume Shaohua Li
2007-06-07  1:55 ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).