From patchwork Mon Sep 22 21:52:13 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 960 X-Patchwork-Delegate: jgarzik@pobox.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 5F554DDF13 for ; Tue, 23 Sep 2008 07:53:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753549AbYIVVxX (ORCPT ); Mon, 22 Sep 2008 17:53:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753530AbYIVVxX (ORCPT ); Mon, 22 Sep 2008 17:53:23 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:58269 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753518AbYIVVxW (ORCPT ); Mon, 22 Sep 2008 17:53:22 -0400 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id m8MLqDtM018347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Sep 2008 14:52:14 -0700 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id m8MLqD65031949; Mon, 22 Sep 2008 14:52:13 -0700 Message-Id: <200809222152.m8MLqD65031949@imap1.linux-foundation.org> Subject: [patch 05/21] sky2: adapt to the reworked PCI PM To: jeff@garzik.org Cc: netdev@vger.kernel.org, akpm@linux-foundation.org, rjw@sisk.pl, jbarnes@virtuousgeek.org, stephen.hemminger@vyatta.com From: akpm@linux-foundation.org Date: Mon, 22 Sep 2008 14:52:13 -0700 X-Spam-Status: No, hits=-3.359 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: "Rafael J. Wysocki" Adapt the sky2 driver to the reworked PCI PM * Use device_set_wakeup_enable() and friends as needed * Remove an open-coded reference to the standard PCI PM registers * Use pci_prepare_to_sleep() and pci_back_from_sleep() in the ->suspend() and ->resume() callbacks * Use the observation that it is sufficient to call pci_enable_wake() once, unless it fails Tested on Asus M3A32-MVP (Yukon-2 EC Ultra rev 3). Signed-off-by: Rafael J. Wysocki Cc: Jeff Garzik Cc: Jesse Barnes Cc: Stephen Hemminger Signed-off-by: Andrew Morton --- drivers/net/sky2.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff -puN drivers/net/sky2.c~skty2-adapt-to-the-reworked-pci-pm drivers/net/sky2.c --- a/drivers/net/sky2.c~skty2-adapt-to-the-reworked-pci-pm +++ a/drivers/net/sky2.c @@ -3034,7 +3034,8 @@ static int sky2_set_wol(struct net_devic struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; - if (wol->wolopts & ~sky2_wol_supported(sky2->hw)) + if ((wol->wolopts & ~sky2_wol_supported(sky2->hw)) + || !device_can_wakeup(&hw->pdev->dev)) return -EOPNOTSUPP; sky2->wol = wol->wolopts; @@ -3045,6 +3046,8 @@ static int sky2_set_wol(struct net_devic sky2_write32(hw, B0_CTST, sky2->wol ? Y2_HW_WOL_ON : Y2_HW_WOL_OFF); + device_set_wakeup_enable(&hw->pdev->dev, sky2->wol); + if (!netif_running(dev)) sky2_wol_init(sky2); return 0; @@ -4179,18 +4182,6 @@ static int __devinit sky2_test_msi(struc return err; } -static int __devinit pci_wake_enabled(struct pci_dev *dev) -{ - int pm = pci_find_capability(dev, PCI_CAP_ID_PM); - u16 value; - - if (!pm) - return 0; - if (pci_read_config_word(dev, pm + PCI_PM_CTRL, &value)) - return 0; - return value & PCI_PM_CTRL_PME_ENABLE; -} - /* * Read and parse the first part of Vital Product Data */ @@ -4314,7 +4305,7 @@ static int __devinit sky2_probe(struct p } } - wol_default = pci_wake_enabled(pdev) ? WAKE_MAGIC : 0; + wol_default = device_may_wakeup(&pdev->dev) ? WAKE_MAGIC : 0; err = -ENOMEM; hw = kzalloc(sizeof(*hw), GFP_KERNEL); @@ -4479,7 +4470,7 @@ static void __devexit sky2_remove(struct static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) { struct sky2_hw *hw = pci_get_drvdata(pdev); - int i, wol = 0; + int i; if (!hw) return 0; @@ -4497,8 +4488,6 @@ static int sky2_suspend(struct pci_dev * if (sky2->wol) sky2_wol_init(sky2); - - wol |= sky2->wol; } sky2_write32(hw, B0_IMSK, 0); @@ -4506,8 +4495,7 @@ static int sky2_suspend(struct pci_dev * sky2_power_aux(hw); pci_save_state(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + pci_prepare_to_sleep(pdev); return 0; } @@ -4520,7 +4508,7 @@ static int sky2_resume(struct pci_dev *p if (!hw) return 0; - err = pci_set_power_state(pdev, PCI_D0); + err = pci_back_from_sleep(pdev); if (err) goto out; @@ -4528,8 +4516,6 @@ static int sky2_resume(struct pci_dev *p if (err) goto out; - pci_enable_wake(pdev, PCI_D0, 0); - /* Re-enable all clocks */ if (hw->chip_id == CHIP_ID_YUKON_EX || hw->chip_id == CHIP_ID_YUKON_EC_U || @@ -4588,8 +4574,8 @@ static void sky2_shutdown(struct pci_dev if (wol) sky2_power_aux(hw); - pci_enable_wake(pdev, PCI_D3hot, wol); - pci_enable_wake(pdev, PCI_D3cold, wol); + if (pci_enable_wake(pdev, PCI_D3cold, wol)) + pci_enable_wake(pdev, PCI_D3hot, wol); pci_disable_device(pdev); pci_set_power_state(pdev, PCI_D3hot);