Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp733656pxa; Wed, 5 Aug 2020 11:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTpcaPLnZmLbwYuqeNHbrZMPAJ3dT1Ea3J5neHnW7NN9A/5JuLQueDBDrG2VsOIJig22Et X-Received: by 2002:a17:906:2681:: with SMTP id t1mr551061ejc.350.1596651850663; Wed, 05 Aug 2020 11:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596651850; cv=none; d=google.com; s=arc-20160816; b=znN/DXRZ5ijS8Yx9rd3px1ms0GAvVNpyJAPCCO13eOm0ndMb8UyOx3eqDrUZ1Go7+X I2dFt+x3LkN/Yz1XAQ0D5OEJXasc2C9V74HBynLABXUAEdvACYTySURosLfUlvCnjOjk M4uHM3+tI7iHrqbw7SHG2vRoVu0pN5BL+B8HGQkq0jBN+NIvD6zwBYbY2P3GoFHojFWt JjVobiTFHn8YWQn0QtOWxu+msTe1I8uWLA7Jq1W0TVFkuLu1MHGzGIPcOWdXDsf5sINn zKUo0Y7/p/fkQk+FT/xbL3Jx/ZXKSMdCNOWm4ASRnHZ8U9c+xe7AZatgmcFLl/QvSypr Mpig== 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=wr1R0/Ze2G4IecD2JkfhRTVYXHTVK1Tx0wo+bfHFfJI=; b=ytXOVZXmfJLrW8ATOsSGr7ZxpaULtkXKkJ6VnG14ryqixv6oic5dQZzZmH4hLiAUiH otE2Z2JQhaw95rzpkYhiLN8BpFiW+U3WWb5YdcBPRPAKmThQjHzTwSafoS565Y/NsXZ/ FCDPA1Lh1UIDYjVWw6MTVMbn8Q8gVOFpSJQ6pBiTiC0gSOy/KWh3MyXdCMYJmjI/ucJk GMiLxdswzv808jplgsTtgcFqjTJTUA2bUO2YKi6hzOE4MtggC2HQW2lhV0UvKV34uftm aALXaWqq+2zXet8t1hb3VWE148xefDPPQldzAloUtVrDXuXTjYTgq67nlniy5U0PS/uN /a3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sJdfVwrs; 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 bj23si1751928ejb.94.2020.08.05.11.23.46; Wed, 05 Aug 2020 11:24:10 -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=sJdfVwrs; 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 S1729048AbgHESXE (ORCPT + 99 others); Wed, 5 Aug 2020 14:23:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729028AbgHESLP (ORCPT ); Wed, 5 Aug 2020 14:11:15 -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 D518BC061575; Wed, 5 Aug 2020 11:10:16 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t11so5908678plr.5; Wed, 05 Aug 2020 11:10:16 -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=wr1R0/Ze2G4IecD2JkfhRTVYXHTVK1Tx0wo+bfHFfJI=; b=sJdfVwrs67VSWJ5Urnu3dK5b8A8dylK7mh1xnF8wRETervUk9RNicZKtC+qvch4EFV k26HGRHycRlUbPnzAzmeVzlHJHTPxIuPT0hzGI/0edcqMTs6QxFztZsAYKTzI/3AuyW9 Q+MMx6BOgb47Xcgt8E6FTwNIFije/ztkRl9lifaif5/f0H0F29Wha7hVxyCaJ3YcoGHu aqSTjF1lsue7sZtzPF9fQvJOlQrT5+iWp+K1nLpsudiy+Cuqa1oF9H9EsLdYlmamTQuL dQuQQUvftJye8+UOMCuoEqKOivnQGMZ9Ut9CFVD3GznkJVvB9d2ltjwYLrY6OnsjR27k mRqw== 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=wr1R0/Ze2G4IecD2JkfhRTVYXHTVK1Tx0wo+bfHFfJI=; b=srRNJmEqmpacQ5x2F1rMCosTuXlh07eYdnj7UNe+R3wdQXTsg5rkhgbY1N1gg2VkEe 4G3aKTZRzlulQXLDUCkG6NvQWF2ujZHONvoVaI1NK2gw0rK9WfkDCn7S47Zj8sZj6YlX bD3UnMZ5xAl5UANmCBV93F/4W2IEoArXFu7N7DdBUKt6PZYu5IAQuWwKKEwSSMd5Z8v/ sGNejzxMXViGwd59G2wg5h6QSFc3urLaxBXqcKVowQFzo7uhzatS30ZwC0U1yUaqOzai 7XkusGvmP3Xp1t1jiqrIJLWelQcifmY4mBJxlM1uOiSqzgPHFC1rjFNsQ63FCyIILBtW R/5w== X-Gm-Message-State: AOAM532N6u/VgGHAFc38dRXJw9HiP+ZCP57yQ/9fI6Xf4VzK6bvtM/ga 0gR8c5HcN+wU8szBXD+HukE= X-Received: by 2002:a17:90b:4a0a:: with SMTP id kk10mr4520046pjb.30.1596651016370; Wed, 05 Aug 2020 11:10:16 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:10:15 -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 09/12] fbdev: i740fb: use generic power management Date: Wed, 5 Aug 2020 23:37:19 +0530 Message-Id: <20200805180722.244008-10-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/i740fb.c | 40 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c index c65ec7386e87..8d7f06fc8a5a 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -1175,16 +1175,11 @@ static void i740fb_remove(struct pci_dev *dev) } } -#ifdef CONFIG_PM -static int i740fb_suspend(struct pci_dev *dev, pm_message_t state) +static int __maybe_unused i740fb_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct i740fb_par *par = info->par; - /* don't disable console during hibernation and wakeup from it */ - if (state.event == PM_EVENT_FREEZE || state.event == PM_EVENT_PRETHAW) - return 0; - console_lock(); mutex_lock(&(par->open_lock)); @@ -1197,19 +1192,15 @@ static int i740fb_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(); return 0; } -static int i740fb_resume(struct pci_dev *dev) +static int __maybe_unused i740fb_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct i740fb_par *par = info->par; console_lock(); @@ -1218,11 +1209,6 @@ static int i740fb_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; - i740fb_set_par(info); fb_set_suspend(info, 0); @@ -1231,10 +1217,17 @@ static int i740fb_resume(struct pci_dev *dev) console_unlock(); return 0; } -#else -#define i740fb_suspend NULL -#define i740fb_resume NULL -#endif /* CONFIG_PM */ + +static const struct dev_pm_ops i740fb_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = i740fb_suspend, + .resume = i740fb_resume, + .freeze = NULL, + .thaw = i740fb_resume, + .poweroff = i740fb_suspend, + .restore = i740fb_resume, +#endif /* CONFIG_PM_SLEEP */ +}; #define I740_ID_PCI 0x00d1 #define I740_ID_AGP 0x7800 @@ -1251,8 +1244,7 @@ static struct pci_driver i740fb_driver = { .id_table = i740fb_id_table, .probe = i740fb_probe, .remove = i740fb_remove, - .suspend = i740fb_suspend, - .resume = i740fb_resume, + .driver.pm = &i740fb_pm_ops, }; #ifndef MODULE -- 2.27.0