Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp602371ybt; Wed, 1 Jul 2020 06:04:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYih2AHFBg0NL3BZbFFhVbOLbq/fK2u8H1FKSlGON5r27ZJMF5YXvbBSDLS60Or0B5lkeS X-Received: by 2002:a17:906:57da:: with SMTP id u26mr23584067ejr.157.1593608661198; Wed, 01 Jul 2020 06:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593608661; cv=none; d=google.com; s=arc-20160816; b=L1SdGD7w0WEFhTi0j398jvZierjWo5BUFFGAEO9D6GJdB4YIsF8Lo2pLS0sUWSw0YU csTIqLmiIK4vE1QHyAWFsmE4liqhCwu5aRzfVFHFB7OBV9I+//t2K3Lbt8pm3O26ecNM gkU0BmrFyxiXlnBz0PgeeJ6l/4TaGoQurDdAv8qB31sriAYE9h8YTqrykc4WvK1Ohe2V wfbrvc6rXSA8uLoHXIPrbWxH8m0VMwYfLSji66ClTQlvMhz6WE8kySJayppC6dgT7Rt3 XYE2L+Nu6Z0W3QKZZQ6TaItSeSXJrl9CcREO9qcCFghCF/6ALnEQbSuwLA+xrJNInP5l 0Eig== 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=gjuP9C77QQBWW18VBdGkv5RF4KEPAm5bxR9TEKk/tdTwA8ddGCwEQvZw9kjtGO3z7U pThM4Lbxom+NFADqkIgOiSRJA6EhhxSKULlMOZUq8YZLCI/FqBYY6T5nqq/pSu9EeIjb iLvqfPl8moE1h+MdakN+HoiQV+HKXucj19J41n1AbWqoB0D/hr7radfE5+QojDxh9dfD 2AbAF7hJApyAERVjkenoPrRBtPBDSPO+qc4glGB86NgqEssWeUNh7QS8HsgT6yB4fMU7 /ruqmqhnXH9FFkn79AG7bmf+d79hlkXSg3CJxfmfWKo4dwvecWSgkEMt5/RPB6KOlDMU w8yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E8x39Fr5; 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 a12si3869088edr.496.2020.07.01.06.03.57; Wed, 01 Jul 2020 06:04:21 -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=E8x39Fr5; 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 S1730929AbgGANCy (ORCPT + 99 others); Wed, 1 Jul 2020 09:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730744AbgGANCt (ORCPT ); Wed, 1 Jul 2020 09:02:49 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 868C2C03E979; Wed, 1 Jul 2020 06:02:49 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p3so11689039pgh.3; Wed, 01 Jul 2020 06:02:49 -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=E8x39Fr5eOXD+lvhdVdIYJZUjHwCPfPjh9s8afGYaGwdfF9LGGiDosxKMlHtPSdlai 4vICc1ddM3/RDbNvPeFDuR2Es5u/ozrZDvV/CrIi2DtIhwBOXhh0UWqBAIEj7+7fQO/T ToUp2cU7mZnlbR1wbQ7ZTMsY7YmqJRVYAC7Ww0nYwaC6cl4Yxwbvr8Kos4OAEORmTzTO GEd4KzeTKDom0SdZU0VMQsB7UsP3Gr2NgUhrWJmDNuseXtHDC6cDKLmtx5/d24SCpIsF E7ohljt1W4EGTgxzVW0YhExDcfKEq0/Qr0gFL981Ft1ytvn70HOU+W6O02gxfrL2tMUO e8gA== 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=QsT9dB4MelUPksEBTACjne4zUCXn10lxZu45LVigAAYwMyxsVgFD6VqSOq6XfXIcz0 SXrpHaTI0UN4dMEI9e7Mj0CGz26XQncmggsFrSzNvZDnz0wBmnpLOI8O6DfDzS3wjzD4 +B+a/hReRg3Jv6vvEsCTKFkleomPokVf5c7ZTjHxZjozCLR1F5iZnagVibBrc24DMgEj fHWgc2HY+wsCeU2C0X3LerCq34rH/ZcdMnEVgeaZATLxK7mCzx0vGiAO1iLWNT5Tq0e1 Y435Ox3okW16ZL15z1JRUliAD/vCqb+BAQlyIv/8aEC6ESFyA7URSuj2US41oMDuDoxm dUkg== X-Gm-Message-State: AOAM531kxYBgt39k5FTyPTHJWIej3Doti6fP8qjfjQVqpJceGM9xHNHO UzJHiCr/gOsipdEFwuEhRWI= X-Received: by 2002:aa7:8f08:: with SMTP id x8mr8291854pfr.41.1593608568921; Wed, 01 Jul 2020 06:02:48 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.57]) by smtp.gmail.com with ESMTPSA id d9sm6070908pgv.45.2020.07.01.06.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 06:02:48 -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 v1 06/11] sundance: use generic power management Date: Wed, 1 Jul 2020 18:29:33 +0530 Message-Id: <20200701125938.639447-7-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200701125938.639447-1-vaibhavgupta40@gmail.com> References: <20200701125938.639447-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