lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1351700455.15558.1571.camel@cliu38-desktop-build>
Date:	Thu, 01 Nov 2012 00:20:55 +0800
From:	Chuansheng Liu <chuansheng.liu@...el.com>
To:	john.stultz@...aro.org, tglx@...utronix.de,
	gregkh@...uxfoundation.org
Cc:	linux-kernel@...r.kernel.org, chuansheng.liu@...el.com
Subject: [PATCH 1/3] alarmtimer: Replace the spinlock rtcdev_lock with mutex


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@...el.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



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