* [PATCH] PM: Add pm_sleep_ops_ptr() macro
@ 2013-06-03 6:21 Jingoo Han
2013-06-03 11:11 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Jingoo Han @ 2013-06-03 6:21 UTC (permalink / raw)
To: 'Rafael J. Wysocki'
Cc: 'Jean-Christophe PLAGNIOL-VILLARD',
'Lars-Peter Clausen', 'Michael Hennerich',
'Tomi Valkeinen', linux-fbdev, linux-pm,
'Jingoo Han'
Add pm_sleep_ops_ptr() macro that allows the .pm entry in the driver structures
to be assigned without having an #define xxx NULL for the case that PM_SLEEP is
not enabled.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
---
drivers/video/bfin-lq035q1-fb.c | 20 +++++++++++---------
include/linux/pm.h | 6 ++++++
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c
index 29d8c04..4474e64 100644
--- a/drivers/video/bfin-lq035q1-fb.c
+++ b/drivers/video/bfin-lq035q1-fb.c
@@ -170,16 +170,19 @@ static int lq035q1_spidev_remove(struct spi_device *spi)
return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT);
}
-#ifdef CONFIG_PM
-static int lq035q1_spidev_suspend(struct spi_device *spi, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int lq035q1_spidev_suspend(struct device *dev)
{
+ struct spi_device *spi = to_spi_device(dev);
+
return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT);
}
-static int lq035q1_spidev_resume(struct spi_device *spi)
+static int lq035q1_spidev_resume(struct device *dev)
{
- int ret;
+ struct spi_device *spi = to_spi_device(dev);
struct spi_control *ctl = spi_get_drvdata(spi);
+ int ret;
ret = lq035q1_control(spi, LQ035_DRIVER_OUTPUT_CTL, ctl->mode);
if (ret)
@@ -187,11 +190,11 @@ static int lq035q1_spidev_resume(struct spi_device *spi)
return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_ON);
}
-#else
-# define lq035q1_spidev_suspend NULL
-# define lq035q1_spidev_resume NULL
#endif
+static SIMPLE_DEV_PM_OPS(lq035q1_spidev_pm_ops, lq035q1_spidev_suspend,
+ lq035q1_spidev_resume);
+
/* Power down all displays on reboot, poweroff or halt */
static void lq035q1_spidev_shutdown(struct spi_device *spi)
{
@@ -708,8 +711,7 @@ static int bfin_lq035q1_probe(struct platform_device *pdev)
info->spidrv.probe = lq035q1_spidev_probe;
info->spidrv.remove = lq035q1_spidev_remove;
info->spidrv.shutdown = lq035q1_spidev_shutdown;
- info->spidrv.suspend = lq035q1_spidev_suspend;
- info->spidrv.resume = lq035q1_spidev_resume;
+ info->spidrv.driver.pm = pm_sleep_ops_ptr(&lq035q1_spidev_pm_ops);
ret = spi_register_driver(&info->spidrv);
if (ret < 0) {
diff --git a/include/linux/pm.h b/include/linux/pm.h
index bd50d15..999d652 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -61,6 +61,12 @@ extern const char power_group_name[]; /* = "power" */
#define pm_ops_ptr(_ptr) NULL
#endif
+#ifdef CONFIG_PM_SLEEP
+#define pm_sleep_ops_ptr(_ptr) (_ptr)
+#else
+#define pm_sleep_ops_ptr(_ptr) NULL
+#endif
+
typedef struct pm_message {
int event;
} pm_message_t;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: Add pm_sleep_ops_ptr() macro
2013-06-03 6:21 [PATCH] PM: Add pm_sleep_ops_ptr() macro Jingoo Han
@ 2013-06-03 11:11 ` Rafael J. Wysocki
2013-06-03 19:54 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2013-06-03 11:11 UTC (permalink / raw)
To: Jingoo Han
Cc: 'Jean-Christophe PLAGNIOL-VILLARD',
'Lars-Peter Clausen', 'Michael Hennerich',
'Tomi Valkeinen', linux-fbdev, linux-pm
On Monday, June 03, 2013 03:21:51 PM Jingoo Han wrote:
> Add pm_sleep_ops_ptr() macro that allows the .pm entry in the driver structures
> to be assigned without having an #define xxx NULL for the case that PM_SLEEP is
> not enabled.
>
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Michael Hennerich <michael.hennerich@analog.com>
Do you want me to replace the previous patch with this?
Rafael
> ---
> drivers/video/bfin-lq035q1-fb.c | 20 +++++++++++---------
> include/linux/pm.h | 6 ++++++
> 2 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c
> index 29d8c04..4474e64 100644
> --- a/drivers/video/bfin-lq035q1-fb.c
> +++ b/drivers/video/bfin-lq035q1-fb.c
> @@ -170,16 +170,19 @@ static int lq035q1_spidev_remove(struct spi_device *spi)
> return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT);
> }
>
> -#ifdef CONFIG_PM
> -static int lq035q1_spidev_suspend(struct spi_device *spi, pm_message_t state)
> +#ifdef CONFIG_PM_SLEEP
> +static int lq035q1_spidev_suspend(struct device *dev)
> {
> + struct spi_device *spi = to_spi_device(dev);
> +
> return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT);
> }
>
> -static int lq035q1_spidev_resume(struct spi_device *spi)
> +static int lq035q1_spidev_resume(struct device *dev)
> {
> - int ret;
> + struct spi_device *spi = to_spi_device(dev);
> struct spi_control *ctl = spi_get_drvdata(spi);
> + int ret;
>
> ret = lq035q1_control(spi, LQ035_DRIVER_OUTPUT_CTL, ctl->mode);
> if (ret)
> @@ -187,11 +190,11 @@ static int lq035q1_spidev_resume(struct spi_device *spi)
>
> return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_ON);
> }
> -#else
> -# define lq035q1_spidev_suspend NULL
> -# define lq035q1_spidev_resume NULL
> #endif
>
> +static SIMPLE_DEV_PM_OPS(lq035q1_spidev_pm_ops, lq035q1_spidev_suspend,
> + lq035q1_spidev_resume);
> +
> /* Power down all displays on reboot, poweroff or halt */
> static void lq035q1_spidev_shutdown(struct spi_device *spi)
> {
> @@ -708,8 +711,7 @@ static int bfin_lq035q1_probe(struct platform_device *pdev)
> info->spidrv.probe = lq035q1_spidev_probe;
> info->spidrv.remove = lq035q1_spidev_remove;
> info->spidrv.shutdown = lq035q1_spidev_shutdown;
> - info->spidrv.suspend = lq035q1_spidev_suspend;
> - info->spidrv.resume = lq035q1_spidev_resume;
> + info->spidrv.driver.pm = pm_sleep_ops_ptr(&lq035q1_spidev_pm_ops);
>
> ret = spi_register_driver(&info->spidrv);
> if (ret < 0) {
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index bd50d15..999d652 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -61,6 +61,12 @@ extern const char power_group_name[]; /* = "power" */
> #define pm_ops_ptr(_ptr) NULL
> #endif
>
> +#ifdef CONFIG_PM_SLEEP
> +#define pm_sleep_ops_ptr(_ptr) (_ptr)
> +#else
> +#define pm_sleep_ops_ptr(_ptr) NULL
> +#endif
> +
> typedef struct pm_message {
> int event;
> } pm_message_t;
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: Add pm_sleep_ops_ptr() macro
2013-06-03 11:11 ` Rafael J. Wysocki
@ 2013-06-03 19:54 ` Rafael J. Wysocki
2013-06-04 4:23 ` Jingoo Han
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2013-06-03 19:54 UTC (permalink / raw)
To: Jingoo Han
Cc: 'Jean-Christophe PLAGNIOL-VILLARD',
'Lars-Peter Clausen', 'Michael Hennerich',
'Tomi Valkeinen', linux-fbdev, linux-pm
On Monday, June 03, 2013 01:11:07 PM Rafael J. Wysocki wrote:
> On Monday, June 03, 2013 03:21:51 PM Jingoo Han wrote:
> > Add pm_sleep_ops_ptr() macro that allows the .pm entry in the driver structures
> > to be assigned without having an #define xxx NULL for the case that PM_SLEEP is
> > not enabled.
> >
> > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> > Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > Cc: Lars-Peter Clausen <lars@metafoo.de>
> > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> > Cc: Michael Hennerich <michael.hennerich@analog.com>
>
> Do you want me to replace the previous patch with this?
Quite frankly, I prefer the previous version, which was more general.
That is, what if someone wants to use that macro for runtime PM too?
Honestly, I think we'll be better off without any of them, so I'm dropping
the previous patch too for now.
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: Add pm_sleep_ops_ptr() macro
2013-06-03 19:54 ` Rafael J. Wysocki
@ 2013-06-04 4:23 ` Jingoo Han
0 siblings, 0 replies; 4+ messages in thread
From: Jingoo Han @ 2013-06-04 4:23 UTC (permalink / raw)
To: 'Rafael J. Wysocki'
Cc: 'Jean-Christophe PLAGNIOL-VILLARD',
'Lars-Peter Clausen', 'Michael Hennerich',
'Tomi Valkeinen', linux-fbdev, linux-pm, Jingoo Han
On Tuesday, June 04, 2013 4:55 AM, Rafael J. Wysocki wrote:
> On Monday, June 03, 2013 01:11:07 PM Rafael J. Wysocki wrote:
> > On Monday, June 03, 2013 03:21:51 PM Jingoo Han wrote:
> > > Add pm_sleep_ops_ptr() macro that allows the .pm entry in the driver structures
> > > to be assigned without having an #define xxx NULL for the case that PM_SLEEP is
> > > not enabled.
> > >
> > > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> > > Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > > Cc: Lars-Peter Clausen <lars@metafoo.de>
> > > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> > > Cc: Michael Hennerich <michael.hennerich@analog.com>
> >
> > Do you want me to replace the previous patch with this?
>
> Quite frankly, I prefer the previous version, which was more general.
>
> That is, what if someone wants to use that macro for runtime PM too?
>
> Honestly, I think we'll be better off without any of them, so I'm dropping
> the previous patch too for now.
OK, I see.
I agree with your opinion.
Also, as I mentioned, I want other's better ideas.
Best regards,
Jingoo Han
>
> Thanks,
> Rafael
>
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-04 4:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03 6:21 [PATCH] PM: Add pm_sleep_ops_ptr() macro Jingoo Han
2013-06-03 11:11 ` Rafael J. Wysocki
2013-06-03 19:54 ` Rafael J. Wysocki
2013-06-04 4:23 ` Jingoo Han
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).