virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio: pci: Use SIMPLE_DEV_PM_OPS macro
@ 2014-09-05  3:52 Jingoo Han
  2014-09-09  0:13 ` Rusty Russell
  0 siblings, 1 reply; 5+ messages in thread
From: Jingoo Han @ 2014-09-05  3:52 UTC (permalink / raw)
  To: 'Rusty Russell'
  Cc: 'Jingoo Han', virtualization,
	'Michael S. Tsirkin'

Use SIMPLE_DEV_PM_OPS macro in order to make the code simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/virtio/virtio_pci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 3d1463c6b120..c5fbdb4023d1 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -810,20 +810,17 @@ static int virtio_pci_restore(struct device *dev)
 
 	return ret;
 }
-
-static const struct dev_pm_ops virtio_pci_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore)
-};
 #endif
 
+static SIMPLE_DEV_PM_OPS(virtio_pci_pm_ops, virtio_pci_freeze,
+			 virtio_pci_restore);
+
 static struct pci_driver virtio_pci_driver = {
 	.name		= "virtio-pci",
 	.id_table	= virtio_pci_id_table,
 	.probe		= virtio_pci_probe,
 	.remove		= virtio_pci_remove,
-#ifdef CONFIG_PM_SLEEP
 	.driver.pm	= &virtio_pci_pm_ops,
-#endif
 };
 
 module_pci_driver(virtio_pci_driver);
-- 
2.0.0

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

* Re: [PATCH] virtio: pci: Use SIMPLE_DEV_PM_OPS macro
  2014-09-05  3:52 [PATCH] virtio: pci: Use SIMPLE_DEV_PM_OPS macro Jingoo Han
@ 2014-09-09  0:13 ` Rusty Russell
  2014-09-17  9:52   ` Jingoo Han
  0 siblings, 1 reply; 5+ messages in thread
From: Rusty Russell @ 2014-09-09  0:13 UTC (permalink / raw)
  Cc: 'Jingoo Han', virtualization,
	'Michael S. Tsirkin'

Jingoo Han <jg1.han@samsung.com> writes:
> Use SIMPLE_DEV_PM_OPS macro in order to make the code simpler.
>
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>

This patch is obviously wrong.  It won't compile without
CONFIG_PM_SLEEP.

Cheers,
Rusty.

> ---
>  drivers/virtio/virtio_pci.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> index 3d1463c6b120..c5fbdb4023d1 100644
> --- a/drivers/virtio/virtio_pci.c
> +++ b/drivers/virtio/virtio_pci.c
> @@ -810,20 +810,17 @@ static int virtio_pci_restore(struct device *dev)
>  
>  	return ret;
>  }
> -
> -static const struct dev_pm_ops virtio_pci_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore)
> -};
>  #endif
>  
> +static SIMPLE_DEV_PM_OPS(virtio_pci_pm_ops, virtio_pci_freeze,
> +			 virtio_pci_restore);
> +
>  static struct pci_driver virtio_pci_driver = {
>  	.name		= "virtio-pci",
>  	.id_table	= virtio_pci_id_table,
>  	.probe		= virtio_pci_probe,
>  	.remove		= virtio_pci_remove,
> -#ifdef CONFIG_PM_SLEEP
>  	.driver.pm	= &virtio_pci_pm_ops,
> -#endif
>  };
>  
>  module_pci_driver(virtio_pci_driver);
> -- 
> 2.0.0

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

* Re: [PATCH] virtio: pci: Use SIMPLE_DEV_PM_OPS macro
  2014-09-09  0:13 ` Rusty Russell
@ 2014-09-17  9:52   ` Jingoo Han
  2014-09-18  5:23     ` Rusty Russell
  0 siblings, 1 reply; 5+ messages in thread
From: Jingoo Han @ 2014-09-17  9:52 UTC (permalink / raw)
  To: 'Rusty Russell'
  Cc: 'Jingoo Han', virtualization,
	'Michael S. Tsirkin'

On Tuesday, September 09, 2014 9:14 AM, Rusty Russell wrote:
> Jingoo Han <jg1.han@samsung.com> writes:
> > Use SIMPLE_DEV_PM_OPS macro in order to make the code simpler.
> >
> > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> 
> This patch is obviously wrong.  It won't compile without
> CONFIG_PM_SLEEP.

No, there is no compile issue.
When, CONFIG_PM_SLEEP=n, there is no build error.

'SIMPLE_DEV_PM_OPS' macro is defined as follows.

#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
const struct dev_pm_ops name = { \
        SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
}

In addition, 'SET_SYSTEM_SLEEP_PM_OPS' is defined as follows.

#ifdef CONFIG_PM_SLEEP
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
        .suspend = suspend_fn, \
        .resume = resume_fn, \
        .freeze = suspend_fn, \
        .thaw = resume_fn, \
        .poweroff = suspend_fn, \
        .restore = resume_fn,
#else
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
#endif

