From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjorn Helgaas Subject: Re: [PATCH] PNPACPI: add support for remote wakeup Date: Mon, 8 Mar 2010 15:21:59 -0700 Message-ID: <201003081521.59985.bjorn.helgaas@hp.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Return-path: Received: from g5t0008.atlanta.hp.com ([15.192.0.45]:5469 "EHLO g5t0008.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755786Ab0CHWWE (ORCPT ); Mon, 8 Mar 2010 17:22:04 -0500 In-Reply-To: Content-Disposition: inline Sender: linux-acpi-owner@vger.kernel.org List-Id: linux-acpi@vger.kernel.org To: Alan Stern Cc: Kernel development list , linux-acpi@vger.kernel.org, "Rafael J. Wysocki" On Monday 08 March 2010 02:50:50 pm Alan Stern wrote: > This patch (as1354) adds remote-wakeup support to the pnpacpi driver. > The new can_wakeup method also allows other PNP protocol drivers > (pnpbios or iaspnp) to add wakeup support, but I don't know enough > about how they work to actually do it. > > Signed-off-by: Alan Stern We usually send PNP patches through the ACPI tree, so I added a CC to linux-acpi. > --- usb-2.6.orig/drivers/pnp/core.c > +++ usb-2.6/drivers/pnp/core.c > @@ -164,6 +164,9 @@ int __pnp_add_device(struct pnp_dev *dev > list_add_tail(&dev->global_list, &pnp_global); > list_add_tail(&dev->protocol_list, &dev->protocol->devices); > spin_unlock(&pnp_lock); > + if (dev->protocol->can_wakeup) > + device_set_wakeup_capable(&dev->dev, > + dev->protocol->can_wakeup(dev)); I also added Rafael because he added code in acpi_bind_one() that does the same thing. I think the struct dev there will be the same one as &dev->dev here: we build both an acpi_device and a pnp_dev, and they refer to the same struct device. However, I think we still need your patch because acpi_bind_one() is only used for PCI devices, so it looks like there's currently no way to use acpi_pm_device_sleep_wake() for non-PCI devices. Reviewed-by: Bjorn Helgaas > return device_register(&dev->dev); > } > > Index: usb-2.6/drivers/pnp/pnpacpi/core.c > =================================================================== > --- usb-2.6.orig/drivers/pnp/pnpacpi/core.c > +++ usb-2.6/drivers/pnp/pnpacpi/core.c > @@ -121,17 +121,37 @@ static int pnpacpi_disable_resources(str > } > > #ifdef CONFIG_ACPI_SLEEP > +static bool pnpacpi_can_wakeup(struct pnp_dev *dev) > +{ > + struct acpi_device *acpi_dev = dev->data; > + acpi_handle handle = acpi_dev->handle; > + > + return acpi_bus_can_wakeup(handle); > +} > + > static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) > { > struct acpi_device *acpi_dev = dev->data; > acpi_handle handle = acpi_dev->handle; > int power_state; > > + if (device_can_wakeup(&dev->dev)) { > + int rc = acpi_pm_device_sleep_wake(&dev->dev, > + device_may_wakeup(&dev->dev)); > + > + if (rc) > + return rc; > + } > power_state = acpi_pm_device_sleep_state(&dev->dev, NULL); > if (power_state < 0) > power_state = (state.event == PM_EVENT_ON) ? > ACPI_STATE_D0 : ACPI_STATE_D3; > > + /* acpi_bus_set_power() often fails (keyboard port can't be > + * powered-down?), and in any case, our return value is ignored > + * by pnp_bus_suspend(). Hence we don't revert the wakeup > + * setting if the set_power fails. > + */ > return acpi_bus_set_power(handle, power_state); > } > > @@ -140,6 +160,8 @@ static int pnpacpi_resume(struct pnp_dev > struct acpi_device *acpi_dev = dev->data; > acpi_handle handle = acpi_dev->handle; > > + if (device_may_wakeup(&dev->dev)) > + acpi_pm_device_sleep_wake(&dev->dev, false); > return acpi_bus_set_power(handle, ACPI_STATE_D0); > } > #endif > @@ -150,6 +172,7 @@ struct pnp_protocol pnpacpi_protocol = { > .set = pnpacpi_set_resources, > .disable = pnpacpi_disable_resources, > #ifdef CONFIG_ACPI_SLEEP > + .can_wakeup = pnpacpi_can_wakeup, > .suspend = pnpacpi_suspend, > .resume = pnpacpi_resume, > #endif > >