Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp784534ybt; Wed, 1 Jul 2020 09:54:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnDNJW7shnWp+O+vhNpTosHo77pezXA2lebsNP0z1D2js6leC6APsDr+JoI7TD4VnOo+uu X-Received: by 2002:aa7:c887:: with SMTP id p7mr15934477eds.240.1593622477229; Wed, 01 Jul 2020 09:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593622477; cv=none; d=google.com; s=arc-20160816; b=c9m6F38ctCBTtMS9j4FUXhqIWstCSqGyCBeyQq9XnmvFPVGZ+7fpbvf35XtJD0xDj1 JiePT0lzHAOIXcUKjWBIeETZ+MSbdMTev51VkPcE17eFpO7cAJVobnXdT1fzgPgFmyFA nXI7x3XVazjFNbFaXX1JGPgis5oQdS1LSwJTcSChz92RVQZDmD+HpQ/ALkvsFrrERQDT TitmsIQaNLumTwaeeA9j+YtM/4K5l1tR5Iay3KkEpEr2MKbYxM+qD0zcf0L7RBn6xjaV QzAFwfzQrqAOfgSS4EB3PwEIShpFks+wXYc7vS5YxMb+NTQe4MM2rjiVlHmh55aKmDch gWwg== 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=GxBM9njwc9t+8wZt245O1720nVEKK0kOwVAxz9sX+f4=; b=zS/e0XUVNjl059UF2k2m3q653EXV9fNTK0mRHLgosXEYR7aCdZjWEp6Pxr3KxxWneO pcuOgh5pGRCTg4f5uq9ihX0Hyi/ytLXTaML0PFqMxcrDqOE7rKnVvQ2UDU558FOtiM90 LI9liZc2h6JWyoh94ntEufFDV2KKpeNTngxuqEHhxYlNuUzwHjnR3H1Syyww5ERIzeOZ Q8DMiP1oXtU8VQU5tf7tNNJoom7CpZHQ7EQC/awwookgch7KMbEwLL45a5WBEG+BHD9G Sfx4GBPb9+i1sniNnxPuUPPHVxF++zDpN6zyt9Gpue1MXAM2JRi/H/pGGUHgQ5M9C7JK FBaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jmZd7hGk; 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 r5si4214741edo.130.2020.07.01.09.54.13; Wed, 01 Jul 2020 09:54:37 -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=jmZd7hGk; 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 S1732695AbgGAQxV (ORCPT + 99 others); Wed, 1 Jul 2020 12:53:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732367AbgGAQxU (ORCPT ); Wed, 1 Jul 2020 12:53:20 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D81CC08C5C1; Wed, 1 Jul 2020 09:53:20 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id 35so10153293ple.0; Wed, 01 Jul 2020 09:53:20 -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=GxBM9njwc9t+8wZt245O1720nVEKK0kOwVAxz9sX+f4=; b=jmZd7hGknXKUy0a9GgdamQ46AbPd9jgv/R4OLxdEvG2N9rYfAbv/LvSgjMRsE2ZZLC 51x+9iissrj7FkAh0f72pBvGkeCN3iHyX3EcGI7nbMc04q5yPpUKBqQEwL1H/qFH7lTq pBDshRklIkIp8b1Yojxyk4q1RFF81nN8nDutxL9FFR24k37bih8I8gHD1iMjPJNqHVw8 B8GWBc6fZzh45dtkLLCskwK5VgtubeOeqU8vXdvPbTW64nsUR4AIwwYy17CpdG5xBBrL cflibanG1EDbJ+D4Msj+L86U2toNBqxQuuAilkl8Yyp1aVez68/grwrhAPGfZpNYH+RS bAIQ== 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=GxBM9njwc9t+8wZt245O1720nVEKK0kOwVAxz9sX+f4=; b=ATJR8P/ILdVyUJjsjBMnUzMzvziv7HVbCXsWLF+HK18SFhCmpxXhqsDCh6UgHzZgoh PW073HnMrAnxad3eu7UGVPzwx1XFQfthF4ZbX/XeGPjO4wBL3dQv0QiDbayhjqafDNqB jGK/k/B++JGRvNiGpDfI4y+fTqBQXIEkSo72UaiZiuS+Sk0W1t5pU9oRDNIY4dWjd9+y 5IzH2tyxrIp8kJJkziZqkNC4i1KsYmXu7LSmFYMeNvl23JJ14maIg5dcgB0Zou5PDfZW BdHvhYtUPeFS4dNh741bw6JejCPG3hSG/9Cl1SbEcMRGF/IrtCjVfmwu3+16GcTTE7YV GK8Q== X-Gm-Message-State: AOAM53057oq9Ubvko+HJB66MR5pbz9Dy3CCHjY/UrTNQ4gYaTEPOpWEf T2+4zl3fMV7hmYHBNAe0xvA= X-Received: by 2002:a17:902:8342:: with SMTP id z2mr23077337pln.300.1593622400123; Wed, 01 Jul 2020 09:53:20 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.57]) by smtp.gmail.com with ESMTPSA id g140sm6297437pfb.48.2020.07.01.09.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 09:53:19 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , "David S. Miller" , Jakub Kicinski , David Dillow , Ion Badulescu , Netanel Belgazal , Arthur Kiyanovski , Guy Tzalik , Saeed Bishara , Zorik Machulsky , Derek Chickles , Satanand Burla , Felix Manlunas , Denis Kirjanov , Ajit Khaparde , Sriharsha Basavapatna , Somnath Kotur , Tariq Toukan , Jon Mason Cc: Vaibhav Gupta , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org Subject: [PATCH v2 06/11] sundance: use generic power management Date: Wed, 1 Jul 2020 22:20:52 +0530 Message-Id: <20200701165057.667799-7-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200701165057.667799-1-vaibhavgupta40@gmail.com> References: <20200701165057.667799-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 With legacy PM, drivers themselves were responsible for managing the device's power states and takes care of register states. After upgrading to the generic structure, PCI core will take care of required tasks and drivers should do only device-specific operations. Thus, there is no need to call the PCI helper functions like pci_enable/disable_device(), pci_save/restore_sate() and pci_set_power_state(). Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/net/ethernet/dlink/sundance.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c index dc566fcc3ba9..ca97e321082d 100644 --- a/drivers/net/ethernet/dlink/sundance.c +++ b/drivers/net/ethernet/dlink/sundance.c @@ -1928,11 +1928,9 @@ static void sundance_remove1(struct pci_dev *pdev) } } -#ifdef CONFIG_PM - -static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state) +static int __maybe_unused sundance_suspend(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pci_dev); + struct net_device *dev = dev_get_drvdata(dev_d); struct netdev_private *np = netdev_priv(dev); void __iomem *ioaddr = np->base; @@ -1942,30 +1940,24 @@ static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state) netdev_close(dev); netif_device_detach(dev); - pci_save_state(pci_dev); if (np->wol_enabled) { iowrite8(AcceptBroadcast | AcceptMyPhys, ioaddr + RxMode); iowrite16(RxEnable, ioaddr + MACCtrl1); } - pci_enable_wake(pci_dev, pci_choose_state(pci_dev, state), - np->wol_enabled); - pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); + + device_set_wakeup_enable(dev_d, np->wol_enabled); return 0; } -static int sundance_resume(struct pci_dev *pci_dev) +static int __maybe_unused sundance_resume(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pci_dev); + struct net_device *dev = dev_get_drvdata(dev_d); int err = 0; 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_D0, 0); - err = netdev_open(dev); if (err) { printk(KERN_ERR "%s: Can't resume interface!\n", @@ -1979,17 +1971,14 @@ static int sundance_resume(struct pci_dev *pci_dev) return err; } -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(sundance_pm_ops, sundance_suspend, sundance_resume); static struct pci_driver sundance_driver = { .name = DRV_NAME, .id_table = sundance_pci_tbl, .probe = sundance_probe1, .remove = sundance_remove1, -#ifdef CONFIG_PM - .suspend = sundance_suspend, - .resume = sundance_resume, -#endif /* CONFIG_PM */ + .driver.pm = &sundance_pm_ops, }; static int __init sundance_init(void) -- 2.27.0