Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1790929ybh; Fri, 17 Jul 2020 00:52:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmhbElFqB11QE69zk8kbSxdGIzsjSV1Gxt8QuKXSfJXD3uo/9ugFML+cWe5bGre3Ttx3Mg X-Received: by 2002:a17:906:f2c1:: with SMTP id gz1mr7662245ejb.88.1594972351432; Fri, 17 Jul 2020 00:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594972351; cv=none; d=google.com; s=arc-20160816; b=iqnbn5ufy1kj/2PhxdsksDqqz1jF4kf31FWAitTIU9Sys7Hp0ueurV/y+8Ll7aU6IV OTcEQ8z0Iw93BH2tTUdHykR+geRX8P7YaZ1ssiwNKaLxJdtKLSbO31v2VUWouvFWE3iY xG7AlWXxWE2TPhG9G+/jWtvA79EHBaOfDQ5TnUz2fZWtuOMahPstZYfqDaNveojYCzxR 6oMmxZQfMm+2OL7NBJxCZOU7HIsKbxP7vsBxgapjcyemgFpGjjose3T5yIPAUnZ5qK9w 2IEkUcmgRE1/wOxhkW23EC3AtkiUnnEPhgrs69xbug6aWQrhyiiFtRoLCCz5+6eyKKj3 O4mg== 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=zNW9uGCCyuNVj0zzY42fxPcN6t0OrV/LrjNayMGPkQU=; b=B8tvDTuqK0neJwVe4nKcpaFFc2m9nClkpjgN1aoKt7/Wwxs3twcZITAUPt86UiPm98 P8XhnLtwJRboFR/RgMmSwss6g4agGYZHj4NcH/k4I+yO7y2wMTDqnD1rh9W7SCiCc5sH DIRHD/exrT6GSNiBDgUuYg5VNMn7QHyrC5IFPfqkWC47o/HorGhyv/k1AAZNodVoksbJ KbO3PxDkhiHCgEkyZyBJcwRq6y7fu2W3Y47mt/BctCPV5nB3c76ug2lClCBzfzmMTpCz +CzyJS0krFCLuzNMugTVcyH/vYmLDEDcsm4kKuF6Podd+TXQ5CHeI60ei1DLF3GcBeRW azug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VzTODCjH; 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 u8si5016105ejx.92.2020.07.17.00.52.09; Fri, 17 Jul 2020 00:52:31 -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=VzTODCjH; 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 S1728210AbgGQHvp (ORCPT + 99 others); Fri, 17 Jul 2020 03:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728050AbgGQHvo (ORCPT ); Fri, 17 Jul 2020 03:51:44 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A520C061755 for ; Fri, 17 Jul 2020 00:51:44 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id x9so5120751plr.2 for ; Fri, 17 Jul 2020 00:51:44 -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=zNW9uGCCyuNVj0zzY42fxPcN6t0OrV/LrjNayMGPkQU=; b=VzTODCjH9JpZgBV2q+hOkDevdJ48kMuEhf5B5qyChStHn1ij1kJSK8BljZ+qDpoUkg yseIQ2cKFjHldhbr1a1xNxv8qm+ptqRBM+5M8oDrgls6NrRhnOIlRJ61cggS8/9e+Osg ndn4P+pguRaQCq6yzwISTb5S4n4xZnrSnZvPmseRt9vnoepDxQf/pjX4f/jG3i9pNgb/ 7Fm2LcV3R4xKnZ+bKXS0eLoolghiY+XtGVgUH7IoNuM7sdRjOcpXkvE84av/NPfKF8qW U8gMr5jhvOlOqhrOYQ0dyj37V2cSZqulhfQ4FOTW+g4hFoRcOgO62bcERyygoJsZ+xmp LQqg== 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=zNW9uGCCyuNVj0zzY42fxPcN6t0OrV/LrjNayMGPkQU=; b=S22ovbVc4uqPpSyjdrySdLrw5NbTlTGOyQJvfjbIsOIecp8Enc2n9fc/euIysu2yqA Vt5akG8YJHQTPKgfbpCziIq5DTDb7I2Rk799pmM5b/qdNHtB4/k78Shw5l/JihcNhT1T x+CNfiuWKlTD34RyHZIGGyNphqieiun3uxW4cfbjpooRth0xcoOphvn+Wh3wTavwO9n8 ENloRdpNVMgV6oN5HTGfWg+iHe/YFw8eWAXMdZfw3SeFTBS5DGyJBppG1mj9RMu7riRf 5ByGxbOdKQWBoX3etLEglRU+ofPA+FpGDshZy8OnL9RviSRfBr+RTbiwCWlK7bzlSQZR QZTg== X-Gm-Message-State: AOAM532TnnU2tC5Ma3z5fXeVvlqfT0qy4h+SPxaXcu8k13IPgjYsgmu6 uV8L8XXNE9njp+TDACCFLPI= X-Received: by 2002:a17:902:10e:: with SMTP id 14mr6368688plb.297.1594972303853; Fri, 17 Jul 2020 00:51:43 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 00:51:43 -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 3/3] via-agp: use generic power management Date: Fri, 17 Jul 2020 13:19:37 +0530 Message-Id: <20200717074937.296192-4-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/via-agp.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c index 87a92a044570..afa941df7d44 100644 --- a/drivers/char/agp/via-agp.c +++ b/drivers/char/agp/via-agp.c @@ -492,22 +492,11 @@ static void agp_via_remove(struct pci_dev *pdev) agp_put_bridge(bridge); } -#ifdef CONFIG_PM +#define agp_via_suspend NULL -static int agp_via_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused agp_via_resume(struct device *dev) { - pci_save_state (pdev); - pci_set_power_state (pdev, PCI_D3hot); - - return 0; -} - -static int agp_via_resume(struct pci_dev *pdev) -{ - struct agp_bridge_data *bridge = pci_get_drvdata(pdev); - - pci_set_power_state (pdev, PCI_D0); - pci_restore_state(pdev); + struct agp_bridge_data *bridge = dev_get_drvdata(dev); if (bridge->driver == &via_agp3_driver) return via_configure_agp3(); @@ -517,8 +506,6 @@ static int agp_via_resume(struct pci_dev *pdev) return 0; } -#endif /* CONFIG_PM */ - /* must be the same order as name table above */ static const struct pci_device_id agp_via_pci_table[] = { #define ID(x) \ @@ -567,16 +554,14 @@ static const struct pci_device_id agp_via_pci_table[] = { MODULE_DEVICE_TABLE(pci, agp_via_pci_table); +static SIMPLE_DEV_PM_OPS(agp_via_pm_ops, agp_via_suspend, agp_via_resume); static struct pci_driver agp_via_pci_driver = { .name = "agpgart-via", .id_table = agp_via_pci_table, .probe = agp_via_probe, .remove = agp_via_remove, -#ifdef CONFIG_PM - .suspend = agp_via_suspend, - .resume = agp_via_resume, -#endif + .driver.pm = &agp_via_pm_ops, }; -- 2.27.0