From patchwork Tue May 26 08:03:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 1297780 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DZ24zU2k; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49WRMh49ymz9sRK for ; Tue, 26 May 2020 18:05:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731544AbgEZIFC (ORCPT ); Tue, 26 May 2020 04:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbgEZIFA (ORCPT ); Tue, 26 May 2020 04:05:00 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9950C03E97E; Tue, 26 May 2020 01:04:59 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id z15so4563016pjb.0; Tue, 26 May 2020 01:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jUN7Z5XSVYvGRqKnsaDJyJI44CO7kk2ydcRogwW0g9A=; b=DZ24zU2kzBS10KM1oPqihig3W3Vzqz1C2+panFVc7mJDCLfPTOfPj2XQ1p8SPHrSbf p3w5XWU822itPLD5+ikGpsY0k0LBjfX7TxUAi//EqbvSTfv+wp6JGplQS8PL1DLzX0GL 7YhJ5fmejEB0lw7B0QpejvATbBc97S9JlsEge5g6/YO/duz4OV5s/ondkAiF2YY6A0nZ mUXEG2Ij/+9giVkfHI2C5gdKtAx0F3mJs3tAE8eKZ8vwcXhPOaIXJd0BiiDdgUlOZbmS jr0Di9woJFL0xaqhNrvfWjbBMt/w4JFPrq2lKCliOAxVcxZ6ZEeeB8e7i9ettKzjEBCc ggwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jUN7Z5XSVYvGRqKnsaDJyJI44CO7kk2ydcRogwW0g9A=; b=CQCquP6ZkXgzWzaDDGQMRGgRoEA409wMRrWJc7Zp0uhVj6bUBT13EBE8lp2U03eCpZ HcYn73ID2z2XMRMuUOPutKAXOhLIhofR+CZ59WIBDbWyETksC7g3ej0juHQtIFQa77KN GjGpnJlM1saz2sbMR3Y0vr0mgSMNiAdaBzpJl4qSdsofaEdyzKF8zEEaEDf0DB1daSWM huJyY3YbfcMRvu345d5MSuqVlE+2iHaLMkvR978jSKhmWzDENq/sQCmpTSYgOKWw9OUl ewYqQ1majYhmTT3Zc9u0/mlxQhoisJ5Vp4zTj715z96BRA/XhNkEwaqL2ShiMqQ1lXRp xDVg== X-Gm-Message-State: AOAM531xM72jj6sbcg2EzrsmvAvGiw1hMPziiabpWFHoFrfG4P1i0bB3 RT0imkOevHxF22+Qk5IP+fl9rG6wTsyIqg== X-Google-Smtp-Source: ABdhPJw+WiWEIFxfAR2QfArjGdBo9QVw2y9nKBsz4PzBM1D5S9VNTZie6OeSTo4FFpdNH2d2r0BxnA== X-Received: by 2002:a17:90a:f098:: with SMTP id cn24mr25039148pjb.201.1590480299286; Tue, 26 May 2020 01:04:59 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.209]) by smtp.gmail.com with ESMTPSA id fa19sm8614477pjb.18.2020.05.26.01.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 01:04:58 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , "David S. Miller" , Jakub Kicinski , Don Fry , Tom Lendacky Cc: Vaibhav Gupta , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [RFC PATCH v1 1/3] pcnet32: Convert to generic power management Date: Tue, 26 May 2020 13:33:22 +0530 Message-Id: <20200526080324.69828-2-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526080324.69828-1-vaibhavgupta40@gmail.com> References: <20200526080324.69828-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org compile-tested only Remove legacy PM callbacks and use generic operations. With legacy code, drivers were responsible for handling PCI PM operations like "pci_save_state()". In generic code, all these handled by PCI core. The generic "suspend()" and "resume()" are called at the same point the legacy ones were called. Thus, it does not affect the normal functioning of the driver. Signed-off-by: Vaibhav Gupta --- drivers/net/ethernet/amd/pcnet32.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c index 07e8211eea51..d32f54d760e7 100644 --- a/drivers/net/ethernet/amd/pcnet32.c +++ b/drivers/net/ethernet/amd/pcnet32.c @@ -2913,30 +2913,27 @@ static void pcnet32_watchdog(struct timer_list *t) mod_timer(&lp->watchdog_timer, round_jiffies(PCNET32_WATCHDOG_TIMEOUT)); } -static int pcnet32_pm_suspend(struct pci_dev *pdev, pm_message_t state) +static int pcnet32_pm_suspend(struct device *device_d) { - struct net_device *dev = pci_get_drvdata(pdev); + struct net_device *dev = dev_get_drvdata(device_d); if (netif_running(dev)) { netif_device_detach(dev); pcnet32_close(dev); } - pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + return 0; } -static int pcnet32_pm_resume(struct pci_dev *pdev) +static int pcnet32_pm_resume(struct device *device_d) { - struct net_device *dev = pci_get_drvdata(pdev); - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); + struct net_device *dev = dev_get_drvdata(device_d); if (netif_running(dev)) { pcnet32_open(dev); netif_device_attach(dev); } + return 0; } @@ -2957,13 +2954,16 @@ static void pcnet32_remove_one(struct pci_dev *pdev) } } +static SIMPLE_DEV_PM_OPS(pcnet32_pm_ops, pcnet32_pm_suspend, pcnet32_pm_resume); + static struct pci_driver pcnet32_driver = { .name = DRV_NAME, .probe = pcnet32_probe_pci, .remove = pcnet32_remove_one, .id_table = pcnet32_pci_tbl, - .suspend = pcnet32_pm_suspend, - .resume = pcnet32_pm_resume, + .driver = { + .pm = &pcnet32_pm_ops, + }, }; /* An additional parameter that may be passed in... */ From patchwork Tue May 26 08:03:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 1297782 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=pDkz+eJC; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49WRMp1GgFz9sSs for ; Tue, 26 May 2020 18:05:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731590AbgEZIFH (ORCPT ); Tue, 26 May 2020 04:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbgEZIFF (ORCPT ); Tue, 26 May 2020 04:05:05 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C15CC03E97E; Tue, 26 May 2020 01:05:05 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id z15so4563094pjb.0; Tue, 26 May 2020 01:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PlwFQdfdCmfSwOeUTRovD942w6tO4d7LRvzC7J4XcqA=; b=pDkz+eJChZDIv9m2rtYLnfyfQOMv1f7nYKnKlGQuQ+paT+GzmxYrIz78q8SEZz5okF 4q8f9Z4NNdrvbaIg/sZq+yLfhIq9va4yW1c/kysxCU4YFOMTmZ9R+VgDno++IXcUaKZL 47tcm2H+k4dRpuv4+eLNweYz+T/u7aFxWJEe/8Fs8EAk5BDlk3UHpMJq+/I2yEn6xxgI cv+X/DdGPPMhmT9djiGWOxWjCkk96xe0Oi8V0SCHlbzDQp8vBQaAgXXkvGfFcDv6ktWm aPQbhmmdCP+IaCYVBiia7cYmX3T93rIGUjkP0JDCiWHvXng2+wkAWyoNfKSdglDZB7Rd PYEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PlwFQdfdCmfSwOeUTRovD942w6tO4d7LRvzC7J4XcqA=; b=LotqSi4NTlGCr3iYuy69+NNJdSyKQesRD0ndFMn2MXhJX9VbqdHGBQw5LhaMD4rTMS nIAi9HKAm414dFXYeOPBbbXyiqJsxP5zVZH5xGY29k1EoPjtO3RweAW4ILmZc/7U7cHN ji7+RVOp+27AGCxyIbzyaTZDco4vfGw9luzkpvS1I3pFrTx7D1hcdKDQxQp2TjNbWuBu gGUQTXM4qdsnsP3xiWvSktRYtQ+IapKlS4GAJ6MbaToM60GKpzYg9k9C33sSpssn7soj CrmU0PfOFCFxNHRQBA0lp4NgitAN6QvFtjth95hVj0lEUclNX5zZ1HElcG9xmLQLUuPj yq/A== X-Gm-Message-State: AOAM5324HvaR7tqI8P/VoyHaTOFKAiehGfQ1mftfPjpe82k+cRW2L5DL q06CmvDLWaOyndukFh44zq4= X-Google-Smtp-Source: ABdhPJzWmQSDNQwEgG3hSXQXPPh564uH3Bj59AaIEpppfhcb0ZSx42XMCCIubBNsIaZom0CqcM0Ybg== X-Received: by 2002:a17:90a:b883:: with SMTP id o3mr23087659pjr.81.1590480305058; Tue, 26 May 2020 01:05:05 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.209]) by smtp.gmail.com with ESMTPSA id fa19sm8614477pjb.18.2020.05.26.01.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 01:05:04 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , "David S. Miller" , Jakub Kicinski , Don Fry , Tom Lendacky Cc: Vaibhav Gupta , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [RFC PATCH v1 2/3] amd8111e: Convert to generic power mangement Date: Tue, 26 May 2020 13:33:23 +0530 Message-Id: <20200526080324.69828-3-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526080324.69828-1-vaibhavgupta40@gmail.com> References: <20200526080324.69828-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org compile-tested only Drivers should not save device registers and/or change the power state of the device. As per the generic PM approach, these are handled by PCI core. The driver should support dev_pm_ops callbacks and bind them to pci_driver. Signed-off-by: Vaibhav Gupta --- drivers/net/ethernet/amd/amd8111e.c | 30 +++++++++++------------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c index 7a1286f8e983..c6591b33abcc 100644 --- a/drivers/net/ethernet/amd/amd8111e.c +++ b/drivers/net/ethernet/amd/amd8111e.c @@ -1580,9 +1580,10 @@ static void amd8111e_tx_timeout(struct net_device *dev, unsigned int txqueue) if(!err) netif_wake_queue(dev); } -static int amd8111e_suspend(struct pci_dev *pci_dev, pm_message_t state) + +static int amd8111e_suspend(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pci_dev); + struct net_device *dev = dev_get_drvdata(dev_d); struct amd8111e_priv *lp = netdev_priv(dev); if (!netif_running(dev)) @@ -1609,34 +1610,24 @@ static int amd8111e_suspend(struct pci_dev *pci_dev, pm_message_t state) if(lp->options & OPTION_WAKE_PHY_ENABLE) amd8111e_enable_link_change(lp); - pci_enable_wake(pci_dev, PCI_D3hot, 1); - pci_enable_wake(pci_dev, PCI_D3cold, 1); + device_set_wakeup_enable(dev_d, 1); } else{ - pci_enable_wake(pci_dev, PCI_D3hot, 0); - pci_enable_wake(pci_dev, PCI_D3cold, 0); + device_set_wakeup_enable(dev_d, 0); } - pci_save_state(pci_dev); - pci_set_power_state(pci_dev, PCI_D3hot); - return 0; } -static int amd8111e_resume(struct pci_dev *pci_dev) + +static int amd8111e_resume(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pci_dev); + struct net_device *dev = dev_get_drvdata(dev_d); struct amd8111e_priv *lp = netdev_priv(dev); if (!netif_running(dev)) return 0; - pci_set_power_state(pci_dev, PCI_D0); - pci_restore_state(pci_dev); - - pci_enable_wake(pci_dev, PCI_D3hot, 0); - pci_enable_wake(pci_dev, PCI_D3cold, 0); /* D3 cold */ - netif_device_attach(dev); spin_lock_irq(&lp->lock); @@ -1918,13 +1909,14 @@ static const struct pci_device_id amd8111e_pci_tbl[] = { }; MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); +static SIMPLE_DEV_PM_OPS(amd8111e_pm_ops, amd8111e_suspend, amd8111e_resume); + static struct pci_driver amd8111e_driver = { .name = MODULE_NAME, .id_table = amd8111e_pci_tbl, .probe = amd8111e_probe_one, .remove = amd8111e_remove_one, - .suspend = amd8111e_suspend, - .resume = amd8111e_resume + .driver.pm = &amd8111e_pm_ops }; module_pci_driver(amd8111e_driver); From patchwork Tue May 26 08:03:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 1297783 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=X3CG+oVN; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49WRMw2kCJz9sSs for ; Tue, 26 May 2020 18:05:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731611AbgEZIFM (ORCPT ); Tue, 26 May 2020 04:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbgEZIFL (ORCPT ); Tue, 26 May 2020 04:05:11 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17AB3C03E97E; Tue, 26 May 2020 01:05:11 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id w20so4606147pga.6; Tue, 26 May 2020 01:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ctzNEK9ct3Xheefnk+QOHIxDO7kXYLYdjrWKg/OFEKg=; b=X3CG+oVNVMX0lnR1bi1OH2EBx9kaknDBst0b0ZXlD1lfVkqB9xV21QY6KlTOXvqitn 0smFZVRkdfWyhtq61P49oHA0xGA6wXQ1JLgF1/G4YuiyR7NlsJEKkw158Nc37bGnGIBn 0uAFuFDVBWHSzmJgM2SnNAEhX4pyBRHMNWuZOz9wy8n2/lQUX843A7Q/oSAjs4x22kyB 0Ho+PzQcqCnkDcrqqboUJFsG04pfnotwisLoJSeGqAzOrk/klA/a/N6LPb8zyyz5vcaV tNpFvwffBFksgUI1WpGWYtkKwHoCUYfl0Yg0zdapn/RkupzOuLVN37cuQ62oKt4Fvl7k jd+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ctzNEK9ct3Xheefnk+QOHIxDO7kXYLYdjrWKg/OFEKg=; b=DTsHeU6LKEBpGCYahHGgQWMUbw9F0x+EBjxhdKX84FOuL8+97XVFgBr4OojlCyLa3K A591Lx/JYKjZsUJMgjQ2O6da3DmJOmVR2w3gfHMRGGUzA+XDGVifSH8PK/LT1UFbLGAD g4yLAswRZtovhg/oloSt+ZLN8MgnJukB870/IokCikuy/isLheciClS6mLneaelujTPE uZb+R7x/cQjt3cFJaP9Y/MGSsZv++asZ/mrqKVr/AkQdiDftmb8QhwUkGIyRpbkX0ub6 JLgRRIkvqfecJFT0BrWqOQW4fdmmKn0B1t3wPlAz3Qj7Z1wWhC14zaJ8iRiiIZJMmzSF /HpQ== X-Gm-Message-State: AOAM533IknjMEyvGYv3TIpd5N0SOzZezk65YprMw2Vqy2QcBk/a6wWDQ 3bmCww8CDhRUzpqKVJNZesI= X-Google-Smtp-Source: ABdhPJztp+CYa62M7C0UA8/be7wZZ+tfVKlbQCJ9G2m7H6/p2rSXV64EhYvePkYTV3VRwa2BU5ITWA== X-Received: by 2002:a05:6a00:a:: with SMTP id h10mr21383389pfk.310.1590480310570; Tue, 26 May 2020 01:05:10 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.209]) by smtp.gmail.com with ESMTPSA id fa19sm8614477pjb.18.2020.05.26.01.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 01:05:10 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , "David S. Miller" , Jakub Kicinski , Don Fry , Tom Lendacky Cc: Vaibhav Gupta , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [RFC PATCH v1 3/3] amd-xgbe: Convert to generic power management Date: Tue, 26 May 2020 13:33:24 +0530 Message-Id: <20200526080324.69828-4-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526080324.69828-1-vaibhavgupta40@gmail.com> References: <20200526080324.69828-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org compile-tested only Use dev_pm_ops structure to call generic suspend() and resume() callbacks. Drivers should avoid saving device register and/or change power states using PCI helper functions. With generic approach, all these are handled by PCI core. Signed-off-by: Vaibhav Gupta --- drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c index 7b86240ecd5f..014cee31a1d4 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c @@ -421,9 +421,9 @@ static void xgbe_pci_remove(struct pci_dev *pdev) xgbe_free_pdata(pdata); } -#ifdef CONFIG_PM -static int xgbe_pci_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused xgbe_pci_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct xgbe_prv_data *pdata = pci_get_drvdata(pdev); struct net_device *netdev = pdata->netdev; int ret = 0; @@ -438,8 +438,9 @@ static int xgbe_pci_suspend(struct pci_dev *pdev, pm_message_t state) return ret; } -static int xgbe_pci_resume(struct pci_dev *pdev) +static int __maybe_unused xgbe_pci_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct xgbe_prv_data *pdata = pci_get_drvdata(pdev); struct net_device *netdev = pdata->netdev; int ret = 0; @@ -460,7 +461,6 @@ static int xgbe_pci_resume(struct pci_dev *pdev) return ret; } -#endif /* CONFIG_PM */ static const struct xgbe_version_data xgbe_v2a = { .init_function_ptrs_phy_impl = xgbe_init_function_ptrs_phy_v2, @@ -502,15 +502,16 @@ static const struct pci_device_id xgbe_pci_table[] = { }; MODULE_DEVICE_TABLE(pci, xgbe_pci_table); +static SIMPLE_DEV_PM_OPS(xgbe_pci_pm_ops, xgbe_pci_suspend, xgbe_pci_resume); + static struct pci_driver xgbe_driver = { .name = XGBE_DRV_NAME, .id_table = xgbe_pci_table, .probe = xgbe_pci_probe, .remove = xgbe_pci_remove, -#ifdef CONFIG_PM - .suspend = xgbe_pci_suspend, - .resume = xgbe_pci_resume, -#endif + .driver = { + .pm = &xgbe_pci_pm_ops, + } }; int xgbe_pci_init(void)