From: Chuansheng Liu <chuansheng.liu@intel.com>
To: john.stultz@linaro.org, tglx@linutronix.de, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, chuansheng.liu@intel.com
Subject: [PATCH 1/3] alarmtimer: Replace the spinlock rtcdev_lock with mutex
Date: Thu, 01 Nov 2012 00:20:55 +0800 [thread overview]
Message-ID: <1351700455.15558.1571.camel@cliu38-desktop-build> (raw)
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
next reply other threads:[~2012-10-31 7:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 16:20 Chuansheng Liu [this message]
2012-10-31 9:03 ` [PATCH 1/3] alarmtimer: Replace the spinlock rtcdev_lock with mutex 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351700455.15558.1571.camel@cliu38-desktop-build \
--to=chuansheng.liu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox