mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH 05/12] parport: PCI core handles power state for us
Date: Wed,  7 Feb 2018 19:47:52 +0000	[thread overview]
Message-ID: <1518032879-5844-5-git-send-email-sudipm.mukherjee@gmail.com> (raw)
In-Reply-To: <1518032879-5844-1-git-send-email-sudipm.mukherjee@gmail.com>

From: Andy Shevchenko <andy.shevchenko@gmail.com>

There is no need to repeat the work that is already done in the PCI
driver core. The patch removes excerpts from suspend and resume
callbacks.

Note that there is no more calls performed to enable or disable a PCI
device during suspend-resume cycle. Nowadays they seems to be
superflous. Someone can read more in [1].

While here, convert calls to new driver API.

[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-319-330.pdf

Tested-by: Nikola Ciprich <nikola.ciprich@linuxbox.cz>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
 drivers/parport/parport_serial.c | 40 ++++++++++++----------------------------
 1 file changed, 12 insertions(+), 28 deletions(-)

diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 53a3eae..d0a5bc5 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -664,57 +664,41 @@ static void parport_serial_pci_remove(struct pci_dev *dev)
 	return;
 }
 
-#ifdef CONFIG_PM
-static int parport_serial_pci_suspend(struct pci_dev *dev, pm_message_t state)
+static int __maybe_unused parport_serial_pci_suspend(struct device *dev)
 {
-	struct parport_serial_private *priv = pci_get_drvdata(dev);
+	struct pci_dev *pdev = to_pci_dev(dev);
+	struct parport_serial_private *priv = pci_get_drvdata(pdev);
 
 	if (priv->serial)
 		pciserial_suspend_ports(priv->serial);
 
 	/* FIXME: What about parport? */
-
-	pci_save_state(dev);
-	pci_set_power_state(dev, pci_choose_state(dev, state));
 	return 0;
 }
 
-static int parport_serial_pci_resume(struct pci_dev *dev)
+static int __maybe_unused parport_serial_pci_resume(struct device *dev)
 {
-	struct parport_serial_private *priv = pci_get_drvdata(dev);
-	int err;
-
-	pci_set_power_state(dev, PCI_D0);
-	pci_restore_state(dev);
-
-	/*
-	 * The device may have been disabled.  Re-enable it.
-	 */
-	err = pci_enable_device(dev);
-	if (err) {
-		printk(KERN_ERR "parport_serial: %s: error enabling "
-			"device for resume (%d)\n", pci_name(dev), err);
-		return err;
-	}
+	struct pci_dev *pdev = to_pci_dev(dev);
+	struct parport_serial_private *priv = pci_get_drvdata(pdev);
 
 	if (priv->serial)
 		pciserial_resume_ports(priv->serial);
 
 	/* FIXME: What about parport? */
-
 	return 0;
 }
-#endif
+
+static SIMPLE_DEV_PM_OPS(parport_serial_pm_ops,
+			 parport_serial_pci_suspend, parport_serial_pci_resume);
 
 static struct pci_driver parport_serial_pci_driver = {
 	.name		= "parport_serial",
 	.id_table	= parport_serial_pci_tbl,
 	.probe		= parport_serial_pci_probe,
 	.remove		= parport_serial_pci_remove,
-#ifdef CONFIG_PM
-	.suspend	= parport_serial_pci_suspend,
-	.resume		= parport_serial_pci_resume,
-#endif
+	.driver         = {
+		.pm     = &parport_serial_pm_ops,
+	},
 };
 
 
-- 
2.7.4

  parent reply	other threads:[~2018-02-07 19:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 19:47 [PATCH 01/12] parport: ax88796: Delete an error message for a failed memory allocation in parport_ax88796_probe() Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 02/12] parport: ax88796: Improve a size determination " Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 03/12] parport: ax88796: Delete an unnecessary variable initialisation " Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 04/12] parport: Add support for BrainBoxes PX272/PX306 MIO card Sudip Mukherjee
2018-02-07 19:47 ` Sudip Mukherjee [this message]
2018-02-07 19:47 ` [PATCH 06/12] parport: Convert to use managed functions pcim_* and devm_* Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 07/12] parport: Don't shadow error codes in ->probe() Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 08/12] parport: Convert printk(KERN_WARN) to dev_warn() Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 09/12] parport: Switch to use module_pci_driver() macro Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 10/12] parport: Sort headers alphabetically Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 11/12] parport: Replace short License header by SPDX identifier Sudip Mukherjee
2018-02-07 19:47 ` [PATCH 12/12] parport_pc: Add support for WCH CH382L PCI-E single parallel port card Sudip Mukherjee
2018-03-01 10:46 ` [PATCH 01/12] parport: ax88796: Delete an error message for a failed memory allocation in parport_ax88796_probe() Andy Shevchenko
2018-03-01 12:06   ` Greg Kroah-Hartman
2018-03-01 12:17     ` Andy Shevchenko
2018-03-03 21:00     ` Sudip Mukherjee
2018-03-12 14:10       ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518032879-5844-5-git-send-email-sudipm.mukherjee@gmail.com \
    --to=sudipm.mukherjee@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®