From patchwork Mon Feb 24 22:34:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Mason X-Patchwork-Id: 323792 X-Patchwork-Delegate: davem@davemloft.net 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.180.67]) by ozlabs.org (Postfix) with ESMTP id A275B2C0089 for ; Tue, 25 Feb 2014 09:34:24 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752898AbaBXWeU (ORCPT ); Mon, 24 Feb 2014 17:34:20 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:37386 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752563AbaBXWeS (ORCPT ); Mon, 24 Feb 2014 17:34:18 -0500 Received: by mail-pa0-f44.google.com with SMTP id kq14so7176243pab.3 for ; Mon, 24 Feb 2014 14:34:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CVcAIr9Bk+NR3n0OSUB2IurZ26O3sck2anmeCJs1Fa0=; b=Ic+OHLksGY1hLNvv18kBGDPMIxyde6QIQB51KbR6GWa2Qwa7DX5nSmqYxVzclcYBL+ oqHmxq27emjMe3AZcbjPYEoVIVW8IZh+4HthLVMxt7bLxzOjqg4UQl4Pn/AtIIwDE7vV DIYScDvONBlntXdxYJep4b2SdfyaWJEYU1AUiBbPUm5AXwV1rQfEUutVVzY4aymG2atz bX3dZeYoLtQW9iWSoRAKkI1EZqUp779S8Ak0q5gcMOaNAolGLuJfpOL60bv/mvAVyyvO JgpfBMG3On7DSpEQD4ynXXKZoXeZlR5FuwJDzfOS+lefOj/th2VdWfaO+91jov/Htc7r vUvw== X-Gm-Message-State: ALoCoQlTMaq7KDJhtIlgnXlkEMhoBh1oziDYZc+pDc1z/q2gcKVC5wtMf0mq8CMmbg2tieS4HNZe X-Received: by 10.68.133.229 with SMTP id pf5mr2241316pbb.115.1393281258576; Mon, 24 Feb 2014 14:34:18 -0800 (PST) Received: from nas (184-98-202-49.phnx.qwest.net. [184.98.202.49]) by mx.google.com with ESMTPSA id bz4sm3520965pbb.12.2014.02.24.14.34.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Feb 2014 14:34:15 -0800 (PST) Received: by nas (sSMTP sendmail emulation); Mon, 24 Feb 2014 15:34:05 -0700 From: Jon Mason To: netdev@vger.kernel.org Cc: Tristram Ha Subject: [RFC 1/3] ksz884x: Use pci_set_power_state() for setting PM states Date: Mon, 24 Feb 2014 15:34:03 -0700 Message-Id: <1393281245-3951-1-git-send-email-jdmason@kudzu.us> X-Mailer: git-send-email 1.8.3.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the existing infrastructure of pci_set_power_state() instead of setting the relevant bits via PCI config read/write in the driver. Also, use pci_pme_active() to set the PCI_PM_CTRL_PME_ENABLE bit in PCI PM control register. pci_set_power_state() and pci_pme_active() perform the same operations as the driver did before, so there should be no functional change. That being said, this has not been tested. Signed-off-by: Jon Mason Cc: Tristram Ha --- drivers/net/ethernet/micrel/ksz884x.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index ce84dc2..d658231 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c @@ -3524,17 +3524,17 @@ static void hw_cfg_wol_pme(struct ksz_hw *hw, int set) { struct dev_info *hw_priv = container_of(hw, struct dev_info, hw); struct pci_dev *pdev = hw_priv->pdev; - u16 data; if (!pdev->pm_cap) return; - pci_read_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, &data); - data &= ~PCI_PM_CTRL_STATE_MASK; - if (set) - data |= PCI_PM_CTRL_PME_ENABLE | PCI_D3hot; - else - data &= ~PCI_PM_CTRL_PME_ENABLE; - pci_write_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, data); + + if (set) { + pci_pme_active(pdev, true); + pci_set_power_state(pdev, PCI_D3hot); + } else { + pci_pme_active(pdev, false); + pci_set_power_state(pdev, PCI_D0); + } } /**