linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: tmp102: add hibernation callbacks
@ 2015-02-02 17:14 grygorii.strashko
  2015-02-02 17:23 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: grygorii.strashko @ 2015-02-02 17:14 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, lm-sensors
  Cc: sumit.semwal, linux-arm-kernel, linux-kernel, linux-pm,
	Grygorii Strashko

From: Grygorii Strashko <Grygorii.Strashko@linaro.org>

Setting a dev_pm_ops suspend/resume pair but not a set of
hibernation functions means those pm functions will not be
called upon hibernation.
Fix this by using SIMPLE_DEV_PM_OPS, which appropriately
assigns the suspend and hibernation handlers.

Signed-off-by: Grygorii Strashko <Grygorii.Strashko@linaro.org>
---
 drivers/hwmon/tmp102.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 6748b45..4f790f5 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -281,17 +281,10 @@ static int tmp102_resume(struct device *dev)
 	config &= ~TMP102_CONF_SD;
 	return i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, config);
 }
-
-static const struct dev_pm_ops tmp102_dev_pm_ops = {
-	.suspend	= tmp102_suspend,
-	.resume		= tmp102_resume,
-};
-
-#define TMP102_DEV_PM_OPS (&tmp102_dev_pm_ops)
-#else
-#define	TMP102_DEV_PM_OPS NULL
 #endif /* CONFIG_PM */
 
+SIMPLE_DEV_PM_OPS(tmp102_dev_pm_ops, tmp102_suspend, tmp102_resume);
+
 static const struct i2c_device_id tmp102_id[] = {
 	{ "tmp102", 0 },
 	{ }
@@ -300,7 +293,7 @@ MODULE_DEVICE_TABLE(i2c, tmp102_id);
 
 static struct i2c_driver tmp102_driver = {
 	.driver.name	= DRIVER_NAME,
-	.driver.pm	= TMP102_DEV_PM_OPS,
+	.driver.pm	= &tmp102_dev_pm_ops,
 	.probe		= tmp102_probe,
 	.remove		= tmp102_remove,
 	.id_table	= tmp102_id,
-- 
1.9.1


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

* Re: [PATCH] hwmon: tmp102: add hibernation callbacks
  2015-02-02 17:14 [PATCH] hwmon: tmp102: add hibernation callbacks grygorii.strashko
@ 2015-02-02 17:23 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2015-02-02 17:23 UTC (permalink / raw)
  To: grygorii.strashko
  Cc: Jean Delvare, lm-sensors, sumit.semwal, linux-arm-kernel,
	linux-kernel, linux-pm

On Mon, Feb 02, 2015 at 07:14:31PM +0200, grygorii.strashko@linaro.org wrote:
> From: Grygorii Strashko <Grygorii.Strashko@linaro.org>
> 
> Setting a dev_pm_ops suspend/resume pair but not a set of
> hibernation functions means those pm functions will not be
> called upon hibernation.
> Fix this by using SIMPLE_DEV_PM_OPS, which appropriately
> assigns the suspend and hibernation handlers.
> 
> Signed-off-by: Grygorii Strashko <Grygorii.Strashko@linaro.org>
> ---
>  drivers/hwmon/tmp102.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
> index 6748b45..4f790f5 100644
> --- a/drivers/hwmon/tmp102.c
> +++ b/drivers/hwmon/tmp102.c
> @@ -281,17 +281,10 @@ static int tmp102_resume(struct device *dev)
>  	config &= ~TMP102_CONF_SD;
>  	return i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, config);
>  }
> -
> -static const struct dev_pm_ops tmp102_dev_pm_ops = {
> -	.suspend	= tmp102_suspend,
> -	.resume		= tmp102_resume,
> -};
> -
> -#define TMP102_DEV_PM_OPS (&tmp102_dev_pm_ops)
> -#else
> -#define	TMP102_DEV_PM_OPS NULL
>  #endif /* CONFIG_PM */
>  
> +SIMPLE_DEV_PM_OPS(tmp102_dev_pm_ops, tmp102_suspend, tmp102_resume);
> +

SIMPLE_DEV_PM_OPS is defined in the context of CONFIG_PM_SLEEP,
while tmp102_suspend and tmp102_resume above are defined in the
context of CONFIG_PM. This will result in situations where the
functions are defined but not used, resulting in build warnings.

Please change the condition in the driver to #ifdef CONFIG_PM_SLEEP
to avoid this problem.

Thanks,
Guenter

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

end of thread, other threads:[~2015-02-02 17:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 17:14 [PATCH] hwmon: tmp102: add hibernation callbacks grygorii.strashko
2015-02-02 17:23 ` Guenter Roeck

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