Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp700083ybh; Tue, 21 Jul 2020 06:00:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYt1ZeEyYj6VR4AbvgN3qwJwv7YL1k9hveMn6+2vdMkI8tKXSFIDNv+hSz0o2AFv/CVMgZ X-Received: by 2002:a50:82c1:: with SMTP id 59mr12382175edg.295.1595336453950; Tue, 21 Jul 2020 06:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595336453; cv=none; d=google.com; s=arc-20160816; b=q42t6TpfFi/oZMp2uhQJzz4qRK14cTSPHnDHYkKeBnVR/Kh/oHr3tn8Rpiu0RzaWS7 nHSdZbkpW0n5ltWOk5geoAbLvJlDIo84Z8wdm9yYp4+AY+1YmMp2K7tDbfj57UYBtkiT cabsGf2018sutESX6Oddl1k+U4ScF6ix0p4PsfJt1Xw8FvK9NSxqY4gSrIlbyEVjktry JU6pHH2hn3JkUIn+2iVQNEy9ZPd4GUfnQMpUkFdUMPlRxr6DKKQU00996GEos0N3BrDA Qh3HH5q2uHzodce75ZBYLrsu4ClHJV6mq43poHdsppbheNQwIrAnkgifoehipDaSZwza 0hmg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=t2vMm5MN6COcLP/AC1bsbI/E+zsl4wCZerr7TM2M9Bk=; b=JjqEZpZ1BVATxPJpLa/R/G0MvLdnV/Xx/ahKFt3y3v+f18mjHjGOiiI1g/piTnUOwl 7AEK0ygUFQyrsNOiu9TbPFMh4eGCbnDYJc8FHYfh4Q6Z6qQkRZgJNs7ogqlAQDuzJk/3 Zo+0vhMuP7mGYVpuxJoRJ00wdhN+NUcFvk14jB3PpTvHyADWb8eWjInhaov3OfPtptTr DKw1e0R0qhmUYXWvsXqgnDe2Q2oFfI+NrvRu/D7jLmxg2NXCiV3jU0Wr06507h+kgFHo QyXBXcceX2+UesjVirww86IPO0HrU9Tu0Urqj0Z1o7e/cNL0Gb2fhXLeAVoNEnBpaN2D iovg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fr3YLS21; 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 u12si11804292eja.373.2020.07.21.06.00.30; Tue, 21 Jul 2020 06:00:53 -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=fr3YLS21; 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 S1728037AbgGUM6M (ORCPT + 99 others); Tue, 21 Jul 2020 08:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbgGUM6J (ORCPT ); Tue, 21 Jul 2020 08:58:09 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE348C061794; Tue, 21 Jul 2020 05:58:08 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id b92so1628581pjc.4; Tue, 21 Jul 2020 05:58:08 -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:mime-version :content-transfer-encoding; bh=t2vMm5MN6COcLP/AC1bsbI/E+zsl4wCZerr7TM2M9Bk=; b=fr3YLS211Gmt5YGjeWiE/LFiFj6YG+zPEieeHXqHXdyDwVPBswzW476JH2GbekCA0R 33FjkoOaQp4eovrKc6t8q+SNSOXcarYBhQ2s4pjcBtcik7wavPC4bKVpTa1d7hfAG63z tFn1Di3tXn1b4rJAGi6IhgCWb7RdDqAx6fGIeprwlcmTYkNlf0g1MsbZJ94oM1tXPGxW Mx0WjzPy7O3iDsciWz+y6G2c+hKVMpa/8+9EjujtbBqjbZdMcXjNNlHcyZTxQAO0pmOd 0fghdSwtQzENvCQbBGW24iwpi4E5dQXaDbWla4QR6q8S5dAgw6WfMdetdCfIEF7vfICF Q3sA== 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:mime-version :content-transfer-encoding; bh=t2vMm5MN6COcLP/AC1bsbI/E+zsl4wCZerr7TM2M9Bk=; b=Uk3suFTfoLe4PpfuNuMzyOivoSsNgWdQx82eU8pzgLEXSXJLoqhU+JWuLECPl6ZLMK njbT1ujsr72rEt1y9BZiysSzy/evIIXCDzJHyMzO8l4qDptcRzGQBuYj4iJqQ2EJyrQQ J/1+yJW0ADKqbfRlybR4lHs/7SNQom4qVw2HXCs+L1KDhxDps4XvMmZaEGmwb81pbSh2 Cq05nXjYEMznNGK0+pHXjtfmZokeJt87thFGhIytEEeAKdGZFjdMPRYsLm9uwOASLblD exsnTryEmfSDbmFazkNTfdrYIO1jmSUdK1TMlK3cJ1DOPIJlbtES0iSswUKM4jWH6mfZ aBGA== X-Gm-Message-State: AOAM532/GmABetcIMKPP5T9vQ4DjGlpYO8rhbIZNjTkZhvGS7PqjcQzL knj/D47NLcdVcHvs/EIp4hI= X-Received: by 2002:a17:90b:3901:: with SMTP id ob1mr4531304pjb.168.1595336288282; Tue, 21 Jul 2020 05:58:08 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id a2sm20573833pfg.120.2020.07.21.05.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 05:58:07 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , "David S. Miller" , Jakub Kicinski , Luis Chamberlain , Kalle Valo Cc: Vaibhav Gupta , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan , netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH v1] prism54: islpci_hotplug: use generic power management Date: Tue, 21 Jul 2020 18:25:15 +0530 Message-Id: <20200721125514.145607-1-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 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 Drivers using legacy power management .suspen()/.resume() callbacks have to manage PCI states and device's PM states themselves. They also need to take care of standard configuration registers. Switch to generic power management framework using a single "struct dev_pm_ops" variable to take the unnecessary load from the driver. This also avoids the need for the driver to directly call most of the PCI helper functions and device power state control functions as through the generic framework, PCI Core takes care of the necessary operations, and drivers are required to do only device-specific jobs. Signed-off-by: Vaibhav Gupta --- .../intersil/prism54/islpci_hotplug.c | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/intersil/prism54/islpci_hotplug.c b/drivers/net/wireless/intersil/prism54/islpci_hotplug.c index 20291c0d962d..e8369befe100 100644 --- a/drivers/net/wireless/intersil/prism54/islpci_hotplug.c +++ b/drivers/net/wireless/intersil/prism54/islpci_hotplug.c @@ -63,16 +63,17 @@ MODULE_DEVICE_TABLE(pci, prism54_id_tbl); static int prism54_probe(struct pci_dev *, const struct pci_device_id *); static void prism54_remove(struct pci_dev *); -static int prism54_suspend(struct pci_dev *, pm_message_t state); -static int prism54_resume(struct pci_dev *); +static int __maybe_unused prism54_suspend(struct device *); +static int __maybe_unused prism54_resume(struct device *); + +static SIMPLE_DEV_PM_OPS(prism54_pm_ops, prism54_suspend, prism54_resume); static struct pci_driver prism54_driver = { .name = DRV_NAME, .id_table = prism54_id_tbl, .probe = prism54_probe, .remove = prism54_remove, - .suspend = prism54_suspend, - .resume = prism54_resume, + .driver.pm = &prism54_pm_ops, }; /****************************************************************************** @@ -243,16 +244,13 @@ prism54_remove(struct pci_dev *pdev) pci_disable_device(pdev); } -static int -prism54_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused +prism54_suspend(struct device *dev) { - struct net_device *ndev = pci_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; BUG_ON(!priv); - - pci_save_state(pdev); - /* tell the device not to trigger interrupts for now... */ isl38xx_disable_interrupts(priv->device_base); @@ -266,26 +264,16 @@ prism54_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } -static int -prism54_resume(struct pci_dev *pdev) +static int __maybe_unused +prism54_resume(struct device *dev) { - struct net_device *ndev = pci_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; - int err; BUG_ON(!priv); printk(KERN_NOTICE "%s: got resume request\n", ndev->name); - err = pci_enable_device(pdev); - if (err) { - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", - ndev->name); - return err; - } - - pci_restore_state(pdev); - /* alright let's go into the PREBOOT state */ islpci_reset(priv, 1); -- 2.27.0