Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2689511ybt; Mon, 22 Jun 2020 04:48:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2PTGzgtutUjoYKNeX/PThLOg8+Dbs3nTAt8kdH3bjWms0yje8J5OYbIpS3uQXPT+cLd/1 X-Received: by 2002:a17:906:4dcc:: with SMTP id f12mr2684570ejw.401.1592826521784; Mon, 22 Jun 2020 04:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592826521; cv=none; d=google.com; s=arc-20160816; b=vCAdoLHOAXVxqZ2cirz4Q0pNABrw4f8Z56v99bfI3lYmOw2sVqwuseMepW37T1l746 dTTnhitm/oCmoVGvWDT//nZwTAF8cIomjVSwNIVCYe4q1ZaiFky1E+dqKE9/2rS7S3Hl 6vkzZe00mscMNnD6YS8myhmfZh0pbqkdP6CgXt4qen/2kjcd+jQrkyX01Vu2k+HR5Ee6 TFcFbb6wg+U1OHxCRM7DoCWCafDiKrNZL7xt8dXvTmKoX+qgDSHKiRPlWqg+8TpCNSAe bJqeIfBmLf3f4o6rx82PqyraBYRZnnY7/7kX51vpbfxu0EjvYj2SDo8dHbHyQUpx+bj8 ZZfg== 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=BPbjKYMHm32Cbq8mcRL1k19s011F/vdrw1Z/1h/BoFI=; b=jhdLlZLDkHN5bmJ0JiTsFEa5dVzjGu3VuglkLSkzx+8lY77eB+p54C4xf09cX3QDzJ yfr3t8dvrd0GF6wKv4c9m40aRSp92pqsUnnvvScWODVf65VkpQAqxYTPSxDMi5Haq4St Tv/yqdhlVRS3ScxvGL5WabXhsmTF8WO/mZLToNOJmwSKUPTl/qz9o9YuH0oPcwwCN4NC OKUddcedtOiyM5imkYwUTF/tjpC9PhOHIWafnGpuIwswXsGFotXVdCLzdUj0XE2dnDxP 0ke2SVUj1EY1d5DDtKk418HYBL2YQAJaK/d8gTdJjmkCWX3bLK+ipa16dbExsfdILSvn l1qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W9WgbAOK; 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 gj24si923026ejb.139.2020.06.22.04.48.19; Mon, 22 Jun 2020 04:48:41 -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=W9WgbAOK; 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 S1728048AbgFVLo1 (ORCPT + 99 others); Mon, 22 Jun 2020 07:44:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727806AbgFVLoX (ORCPT ); Mon, 22 Jun 2020 07:44:23 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C095AC061794; Mon, 22 Jun 2020 04:44:21 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id b7so6565509pju.0; Mon, 22 Jun 2020 04:44:21 -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=BPbjKYMHm32Cbq8mcRL1k19s011F/vdrw1Z/1h/BoFI=; b=W9WgbAOKoQ9vJ+KfjZt44yCSuN6FjFvqzAiNjUlfhV7txGEG3vtw3b3rD86ksCnkrx G/Oz1KBaCQbtLY9yPTT4aT1aQx4Qk+27aKmrCxjltwg6tWVd/PxOhEGaorD0XbV4+3y5 T+pLGjjW5tjiRifgebT9pvqspqhMPNh1zTSKJVzQO1t3ADjp8Jvnc4TbyW9YZg8ePr2/ 6I6Foa55k4QvKyvch1mjgcR/ppgH1DBjV2iCXCMyXEUBVX96CpT6XrBsczUeTvJJkkiP RWytvzzjbTMt30hkiIDbfuFPRixxftMVR1Wg8pS7rcTdsfmk8iEIgKlMmwpDjP2BKstB GaIw== 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=BPbjKYMHm32Cbq8mcRL1k19s011F/vdrw1Z/1h/BoFI=; b=ZUbxUlJx6fnOIMWjGrH7fHU7SpFL0PSaR2NHPGqeVs/ZkV1qWFRRdG+Yui9WWTddvw qCU5fHWQdIm1cid5SRZAnEY9U2Bfdqtfd84vsV2FwIx6hp14gWiEg95sOk3FpgwOyhBx vRWPYz0qm8gPNrbmGMZbllSHwdg0KuQnogytC/3tK5Xa0K40jMtIjOF8vKUA+VVF13dq ZiztpBQATJNcC4Y8oNK2g7Fl/LSM3e9GcEz0g8Dgn0QTD90WlbIWTewD9ucRLAyRzsGX YV+Al3fgRoZYELfSndVC6d4uOm7gYlXolGLo40c8YDeA2B7YMm+kuO40eFc+oC1/izT0 RsoQ== X-Gm-Message-State: AOAM532dS0bJVFJrIvVgo+blRFmg2ATZ4sWyFwblNjLeXK23qx7heLZ8 8+gDBns4mPBJqMCt5ODz1yk= X-Received: by 2002:a17:902:3:: with SMTP id 3mr17681289pla.120.1592826261334; Mon, 22 Jun 2020 04:44:21 -0700 (PDT) Received: from varodek.localdomain ([2401:4900:b8b:123e:d7ae:5602:b3d:9c0]) by smtp.gmail.com with ESMTPSA id j17sm14081032pjy.22.2020.06.22.04.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 04:44:20 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, "David S. Miller" , Jakub Kicinski , Vaibhav Gupta Cc: Vaibhav Gupta , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, netdev@vger.kernel.org, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] tulip: de2104x: use generic power management Date: Mon, 22 Jun 2020 17:12:26 +0530 Message-Id: <20200622114228.60027-4-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200622114228.60027-1-vaibhavgupta40@gmail.com> References: <20200622114228.60027-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 the support of generic PM callbacks, drivers no longer need to use legacy .suspend() and .resume() in which they had to maintain PCI states changes and device's power state themselves. Earlier, .suspend() and .resume() were invoking pci_disable_device() and pci_enable_device() respectively to manage the device's power state. With generic PM, it is no longer needed. The driver is expected to just implement driver-specific operations and leave power transitions to PCI core. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/net/ethernet/dec/tulip/de2104x.c | 25 ++++++++---------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c index 592454f444ce..cb116b530f5e 100644 --- a/drivers/net/ethernet/dec/tulip/de2104x.c +++ b/drivers/net/ethernet/dec/tulip/de2104x.c @@ -2105,11 +2105,10 @@ static void de_remove_one(struct pci_dev *pdev) free_netdev(dev); } -#ifdef CONFIG_PM - -static int de_suspend (struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused de_suspend(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata (pdev); + struct pci_dev *pdev = to_pci_dev(dev_d); + struct net_device *dev = pci_get_drvdata(pdev); struct de_private *de = netdev_priv(dev); rtnl_lock(); @@ -2136,7 +2135,6 @@ static int de_suspend (struct pci_dev *pdev, pm_message_t state) de_clean_rings(de); de_adapter_sleep(de); - pci_disable_device(pdev); } else { netif_device_detach(dev); } @@ -2144,21 +2142,17 @@ static int de_suspend (struct pci_dev *pdev, pm_message_t state) return 0; } -static int de_resume (struct pci_dev *pdev) +static int __maybe_unused de_resume(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata (pdev); + struct pci_dev *pdev = to_pci_dev(dev_d); + struct net_device *dev = pci_get_drvdata(pdev); struct de_private *de = netdev_priv(dev); - int retval = 0; rtnl_lock(); if (netif_device_present(dev)) goto out; if (!netif_running(dev)) goto out_attach; - if ((retval = pci_enable_device(pdev))) { - netdev_err(dev, "pci_enable_device failed in resume\n"); - goto out; - } pci_set_master(pdev); de_init_rings(de); de_init_hw(de); @@ -2169,17 +2163,14 @@ static int de_resume (struct pci_dev *pdev) return 0; } -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(de_pm_ops, de_suspend, de_resume); static struct pci_driver de_driver = { .name = DRV_NAME, .id_table = de_pci_tbl, .probe = de_init_one, .remove = de_remove_one, -#ifdef CONFIG_PM - .suspend = de_suspend, - .resume = de_resume, -#endif + .driver.pm = &de_pm_ops, }; static int __init de_init (void) -- 2.27.0