From: Vaibhav Gupta <vaibhavgupta40@gmail.com>
To: Bjorn Helgaas <helgaas@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
bjorn@helgaas.com, Vaibhav Gupta <vaibhav.varodek@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: Re: [Linux-kernel-mentees] [PATCH v1] [media] saa7134: use generic power management
Date: Mon, 17 Aug 2020 13:12:29 +0530 [thread overview]
Message-ID: <20200817074229.GB5869@gmail.com> (raw)
In-Reply-To: <20200622120229.89610-1-vaibhavgupta40@gmail.com>
On Mon, Jun 22, 2020 at 05:32:30PM +0530, Vaibhav Gupta wrote:
> With the support of generic PM callbacks, drivers no longer need to use
> legacy .suspend() and .resume() in which they had to maintain PCI states
> changes and device's power state themselves. The required operations are
> done by PCI core.
>
> Compile-tested only.
>
> Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
> ---
> drivers/media/pci/saa7134/saa7134-core.c | 25 ++++++++----------------
> 1 file changed, 8 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
> index e4623ed2f831..eb01109d4f98 100644
> --- a/drivers/media/pci/saa7134/saa7134-core.c
> +++ b/drivers/media/pci/saa7134/saa7134-core.c
> @@ -1370,10 +1370,8 @@ static void saa7134_finidev(struct pci_dev *pci_dev)
> kfree(dev);
> }
>
> -#ifdef CONFIG_PM
> -
> /* resends a current buffer in queue after resume */
> -static int saa7134_buffer_requeue(struct saa7134_dev *dev,
> +static int __maybe_unused saa7134_buffer_requeue(struct saa7134_dev *dev,
> struct saa7134_dmaqueue *q)
> {
> struct saa7134_buf *buf, *next;
> @@ -1397,8 +1395,9 @@ static int saa7134_buffer_requeue(struct saa7134_dev *dev,
> return 0;
> }
>
> -static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
> +static int __maybe_unused saa7134_suspend(struct device *dev_d)
> {
> + struct pci_dev *pci_dev = to_pci_dev(dev_d);
> struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
> struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
>
> @@ -1428,21 +1427,15 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
> if (dev->remote && dev->remote->dev->users)
> saa7134_ir_close(dev->remote->dev);
>
> - pci_save_state(pci_dev);
> - pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
> -
> return 0;
> }
>
> -static int saa7134_resume(struct pci_dev *pci_dev)
> +static int __maybe_unused saa7134_resume(struct device *dev_d)
> {
> - struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
> + struct v4l2_device *v4l2_dev = dev_get_drvdata(dev_d);
> struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
> unsigned long flags;
>
> - pci_set_power_state(pci_dev, PCI_D0);
> - pci_restore_state(pci_dev);
> -
> /* Do things that are done in saa7134_initdev ,
> except of initializing memory structures.*/
>
> @@ -1490,7 +1483,6 @@ static int saa7134_resume(struct pci_dev *pci_dev)
>
> return 0;
> }
> -#endif
>
> /* ----------------------------------------------------------- */
>
> @@ -1522,15 +1514,14 @@ EXPORT_SYMBOL(saa7134_ts_unregister);
>
> /* ----------------------------------------------------------- */
>
> +static SIMPLE_DEV_PM_OPS(saa7134_pm_ops, saa7134_suspend, saa7134_resume);
> +
> static struct pci_driver saa7134_pci_driver = {
> .name = "saa7134",
> .id_table = saa7134_pci_tbl,
> .probe = saa7134_initdev,
> .remove = saa7134_finidev,
> -#ifdef CONFIG_PM
> - .suspend = saa7134_suspend,
> - .resume = saa7134_resume
> -#endif
> + .driver.pm = &saa7134_pm_ops,
> };
>
> static int __init saa7134_init(void)
> --
> 2.27.0
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
prev parent reply other threads:[~2020-08-17 7:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 12:02 [Linux-kernel-mentees] [PATCH v1] [media] saa7134: use generic power management Vaibhav Gupta
2020-07-20 10:47 ` Vaibhav Gupta
2020-08-17 7:42 ` Vaibhav Gupta [this message]
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=20200817074229.GB5869@gmail.com \
--to=vaibhavgupta40@gmail.com \
--cc=bhelgaas@google.com \
--cc=bjorn@helgaas.com \
--cc=helgaas@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=vaibhav.varodek@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).