Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1790898ybh; Fri, 17 Jul 2020 00:52:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+lyfnbpGkmJZAoC/GXyyQz7dRZaCFysyh4UK8swUQZOxgw9pOvuOso/giCkZeUkjpyZrU X-Received: by 2002:a17:906:1d5b:: with SMTP id o27mr7859906ejh.367.1594972345012; Fri, 17 Jul 2020 00:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594972345; cv=none; d=google.com; s=arc-20160816; b=BbgJEyCgkKwTp1SSN7GXhNJLsXT+sMuZg/PKcnt8R//ZbZpbPT4IXKKfLBKdb09P3L aHVC2UajrzIH2wdyvjsk8hqgzIFsGntJVSusZ8+NPacqyrapyoavUYxBrTpPNw192BXP DazRphoqgtx4yEJcN+jdWWS6QBurLSj7cCBdIQRtXlfBx/O6hz9bs1Ys6BZSmVnu37tb 2ozUqqd3pKXwt11aS0Svxq3qq+U5AdOW9JRwZddN7wvTadIUQ9exIpFUhJ8YZXryz4XD EvMx8KybeUZZDJBDkz+73phLWiH3c2FSsBHk96NMc7RAKNhmsnb7HN7eBoA0dBKqnFXG /h+w== 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=cWqo/1iGGhIfGKCAu2qJyy90N6APTvXdwVB6pQxCcg0=; b=LPb9uKVYd4TNBJnxpjVSPPlvr5yLjLQgljNMLdDevacuwa2mV7sZyWObhjgapJ73yW /Te5nb/1ZhLJF3I7DQYCrTtvbY7S6HdS2seHWF+LVp6tgDaMD55Pb2Z/AUtNKvR1J1M8 aWHKgeNTY1hcqbbR93ofWdsOxiGnO0EU/qnaMCxCzBgkLSgn/ZVl4Jz48MKS8oZK4M7R fRcuDY54nbpKfqypADGCscpJCEC/hdsxkP4YDFIFULMFboh78hUPyYMD5/KolndUwzr9 k//WbaMrvATqdlHhbL1K7RdZr0NRkyvY4ppALxPrXqFgtclB3VjrZ40nFx21qT11h4hj ontg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rVE0X2HT; 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 d21si4640468eja.703.2020.07.17.00.52.02; Fri, 17 Jul 2020 00:52:24 -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=rVE0X2HT; 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 S1728080AbgGQHvh (ORCPT + 99 others); Fri, 17 Jul 2020 03:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbgGQHvh (ORCPT ); Fri, 17 Jul 2020 03:51:37 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E841AC061755 for ; Fri, 17 Jul 2020 00:51:36 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id o1so5122222plk.1 for ; Fri, 17 Jul 2020 00:51:36 -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=cWqo/1iGGhIfGKCAu2qJyy90N6APTvXdwVB6pQxCcg0=; b=rVE0X2HTdehxwlgLKfFZNc2cCb/5/HluVTLh895T6EIOW9altfl3qdh4EQ+IXSzCWE XF2HTtZPy2Nu/IFQHuAfm5Wsa5gG3onbgQAc6U/PPxSQfoYQvK+BS0qFPN+OuPVWVhYh RtARknXTxz05y1CdfNR+Ymi8omU/rIxrrYZL+YKsuBWNCz2K8L3jpiMr8IOmBXomz1xs AEPz5fOnFqzQQzKSHEf5emk3lBjENVjkGaQLItuM0oV5DuVAdTM1K4CyO8r/UlLIhGYP b8QZW2JOPC0te8A9HAkdpYK03GFI1yujrC8AZ3uVebT7gAf5OGEDWVkMVgQVol5gMALR BKBQ== 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=cWqo/1iGGhIfGKCAu2qJyy90N6APTvXdwVB6pQxCcg0=; b=FFHZ/EFfsABQcHUeFDtYszCElCAfxsov8xxqViSEKuxd0RENZAzjlXwZ4ax3NUDS4u VoGTnVOJcri1wIhFnW0YoZnnMEZvBNiq7W2kT2Mt5D5rryT1kokcBaa413unI+6fwHPa C43UI6y5tbkJI0f0pw+BQTR+/tVDHxnF30qovTsY+nOoZV1kBy9DtujIMnjjB/keZghq 74hsfXp2UhAcVI9WTVxwV57aadn7k8YwiqVxWJiTI0Sj3g6OCL05I3vVQcS6wDoHsBqf yALUgpj89y3R2cDnO9dekc/Dyq8+lLTLjjDLKjaRPFqAxXsnGpRsfRknr8RXWitWs3fp mAcg== X-Gm-Message-State: AOAM532RpAfxHTuuoxPK/8Mwn6Yl87jT+jyzbo9nPUU9C1QR2uqYni4A XjqQi3EGzQFOeAqCJfVQWoYowR+S0oCc5g== X-Received: by 2002:a17:902:a389:: with SMTP id x9mr6633756pla.63.1594972296470; Fri, 17 Jul 2020 00:51:36 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id s68sm1924332pjb.38.2020.07.17.00.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 00:51:36 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , David Airlie , Arnd Bergmann , Greg Kroah-Hartman Cc: Vaibhav Gupta , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: [PATCH v1 2/3] sis-agp: use generic power management Date: Fri, 17 Jul 2020 13:19:36 +0530 Message-Id: <20200717074937.296192-3-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717074937.296192-1-vaibhavgupta40@gmail.com> References: <20200717074937.296192-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 Drivers using legacy PM have to manage PCI states and device's PM states themselves. They also need to take care of configuration registers. With improved and powerful support of generic PM, PCI Core takes care of above mentioned, device-independent, jobs. This driver makes use of PCI helper functions like pci_save/restore_state() and pci_set_power_state() to do required operations. In generic mode, they are no longer needed. Change function parameter in .resume() to "struct device*" type. Use to_pci_dev() to get "struct pci_dev*" variable. After upgrading, .suspend() became an empty-body function, hence defined as NULL. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/char/agp/sis-agp.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c index 14909fc5d767..e2e62d5a8914 100644 --- a/drivers/char/agp/sis-agp.c +++ b/drivers/char/agp/sis-agp.c @@ -217,26 +217,14 @@ static void agp_sis_remove(struct pci_dev *pdev) agp_put_bridge(bridge); } -#ifdef CONFIG_PM +#define agp_sis_suspend NULL -static int agp_sis_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused agp_sis_resume( + __attribute__((unused)) struct device *dev) { - pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - - return 0; -} - -static int agp_sis_resume(struct pci_dev *pdev) -{ - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - return sis_driver.configure(); } -#endif /* CONFIG_PM */ - static const struct pci_device_id agp_sis_pci_table[] = { { .class = (PCI_CLASS_BRIDGE_HOST << 8), @@ -419,15 +407,14 @@ static const struct pci_device_id agp_sis_pci_table[] = { MODULE_DEVICE_TABLE(pci, agp_sis_pci_table); +static SIMPLE_DEV_PM_OPS(agp_sis_pm_ops, agp_sis_suspend, agp_sis_resume); + static struct pci_driver agp_sis_pci_driver = { .name = "agpgart-sis", .id_table = agp_sis_pci_table, .probe = agp_sis_probe, .remove = agp_sis_remove, -#ifdef CONFIG_PM - .suspend = agp_sis_suspend, - .resume = agp_sis_resume, -#endif + .driver.pm = &agp_sis_pm_ops, }; static int __init agp_sis_init(void) -- 2.27.0