Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp101421ybs; Tue, 26 May 2020 04:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUP8QAn316lnBtdzUPMcUG42suDGQItk1r16F0Q3nUxY8EVKUcT/OEY0vEeA+9mGvPcpjy X-Received: by 2002:aa7:c1c5:: with SMTP id d5mr18601622edp.183.1590493823352; Tue, 26 May 2020 04:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590493823; cv=none; d=google.com; s=arc-20160816; b=prPAibeEVkwTlNVV6SdhQF7PrKlYvbwhfwRnw/ZcjiDiRooM3Spk/dbF8arJIXNTuC Rm1o2l8UkFsjJn8FJZ5nCHFJvXAG3Fp5MjzHBEYIsa73xlgjXsLFa/IJ6LOR1YC1qJ30 B1PzZ7+n+AXZ4DcrkPfg4HQI65owsLQb3YRirHTEre/i8cwShlcRk3HOXT3g2aZWoZ0X fscfIJ70ODfeS7E95mXHQn5EmhDDSFbPNDZhQpKbl+UT6MxBxudyzAvgyI492BrR6dta exoqoLkfLFrSGoQ993c8LweOx+81Xp6YZAP4JE8ME2ehRDUUIYyc1uziCypPqIR0RxLz Kshw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ctzNEK9ct3Xheefnk+QOHIxDO7kXYLYdjrWKg/OFEKg=; b=JqxD+dj9aRT5mS1NTSFvWlI6K9h5uq8d/VQkJxyLZEkYcW8EQDViFXMtqPTtvloUTC fbAQq2jj1WSWXaJQLzym/CWSXIjtnRaUm/PJD5YVzBgtwpgSvs4y3V2CMJkVTwo/b0Co ugPgCHpkbwgisLkfwJRqaZeNlAI5fLzBr5+4BigbURKUetwl9v48QclrI1ud+e36VlFc odIPOWYQtGYlqxw7/IJB/XNKbfRRI+wvK+3hdKV1hdGN0EEx53vB7fBwEJlaLu6MQ0Dr n6le/Ia+bkAXYNWwWVykXPZvKoeMi29wONY0EbbxYAFKh8PLk5bMTkoElnsMSys6CfDg lsvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X3CG+oVN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gl22si11515393ejb.297.2020.05.26.04.49.58; Tue, 26 May 2020 04:50:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X3CG+oVN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731612AbgEZIFM (ORCPT + 99 others); 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-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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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) -- 2.26.2