So, when CONFIG_PM_SLEEP is NOT enabled, SIMPLE_DEV_PM_OPS can be
changed as below. The members of virtio_pci_pm_ops can be NULL.
Thus, there is no build error, when CONFIG_PM_SLEEP=n.

However, if you want, I will just change SET_SYSTEM_SLEEP_PM_OPS
into SIMPLE_DEV_PM_OPS macro, without any change about
'#ifdef CONFIG_PM_SLEEP' guards.

const struct dev_pm_ops virtio_pci_pm_ops = {
};

static struct pci_driver virtio_pci_driver = {
 	.name		= "virtio-pci",
 	.id_table	= virtio_pci_id_table,
 	.probe		= virtio_pci_probe,
 	.remove		= virtio_pci_remove,
 	.driver.pm	= &virtio_pci_pm_ops,
};

Best regards,
Jingoo Han

> 
> Cheers,
> Rusty.
> 
> > ---
> >  drivers/virtio/virtio_pci.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> > index 3d1463c6b120..c5fbdb4023d1 100644
> > --- a/drivers/virtio/virtio_pci.c
> > +++ b/drivers/virtio/virtio_pci.c
> > @@ -810,20 +810,17 @@ static int virtio_pci_restore(struct device *dev)
> >
> >  	return ret;
> >  }
> > -
> > -static const struct dev_pm_ops virtio_pci_pm_ops = {
> > -	SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore)
> > -};
> >  #endif
> >
> > +static SIMPLE_DEV_PM_OPS(virtio_pci_pm_ops, virtio_pci_freeze,
> > +			 virtio_pci_restore);
> > +
> >  static struct pci_driver virtio_pci_driver = {
> >  	.name		= "virtio-pci",
> >  	.id_table	= virtio_pci_id_table,
> >  	.probe		= virtio_pci_probe,
> >  	.remove		= virtio_pci_remove,
> > -#ifdef CONFIG_PM_SLEEP
> >  	.driver.pm	= &virtio_pci_pm_ops,
> > -#endif
> >  };
> >
> >  module_pci_driver(virtio_pci_driver);
> > --
> > 2.0.0

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

* Re: [PATCH] virtio: pci: Use SIMPLE_DEV_PM_OPS macro
  2014-09-17  9:52   ` Jingoo Han
@ 2014-09-18  5:23     ` Rusty Russell
  2014-10-05 15:49       ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Rusty Russell @ 2014-09-18  5:23 UTC (permalink / raw)
  Cc: 'Jingoo Han', virtualization,
	'Michael S. Tsirkin'

Jingoo Han <jg1.han@samsung.com> writes:
> On Tuesday, September 09, 2014 9:14 AM, Rusty Russell wrote:
>> Jingoo Han <jg1.han@samsung.com> writes:
>> > Use SIMPLE_DEV_PM_OPS macro in order to make the code simpler.
>> >
>> > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
>> 
>> This patch is obviously wrong.  It won't compile without
>> CONFIG_PM_SLEEP.
>
> No, there is no compile issue.
> When, CONFIG_PM_SLEEP=n, there is no build error.

My mistake.  Thanks, I've applied it.  It probably won't go in until the
next merge window, however, since I'm travelling for this one.

Cheers,
Rusty.

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

* Re: [PATCH] virtio: pci: Use SIMPLE_DEV_PM_OPS macro
  2014-09-18  5:23     ` Rusty Russell
@ 2014-10-05 15:49       ` Michael S. Tsirkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-10-05 15:49 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Jingoo Han, virtualization

On Thu, Sep 18, 2014 at 02:53:10PM +0930, Rusty Russell wrote:
> Jingoo Han <jg1.han@samsung.com> writes:
> > On Tuesday, September 09, 2014 9:14 AM, Rusty Russell wrote:
> >> Jingoo Han <jg1.han@samsung.com> writes:
> >> > Use SIMPLE_DEV_PM_OPS macro in order to make the code simpler.
> >> >
> >> > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> >> 
> >> This patch is obviously wrong.  It won't compile without
> >> CONFIG_PM_SLEEP.
> >
> > No, there is no compile issue.
> > When, CONFIG_PM_SLEEP=n, there is no build error.
> 
> My mistake.  Thanks, I've applied it.  It probably won't go in until the
> next merge window, however, since I'm travelling for this one.
> 
> Cheers,
> Rusty.

I have some bugfixes that are I think worth merging, so maybe
I'll do a pull request.
If so, this cleanup could go in, on top.

Rusty, what do you say?

-- 
MST

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

end of thread, other threads:[~2014-10-05 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-05  3:52 [PATCH] virtio: pci: Use SIMPLE_DEV_PM_OPS macro Jingoo Han
2014-09-09  0:13 ` Rusty Russell
2014-09-17  9:52   ` Jingoo Han
2014-09-18  5:23     ` Rusty Russell
2014-10-05 15:49       ` Michael S. Tsirkin

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).