From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A68B6C433DF for ; Wed, 5 Aug 2020 18:22:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AE3122CA0 for ; Wed, 5 Aug 2020 18:22:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gub5BhXg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729184AbgHESWb (ORCPT ); Wed, 5 Aug 2020 14:22:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbgHESLW (ORCPT ); Wed, 5 Aug 2020 14:11:22 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E97BCC0617B1; Wed, 5 Aug 2020 11:10:28 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id 74so14935607pfx.13; Wed, 05 Aug 2020 11:10:28 -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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=gub5BhXgKIwql1fVHMrX+4usvSKCyg4lEY8j+g0tftBKI6jTK++/xJ98ikhyonQevY DcLYyqAawxEpy1H9uh0ctJVCOSy6DVB6UbVaYPu9jY0G0ktlVkw+X21iaOWak94jrsje YpxQ1fTAdY0T9Q0qSVuWXq6A+0isRy8zZ0NbEA/o/9TfA02w/0zGNY4LVR5gUeAxm3lO 8US9cWJrqi3g6NL79G5wBUNN423vu40M3SuAnMfxpaGrVwO3QHs/RrIFY2aILq3cLCZJ 2nkBJ7O1LJb9mDA+yk7c7Acv7rxDBePnN5iZBw9YWWV39K2npVI8Oyx0SV3i3w2TrFXu Ejdw== 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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=KXeq+kRb9UeTW13/nwi6eKi/rTaimi58N/PhyG4uPGzBMe9j0qY5LAyvicmbVgc0ps 2pGl7NUsNv0i4oSn1IXaUuS1csFJcmROsyX664dfeqIZkiZc2meTmGlWsOUAyi9ThgQv Kmv+ZlIfmBclvfj03J+4fzNeXaYSFeFv1BmREcSRy/QBBZM71ipr6V8e//cgrw4DmjjQ /rQ7Y1XmYNudHFbJ10hSiYLsIQmbwKFdQqxZoESBMnDjo9y8sWlze1qCpUD3pp+4PJZA rCyNQWbTnTKqS4EwUS5ed1U0rnllBEoxlskPCBgzRmGDq4dNtftgG4o2jtEdvPVODe65 W4pQ== X-Gm-Message-State: AOAM5329q37U+tZrJgNEDdSX0YRmjoBRE3+oI18SvWjUgH+Zu3R2Rp93 qcTtPoM/oOZ6YF07fadaEv8= X-Google-Smtp-Source: ABdhPJyAAqO7Rx5av7I1iXkiEYPek0iKwQgNUn4/m4VcSnNpdaU7uE7GLjNluwPRQgTfUc24ejyZ3w== X-Received: by 2002:a63:330c:: with SMTP id z12mr4150629pgz.46.1596651028426; Wed, 05 Aug 2020 11:10:28 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:10:27 -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 11/12] fbdev: s3fb: use generic power management Date: Wed, 5 Aug 2020 23:37:21 +0530 Message-Id: <20200805180722.244008-12-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/s3fb.c | 39 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 60c424fae988..5c74253e7b2c 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1410,9 +1410,9 @@ static void s3_pci_remove(struct pci_dev *dev) /* PCI suspend */ -static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused s3_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -1420,7 +1420,7 @@ static int s3_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; @@ -1428,10 +1428,6 @@ static int s3_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(); @@ -1441,11 +1437,10 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int s3_pci_resume(struct pci_dev* dev) +static int __maybe_unused s3_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; - int err; dev_info(info->device, "resume\n"); @@ -1458,17 +1453,6 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - err = pci_enable_device(dev); - if (err) { - mutex_unlock(&(par->open_lock)); - console_unlock(); - dev_err(info->device, "error %d enabling device for resume\n", err); - return err; - } - pci_set_master(dev); - s3fb_set_par(info); fb_set_suspend(info, 0); @@ -1478,6 +1462,16 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops s3_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = s3_pci_suspend, + .resume = s3_pci_resume, + .freeze = NULL, + .thaw = s3_pci_resume, + .poweroff = s3_pci_suspend, + .restore = s3_pci_resume, +#endif +}; /* List of boards that we are trying to support */ @@ -1510,8 +1504,7 @@ static struct pci_driver s3fb_pci_driver = { .id_table = s3_devices, .probe = s3_pci_probe, .remove = s3_pci_remove, - .suspend = s3_pci_suspend, - .resume = s3_pci_resume, + .driver.pm = &s3_pci_pm_ops, }; /* Parse user specified options */ -- 2.27.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vaibhav Gupta Date: Wed, 05 Aug 2020 18:19:21 +0000 Subject: [PATCH v1 11/12] fbdev: s3fb: use generic power management Message-Id: <20200805180722.244008-12-vaibhavgupta40@gmail.com> List-Id: References: <20200805180722.244008-1-vaibhavgupta40@gmail.com> In-Reply-To: <20200805180722.244008-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Bartlomiej Zolnierkiewicz , Paul Mackerras , Russell King , Andres Salomon , Antonino Daplas , Florian Tobias Schandinat Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.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/s3fb.c | 39 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 60c424fae988..5c74253e7b2c 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1410,9 +1410,9 @@ static void s3_pci_remove(struct pci_dev *dev) /* PCI suspend */ -static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused s3_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -1420,7 +1420,7 @@ static int s3_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; @@ -1428,10 +1428,6 @@ static int s3_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(); @@ -1441,11 +1437,10 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int s3_pci_resume(struct pci_dev* dev) +static int __maybe_unused s3_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; - int err; dev_info(info->device, "resume\n"); @@ -1458,17 +1453,6 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - err = pci_enable_device(dev); - if (err) { - mutex_unlock(&(par->open_lock)); - console_unlock(); - dev_err(info->device, "error %d enabling device for resume\n", err); - return err; - } - pci_set_master(dev); - s3fb_set_par(info); fb_set_suspend(info, 0); @@ -1478,6 +1462,16 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops s3_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = s3_pci_suspend, + .resume = s3_pci_resume, + .freeze = NULL, + .thaw = s3_pci_resume, + .poweroff = s3_pci_suspend, + .restore = s3_pci_resume, +#endif +}; /* List of boards that we are trying to support */ @@ -1510,8 +1504,7 @@ static struct pci_driver s3fb_pci_driver = { .id_table = s3_devices, .probe = s3_pci_probe, .remove = s3_pci_remove, - .suspend = s3_pci_suspend, - .resume = s3_pci_resume, + .driver.pm = &s3_pci_pm_ops, }; /* Parse user specified options */ -- 2.27.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A6C0C433E0 for ; Wed, 5 Aug 2020 18:10:33 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F9DD20656 for ; Wed, 5 Aug 2020 18:10:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gub5BhXg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F9DD20656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4221220421; Wed, 5 Aug 2020 18:10:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KwYrdH+2FGJI; Wed, 5 Aug 2020 18:10:30 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id C3C862271F; Wed, 5 Aug 2020 18:10:30 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B1716C0050; Wed, 5 Aug 2020 18:10:30 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6B6B5C004C for ; Wed, 5 Aug 2020 18:10:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5ADB7864E6 for ; Wed, 5 Aug 2020 18:10:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iuzXvaouXr7D for ; Wed, 5 Aug 2020 18:10:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id DD69585546 for ; Wed, 5 Aug 2020 18:10:28 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id d188so17144801pfd.2 for ; Wed, 05 Aug 2020 11:10:28 -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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=gub5BhXgKIwql1fVHMrX+4usvSKCyg4lEY8j+g0tftBKI6jTK++/xJ98ikhyonQevY DcLYyqAawxEpy1H9uh0ctJVCOSy6DVB6UbVaYPu9jY0G0ktlVkw+X21iaOWak94jrsje YpxQ1fTAdY0T9Q0qSVuWXq6A+0isRy8zZ0NbEA/o/9TfA02w/0zGNY4LVR5gUeAxm3lO 8US9cWJrqi3g6NL79G5wBUNN423vu40M3SuAnMfxpaGrVwO3QHs/RrIFY2aILq3cLCZJ 2nkBJ7O1LJb9mDA+yk7c7Acv7rxDBePnN5iZBw9YWWV39K2npVI8Oyx0SV3i3w2TrFXu Ejdw== 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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=HMBGubBlg7rTkPAMRWb1T1J0xnWqzI16+FXSzyYhCZMH94uGPJ3iFqHHg9VN5yCboy i1zv1udrVXQjM4yC5Xz4r4YlnPpjRruM3/AdR5Y72lVUXUpf2naxZb7BdGPv8d0cysn/ Qbux95yH2gaoLS3LrDzQ5S9Eese8ZMz9MCyaJ8K5aU8OmQ20IJu93UUW8ZyZzO5ZlLNg mxgjG6amgRTa0J4MylGOF1p8gxow5OKYx+psdBlwL7lrqQc07Y/Yp6MaioSAGmcd9/Fq fCyx6ygSRPXx1ERgOBOObY0HOUjyeUEmPKuxOO0nfGCOjbK8oSfiu6VxnkQ8f26+c6sI X0QQ== X-Gm-Message-State: AOAM531KBmNLHXsDEj7P+V7vZeps8wXtp7dZpEBNZYlp9O4xpgi+M5ez j2G/ivBghahb8SV2BeAgRPY= X-Google-Smtp-Source: ABdhPJyAAqO7Rx5av7I1iXkiEYPek0iKwQgNUn4/m4VcSnNpdaU7uE7GLjNluwPRQgTfUc24ejyZ3w== X-Received: by 2002:a63:330c:: with SMTP id z12mr4150629pgz.46.1596651028426; Wed, 05 Aug 2020 11:10:28 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:10:27 -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 Date: Wed, 5 Aug 2020 23:37:21 +0530 Message-Id: <20200805180722.244008-12-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 Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Subject: [Linux-kernel-mentees] [PATCH v1 11/12] fbdev: s3fb: use generic power management X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" 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/s3fb.c | 39 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 60c424fae988..5c74253e7b2c 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1410,9 +1410,9 @@ static void s3_pci_remove(struct pci_dev *dev) /* PCI suspend */ -static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused s3_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -1420,7 +1420,7 @@ static int s3_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; @@ -1428,10 +1428,6 @@ static int s3_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(); @@ -1441,11 +1437,10 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int s3_pci_resume(struct pci_dev* dev) +static int __maybe_unused s3_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; - int err; dev_info(info->device, "resume\n"); @@ -1458,17 +1453,6 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - err = pci_enable_device(dev); - if (err) { - mutex_unlock(&(par->open_lock)); - console_unlock(); - dev_err(info->device, "error %d enabling device for resume\n", err); - return err; - } - pci_set_master(dev); - s3fb_set_par(info); fb_set_suspend(info, 0); @@ -1478,6 +1462,16 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops s3_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = s3_pci_suspend, + .resume = s3_pci_resume, + .freeze = NULL, + .thaw = s3_pci_resume, + .poweroff = s3_pci_suspend, + .restore = s3_pci_resume, +#endif +}; /* List of boards that we are trying to support */ @@ -1510,8 +1504,7 @@ static struct pci_driver s3fb_pci_driver = { .id_table = s3_devices, .probe = s3_pci_probe, .remove = s3_pci_remove, - .suspend = s3_pci_suspend, - .resume = s3_pci_resume, + .driver.pm = &s3_pci_pm_ops, }; /* Parse user specified options */ -- 2.27.0 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D77EC433E0 for ; Wed, 5 Aug 2020 18:12:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E579F20656 for ; Wed, 5 Aug 2020 18:12:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UjN2iU70"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gub5BhXg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E579F20656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uOCt9PpKu8buikyKPiiXudcDhQuJQ8yyDRcmJOo8P30=; b=UjN2iU70XvVTgdzBwbGV3xn34 w7so6EheUFeW9CqnRIvQRObG6CBvxBn5ME6Vg53uUzMOVOrC97AfX7W8CPHx/hSFftECX0Mhj7XJW O5D83xnl01rLH3yNmXaex1mcmPdpR3o9gt83CoUaN2p5OKgNBg9mkb5ccxDeh3/5XMVmXbkYeA4aj +jlaKwc30d0bTgGg6+fkolDqUX15AMBd4gxfZm5cwLhZhyKHLrn/Vnhp2bBYyqCh4POpeEvGi7mfn PdyXckfdO9yv+VzL9OmMCFbFpHEQGWdD+iXxnVvi6Sj8RCsFG4nJ6wj3xE8Fq2vmsgkjKaTH0V4It UUCNV/nOw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3NsM-0006DO-S3; Wed, 05 Aug 2020 18:10:54 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3Nry-0005xU-F1; Wed, 05 Aug 2020 18:10:32 +0000 Received: by mail-pf1-x442.google.com with SMTP id m8so16345499pfh.3; Wed, 05 Aug 2020 11:10:30 -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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=gub5BhXgKIwql1fVHMrX+4usvSKCyg4lEY8j+g0tftBKI6jTK++/xJ98ikhyonQevY DcLYyqAawxEpy1H9uh0ctJVCOSy6DVB6UbVaYPu9jY0G0ktlVkw+X21iaOWak94jrsje YpxQ1fTAdY0T9Q0qSVuWXq6A+0isRy8zZ0NbEA/o/9TfA02w/0zGNY4LVR5gUeAxm3lO 8US9cWJrqi3g6NL79G5wBUNN423vu40M3SuAnMfxpaGrVwO3QHs/RrIFY2aILq3cLCZJ 2nkBJ7O1LJb9mDA+yk7c7Acv7rxDBePnN5iZBw9YWWV39K2npVI8Oyx0SV3i3w2TrFXu Ejdw== 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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=Bz3pYLdxMuQEwGxYnyRiSzlhphKTGgIXAtvAeuwnpEZz52I97m5jOvLk4khJeUWGA4 jd9L4r5m7rtMMOBjLAi/ALsHKMv0bNcU5fjXfClIIiZmFLjEn6KZycvYxb1zCRoiWhF+ OrOplR664u4lhSfZULKBMiQSYSkNIsHisw2H8tDHCHIOepiC28M6DtGMmHgNQlCwP2xp hqgzr600uZ3SEKFQsZg3kffWr9b6auJxh1414QyRt+IWh+8Z+3DVlfPlmMWFV9oZPoJT GymMyAW9E4wH+Vj4hxIQc3NFU0EoyFLsw3hGqB9ILazg1f08wh0H9fpbGwkiqFr91LOk L/Ag== X-Gm-Message-State: AOAM532gyZaaO1pYCIgqCmy23/UFyZSwqvcmwFyCZueBL4bgkgGb5tGk 1hYVxVw4vh+kHhUXtms9OWg= X-Google-Smtp-Source: ABdhPJyAAqO7Rx5av7I1iXkiEYPek0iKwQgNUn4/m4VcSnNpdaU7uE7GLjNluwPRQgTfUc24ejyZ3w== X-Received: by 2002:a63:330c:: with SMTP id z12mr4150629pgz.46.1596651028426; Wed, 05 Aug 2020 11:10:28 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:10:27 -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 Subject: [PATCH v1 11/12] fbdev: s3fb: use generic power management Date: Wed, 5 Aug 2020 23:37:21 +0530 Message-Id: <20200805180722.244008-12-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_141031_319999_8B6E46D1 X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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/s3fb.c | 39 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 60c424fae988..5c74253e7b2c 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1410,9 +1410,9 @@ static void s3_pci_remove(struct pci_dev *dev) /* PCI suspend */ -static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused s3_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -1420,7 +1420,7 @@ static int s3_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; @@ -1428,10 +1428,6 @@ static int s3_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(); @@ -1441,11 +1437,10 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int s3_pci_resume(struct pci_dev* dev) +static int __maybe_unused s3_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; - int err; dev_info(info->device, "resume\n"); @@ -1458,17 +1453,6 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - err = pci_enable_device(dev); - if (err) { - mutex_unlock(&(par->open_lock)); - console_unlock(); - dev_err(info->device, "error %d enabling device for resume\n", err); - return err; - } - pci_set_master(dev); - s3fb_set_par(info); fb_set_suspend(info, 0); @@ -1478,6 +1462,16 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops s3_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = s3_pci_suspend, + .resume = s3_pci_resume, + .freeze = NULL, + .thaw = s3_pci_resume, + .poweroff = s3_pci_suspend, + .restore = s3_pci_resume, +#endif +}; /* List of boards that we are trying to support */ @@ -1510,8 +1504,7 @@ static struct pci_driver s3fb_pci_driver = { .id_table = s3_devices, .probe = s3_pci_probe, .remove = s3_pci_remove, - .suspend = s3_pci_suspend, - .resume = s3_pci_resume, + .driver.pm = &s3_pci_pm_ops, }; /* Parse user specified options */ -- 2.27.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B18AC433F4 for ; Thu, 6 Aug 2020 11:55:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0267023118 for ; Thu, 6 Aug 2020 11:55:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gub5BhXg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0267023118 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56F496E88C; Thu, 6 Aug 2020 07:39:40 +0000 (UTC) Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id E0D6E6E82E for ; Wed, 5 Aug 2020 18:10:28 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id k18so15970562pfp.7 for ; Wed, 05 Aug 2020 11:10:28 -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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=gub5BhXgKIwql1fVHMrX+4usvSKCyg4lEY8j+g0tftBKI6jTK++/xJ98ikhyonQevY DcLYyqAawxEpy1H9uh0ctJVCOSy6DVB6UbVaYPu9jY0G0ktlVkw+X21iaOWak94jrsje YpxQ1fTAdY0T9Q0qSVuWXq6A+0isRy8zZ0NbEA/o/9TfA02w/0zGNY4LVR5gUeAxm3lO 8US9cWJrqi3g6NL79G5wBUNN423vu40M3SuAnMfxpaGrVwO3QHs/RrIFY2aILq3cLCZJ 2nkBJ7O1LJb9mDA+yk7c7Acv7rxDBePnN5iZBw9YWWV39K2npVI8Oyx0SV3i3w2TrFXu Ejdw== 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=lTR8Lgo0lTVr30kAgGXldRLjSzJrurZ+/TCCEqZVqLQ=; b=UbMDRFpZB9b8J/G1lpkWrQLDa1PYNmlze7BNMKvvQbrt6VzJ8P1AdV3lNsBKZbDeDp v2aNvH+9qLBv9JMe0Za3IBse3u5QwYJDx/8xdLcvqanEWxECDPKCMdOItshEAjHsoKu/ fjO2Gc9IhJNUGduvYuQleM17FdoBhheVm0BTfBfU9m0z9ylJKahICj2D8M6db77L9OfO 3G8Xz0SxW0TIpBIAE1f7IQ8sFieZaR7xKqUAcsyfk9HD2cLWLvFjXKIkcBsGxU8Wvo0D 9rX/8/wnTDnMlcQQrBMS9v+WCi2WL7QmHUIgBxdW674trVKc+mIF8Oe92dXRNIpkDrlZ QLcQ== X-Gm-Message-State: AOAM530OPpweoChUDmNWEjJjLfKi55+dg9Nqyz34ZtDxSjDHykxvkbMb U+zBrLVRXuN79iDtnI27llI= X-Google-Smtp-Source: ABdhPJyAAqO7Rx5av7I1iXkiEYPek0iKwQgNUn4/m4VcSnNpdaU7uE7GLjNluwPRQgTfUc24ejyZ3w== X-Received: by 2002:a63:330c:: with SMTP id z12mr4150629pgz.46.1596651028426; Wed, 05 Aug 2020 11:10:28 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:10:27 -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 Subject: [PATCH v1 11/12] fbdev: s3fb: use generic power management Date: Wed, 5 Aug 2020 23:37:21 +0530 Message-Id: <20200805180722.244008-12-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 X-Mailman-Approved-At: Thu, 06 Aug 2020 07:39:21 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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/s3fb.c | 39 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 60c424fae988..5c74253e7b2c 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1410,9 +1410,9 @@ static void s3_pci_remove(struct pci_dev *dev) /* PCI suspend */ -static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused s3_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -1420,7 +1420,7 @@ static int s3_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; @@ -1428,10 +1428,6 @@ static int s3_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(); @@ -1441,11 +1437,10 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int s3_pci_resume(struct pci_dev* dev) +static int __maybe_unused s3_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; - int err; dev_info(info->device, "resume\n"); @@ -1458,17 +1453,6 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - err = pci_enable_device(dev); - if (err) { - mutex_unlock(&(par->open_lock)); - console_unlock(); - dev_err(info->device, "error %d enabling device for resume\n", err); - return err; - } - pci_set_master(dev); - s3fb_set_par(info); fb_set_suspend(info, 0); @@ -1478,6 +1462,16 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops s3_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = s3_pci_suspend, + .resume = s3_pci_resume, + .freeze = NULL, + .thaw = s3_pci_resume, + .poweroff = s3_pci_suspend, + .restore = s3_pci_resume, +#endif +}; /* List of boards that we are trying to support */ @@ -1510,8 +1504,7 @@ static struct pci_driver s3fb_pci_driver = { .id_table = s3_devices, .probe = s3_pci_probe, .remove = s3_pci_remove, - .suspend = s3_pci_suspend, - .resume = s3_pci_resume, + .driver.pm = &s3_pci_pm_ops, }; /* Parse user specified options */ -- 2.27.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel