linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH v1] [media] saa7134: use generic power management
@ 2020-06-22 12:02 Vaibhav Gupta
  2020-07-20 10:47 ` Vaibhav Gupta
  2020-08-17  7:42 ` Vaibhav Gupta
  0 siblings, 2 replies; 3+ messages in thread
From: Vaibhav Gupta @ 2020-06-22 12:02 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta
  Cc: linux-media, linux-kernel-mentees, linux-kernel, Vaibhav Gupta

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v1] [media] saa7134: use generic power management
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Vaibhav Gupta @ 2020-07-20 10:47 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, Bjorn Helgaas, Vaibhav Gupta,
	Mauro Carvalho Chehab, Hans Verkuil, Hans Verkuil
  Cc: linux-kernel-mentees, Linux Kernel Mailing List, linux-media

On Mon, Jun 22, 2020 at 5:36 PM Vaibhav Gupta <vaibhavgupta40@gmail.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v1] [media] saa7134: use generic power management
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Vaibhav Gupta @ 2020-08-17  7:42 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta
  Cc: linux-kernel-mentees, linux-kernel, linux-media

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-17  7:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).