The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/3] alarmtimer: Replace the spinlock rtcdev_lock with mutex
@ 2012-10-31 16:20 Chuansheng Liu
  2012-10-31  9:03 ` Oliver Neukum
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Chuansheng Liu @ 2012-10-31 16:20 UTC (permalink / raw)
  To: john.stultz, tglx, gregkh; +Cc: linux-kernel, chuansheng.liu


When do code reviewing, found no special requirement to
use spin_lock_irqsave/spin_unlock_irqrestore, because
alarmtimer_get_rtcdev() is called by posix clock interface.
So would like to use mutex to replace it.

Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
---
 kernel/time/alarmtimer.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index f11d83b..4fc17cb 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -51,7 +51,7 @@ static struct wakeup_source *ws;
 /* rtc timer and device for setting alarm wakeups at suspend */
 static struct rtc_timer		rtctimer;
 static struct rtc_device	*rtcdev;
-static DEFINE_SPINLOCK(rtcdev_lock);
+static DEFINE_MUTEX(rtcdev_mutex);
 
 /**
  * alarmtimer_get_rtcdev - Return selected rtcdevice
@@ -62,12 +62,11 @@ static DEFINE_SPINLOCK(rtcdev_lock);
  */
 struct rtc_device *alarmtimer_get_rtcdev(void)
 {
-	unsigned long flags;
 	struct rtc_device *ret;
 
-	spin_lock_irqsave(&rtcdev_lock, flags);
+	mutex_lock(&rtcdev_mutex);
 	ret = rtcdev;
-	spin_unlock_irqrestore(&rtcdev_lock, flags);
+	mutex_unlock(&rtcdev_mutex);
 
 	return ret;
 }
@@ -76,7 +75,6 @@ struct rtc_device *alarmtimer_get_rtcdev(void)
 static int alarmtimer_rtc_add_device(struct device *dev,
 				struct class_interface *class_intf)
 {
-	unsigned long flags;
 	struct rtc_device *rtc = to_rtc_device(dev);
 
 	if (rtcdev)
@@ -87,13 +85,13 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 	if (!device_may_wakeup(rtc->dev.parent))
 		return -1;
 
-	spin_lock_irqsave(&rtcdev_lock, flags);
+	mutex_lock(&rtcdev_mutex);
 	if (!rtcdev) {
 		rtcdev = rtc;
 		/* hold a reference so it doesn't go away */
 		get_device(dev);
 	}
-	spin_unlock_irqrestore(&rtcdev_lock, flags);
+	mutex_unlock(&rtcdev_mutex);
 	return 0;
 }
 
-- 
1.7.0.4




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

end of thread, other threads:[~2012-11-02  6:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31 16:20 [PATCH 1/3] alarmtimer: Replace the spinlock rtcdev_lock with mutex Chuansheng Liu
2012-10-31  9:03 ` Oliver Neukum
2012-11-01  0:02   ` Liu, Chuansheng
2012-11-01 22:43     ` Thomas Gleixner
2012-11-02  3:32       ` Liu, Chuansheng
2012-10-31 16:23 ` [PATCH 2/3] alarmtimer: Using the alarmtimer_get_rtcdev for all posix clock interface Chuansheng Liu
2012-11-01 22:55   ` Thomas Gleixner
2012-11-02  3:41     ` Liu, Chuansheng
2012-11-02  6:10     ` Liu, Chuansheng
2012-10-31 16:25 ` [PATCH 3/3] alarmtimer: cleanup the POSIX clock interface without CONFIG_RTC_CLASS Chuansheng Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox