Skip to contentSkip to conversation

drivers/rtc/class: convert from Legacy pm ops to dev_pm_ops

PATCH In review Jingoo Han 2 participants 2 messages Jun 7, 2013 – Jun 10, 2013 Real time clock (RTC)

lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH v2 1/1 drivers/rtc/class: convert from Legacy pm ops to dev_pm_ops

From: Shuah Khan <[email protected]>

Convert drivers/rtc/class to use dev_pm_ops for power management and remove Legacy PM ops hooks. With this change, rtc class registers suspend/resume callbacks via class->pm (dev_pm_ops) instead of Legacy class->suspend/resume. When __device_suspend() runs call-backs, it will find class->pm ops for the rtc class.

Cc Shuah Khan <[email protected]>
Cc Alessandro Zummo <[email protected]>

---
Changes since v1:
- Added 'RTC_CLASS_DEV_PM_OPS' to fix buill errors.
- Replaced '#if defined(CONFIG_PM)' with '#if defined(CONFIG_PM_SLEEP)'.

 drivers/rtc/class.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/rtc/class.c +6 -6
index 6638540..0242681 100644
@@ -38,7 +38,7 @@ static void rtc_device_release(struct device *dev)
 int rtc_hctosys_ret = -ENODEV;
 #endif
 
-#if defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
+#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
 /*
  * On suspend(), measure the delta between one RTC and the
  * system's wall clock; restore it on resume().
@@ -47,7 +47,7 @@ int rtc_hctosys_ret = -ENODEV;
 static struct timespec old_rtc, old_system, old_delta;
 
 
-static int rtc_suspend(struct device *dev, pm_message_t mesg)
+static int rtc_suspend(struct device *dev)
 {
 	struct rtc_device	*rtc = to_rtc_device(dev);
 	struct rtc_time		tm;
@@ -135,9 +135,10 @@ static int rtc_resume(struct device *dev)
 	return 0;
 }
 
+static SIMPLE_DEV_PM_OPS(rtc_class_dev_pm_ops, rtc_suspend, rtc_resume);
+#define RTC_CLASS_DEV_PM_OPS	(&rtc_class_dev_pm_ops)
 #else
-#define rtc_suspend	NULL
-#define rtc_resume	NULL
+#define RTC_CLASS_DEV_PM_OPS	NULL
 #endif
 
 
@@ -336,8 +337,7 @@ static int __init rtc_init(void)
 		pr_err("couldn't create class\n");
 		return PTR_ERR(rtc_class);
 	}
-	rtc_class->suspend = rtc_suspend;
-	rtc_class->resume = rtc_resume;
+	rtc_class->pm = RTC_CLASS_DEV_PM_OPS;
 	rtc_dev_init();
 	rtc_sysfs_init(rtc_class);
 	return 0;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 57 lines · Jingoo Han

From: Shuah Khan <[email protected]>

Convert drivers/rtc/class to use dev_pm_ops for power management and remove Legacy PM ops hooks. With this change, rtc class registers suspend/resume callbacks via class->pm (dev_pm_ops) instead of Legacy class->suspend/resume. When __device_suspend() runs call-backs, it will find class->pm ops for the rtc class.

Cc Shuah Khan <[email protected]>
Cc Alessandro Zummo <[email protected]>

---
Changes since v1:
- Added 'RTC_CLASS_DEV_PM_OPS' to fix buill errors.
- Replaced '#if defined(CONFIG_PM)' with '#if defined(CONFIG_PM_SLEEP)'.

  drivers/rtc/class.c |   12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
drivers/rtc/class.c +5 -4
index 6638540..0242681 100644
@@ -38,7 +38,7 @@ static void rtc_device_release(struct device *dev)
  int rtc_hctosys_ret = -ENODEV;
  #endif
 
-#if defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
+#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
  /*
   * On suspend(), measure the delta between one RTC and the
   * system's wall clock; restore it on resume().
@@ -47,7 +47,7 @@ int rtc_hctosys_ret = -ENODEV;
  static struct timespec old_rtc, old_system, old_delta;
 
 
-static int rtc_suspend(struct device *dev, pm_message_t mesg)
+static int rtc_suspend(struct device *dev)
  {
  	struct rtc_device	*rtc = to_rtc_device(dev);
  	struct rtc_time		tm;
@@ -135,9 +135,10 @@ static int rtc_resume(struct device *dev)
  	return 0;
  }
 
+static SIMPLE_DEV_PM_OPS(rtc_class_dev_pm_ops, rtc_suspend, rtc_resume);
+#define RTC_CLASS_DEV_PM_OPS	(&rtc_class_dev_pm_ops)
  #else
-#define rtc_suspend	NULL
-#define rtc_resume	NULL
+#define RTC_CLASS_DEV_PM_OPS	NULL
  #endif
 
 

drivers/rtc/class.c static int __init rtc_init(void) · line 343

Quoted 9 lines
drivers/rtc/class.c +1 -2
@@ -336,8 +337,7 @@ static int __init rtc_init(void)
  		pr_err("couldn't create class\n");
  		return PTR_ERR(rtc_class);
  	}
-	rtc_class->suspend = rtc_suspend;
-	rtc_class->resume = rtc_resume;
+	rtc_class->pm = RTC_CLASS_DEV_PM_OPS;
  	rtc_dev_init();
  	rtc_sysfs_init(rtc_class);
  	return 0;

Looks good. Thanks for fixing the problem. My apologies for introducing the warnings. I had CONFIG_PM and CONFIG_PM_SLEEP both enabled and didn't see this warning. I will be careful with subsequent patches in this area.

-- Shuah

Shuah Khan, Linux Kernel Developer - Open Source Group Samsung Research America (Silicon Valley) [email protected] | (970) 672-0658