Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp733502pxa; Wed, 5 Aug 2020 11:23:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwiKV546BKqNS7HE/GnJGa/XX7obJGJgA7r/nhNHQ/SdgikS0mRiLZZX5s//rtH8ix4m44 X-Received: by 2002:a17:906:a204:: with SMTP id r4mr541049ejy.552.1596651836581; Wed, 05 Aug 2020 11:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596651836; cv=none; d=google.com; s=arc-20160816; b=fBahYiemg8TVjSLJqGSToS11eMt0i8dvvxO65nZNfFdxwnXzqFxUO2IjwlDfy5T0es vcFgAxPB2U4jOxWWxmJ8lcoIRjFWX/oa/zIthR++5OuEQQ6L3cYZPO1eE5yrfMvCEzrX 8XEEnuLc7FAHLk5iTwhIBGj9KrUcpLCTSvNYnGN/mctCx+nYnESCTeH8BnxMeGzWiEkR dpfDFI55EYR12gWjwj2kyqCgMOAL2mrPMsskKIUs/RVmTkNXoqPQgXciQ/ZoOoE7F/V0 frQvF9AnhzIq61hgyeivh2bOhI9Z94aSHR0Jk/VrzDV8Lmxv/DbujI93uXWGgdWdlSH+ gA6w== 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=oVv4Wzhn3JTwGtZviwAnr4HC2ws5LBgl7lYKjJuNKZY=; b=YmykysT22wgNHtdpp6BX9rSb8cYN+EiNsABXE7pjxZibC3UUCaXoWvzmyZXKWnhpJ9 umiVAY4GVDFRT+XRJ/2HRxXp1fl0/N3g98Yea17NeZtPeguI2W7TmmVFD+cCKlNagHdg w1V0UYOMRcFtaaSmuWZrbHS3pVhvksyk93vFLg+U8Bt8ojJfmXOBnydWbnz6dA7ho6XS ngzTTc/KgVhUVccuxMgw97kNumQQFd+ERYOHz5X1bg1SMOS6b5sNLJDFOAe1UCslW0mO bUeqJmW5NXUvGq12tgJ2K3uHfP6vv9vRh6127Jfmlo3dRDCbORt3SOhkmD94huXZ57Ir IXbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BrpYJEVk; 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 e19si1763612ejq.306.2020.08.05.11.23.32; Wed, 05 Aug 2020 11:23:56 -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=BrpYJEVk; 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 S1728918AbgHESW4 (ORCPT + 99 others); Wed, 5 Aug 2020 14:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729079AbgHESLQ (ORCPT ); Wed, 5 Aug 2020 14:11:16 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC79FC0617AB; Wed, 5 Aug 2020 11:10:22 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id z5so24937925pgb.6; Wed, 05 Aug 2020 11:10:22 -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=oVv4Wzhn3JTwGtZviwAnr4HC2ws5LBgl7lYKjJuNKZY=; b=BrpYJEVk8N/XVlt4jsasznf003BTu7lhnJ1yz6JbHpFcdbh0Jgwy5vrSZZzMMpXNuG rOCr8SOkoAUK5ZMGdgz4COUznIrU9pfS1GFtceCstYb8ZmuWiqwS9T01VCXsRcny3SD0 8SK+j9Lv9xT4IBuOUEiGFY9p2ilme1znS6pOMaj//glr5nnDJI8CJUmOFiFQD0f7NoRF 5Q7c1ON8o7dzq+Dq8i6ssclH+jsM/2vInABBoozfXimoPjvFEv1eGrBXTITf3ANqucbK e8MtS3enVGZa5I4TOXD50C2ibKk8cBoPjYGBQLEZSATPyhJDUErPbVmNDHEqOEa4M05x WhgQ== 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=oVv4Wzhn3JTwGtZviwAnr4HC2ws5LBgl7lYKjJuNKZY=; b=WDKjX9J8hXytZZqjWaaYy9pvHueZmjCdY3+fA0hWVTr2OFAYnM8jDdIae5aOFj/M0Y POer1aqWnDtkrD2CSfS6df1LD37sT04INsRta0RqIVvN6cMKKlbQ+9m6rmYGjL75TpEB RCQMEFe76SBcyF9EYtRv0UVGZA9Zq3EixGik8HKz04WXVbab0xHdCkaTyYaLIErVeAyB 5zBC+0p+PFQrGv58O/UuIUIdHctG2+EdaRbpBhuR8JlTapE5Phi0UauPF5haTWzjAkBN okJDDyM2afgbL4CEzUhHOeJumOszIw6wW1gHLCdUE/bUjDRmZmGs5MF9cDjHqX7+BWqJ N2lA== X-Gm-Message-State: AOAM533DC2vPlFc/Dso1Py68HDwke9NwsmhqVrp+3COOauZce07Od1Rq s1ZHH2Teoo8FuWcEPzcRS1w= X-Received: by 2002:a65:524b:: with SMTP id q11mr4075709pgp.372.1596651022278; Wed, 05 Aug 2020 11:10:22 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id t63sm4977510pfb.210.2020.08.05.11.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:10:21 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Bartlomiej Zolnierkiewicz , Paul Mackerras , Russell King , Andres Salomon , Antonino Daplas , Florian Tobias Schandinat Cc: Vaibhav Gupta , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-geode@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: [PATCH v1 10/12] fbdev: vt8623fb: use generic power management Date: Wed, 5 Aug 2020 23:37:20 +0530 Message-Id: <20200805180722.244008-11-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200805180722.244008-1-vaibhavgupta40@gmail.com> References: <20200805180722.244008-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 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 --- drivers/video/fbdev/vt8623fb.c | 41 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index 7b3eef1b893f..c488e0117758 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -815,12 +815,11 @@ static void vt8623_pci_remove(struct pci_dev *dev) } -#ifdef CONFIG_PM /* PCI suspend */ -static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused vt8623_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct vt8623fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -828,7 +827,7 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) console_lock(); mutex_lock(&(par->open_lock)); - if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { + if (par->ref_count == 0) { mutex_unlock(&(par->open_lock)); console_unlock(); return 0; @@ -836,10 +835,6 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) fb_set_suspend(info, 1); - pci_save_state(dev); - pci_disable_device(dev); - pci_set_power_state(dev, pci_choose_state(dev, state)); - mutex_unlock(&(par->open_lock)); console_unlock(); @@ -849,9 +844,9 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int vt8623_pci_resume(struct pci_dev* dev) +static int __maybe_unused vt8623_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct vt8623fb_info *par = info->par; dev_info(info->device, "resume\n"); @@ -862,14 +857,6 @@ static int vt8623_pci_resume(struct pci_dev* dev) if (par->ref_count == 0) goto fail; - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - - if (pci_enable_device(dev)) - goto fail; - - pci_set_master(dev); - vt8623fb_set_par(info); fb_set_suspend(info, 0); @@ -879,10 +866,17 @@ static int vt8623_pci_resume(struct pci_dev* dev) return 0; } -#else -#define vt8623_pci_suspend NULL -#define vt8623_pci_resume NULL -#endif /* CONFIG_PM */ + +static const struct dev_pm_ops vt8623_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = vt8623_pci_suspend, + .resume = vt8623_pci_resume, + .freeze = NULL, + .thaw = vt8623_pci_resume, + .poweroff = vt8623_pci_suspend, + .restore = vt8623_pci_resume, +#endif /* CONFIG_PM_SLEEP */ +}; /* List of boards that we are trying to support */ @@ -898,8 +892,7 @@ static struct pci_driver vt8623fb_pci_driver = { .id_table = vt8623_devices, .probe = vt8623_pci_probe, .remove = vt8623_pci_remove, - .suspend = vt8623_pci_suspend, - .resume = vt8623_pci_resume, + .driver.pm = &vt8623_pci_pm_ops, }; /* Cleanup */ -- 2.27.0