Patchwork Re: [PATCH] rtc: rtc-s3c: fix no occurrence of alarm interrupt

login
register
mail settings
Submitter Andrew Morton
Date Sept. 8, 2011, 11:52 p.m.
Message ID <20110908165247.32902b28.akpm@linux-foundation.org>
Download mbox | patch
Permalink /patch/114003/
State New
Headers show

Comments

Andrew Morton - Sept. 8, 2011, 11:52 p.m.
On Wed, 31 Aug 2011 19:21:50 +0900
Donggeun Kim <dg77.kim@samsung.com> wrote:

> The driver does not generate alarm interrupt
> even though time for alarm is set.
> This results from disabling rtc_clk after setting time for alarm.
> To generate alarm interrupt,
> the driver should maintain enabled state for rtc_clk
> until alarm interrupt occurs.
> This patch allows to generate alarm interrupt.
> 
> ...
>
> +static DEFINE_SPINLOCK(s3c_rtc_alarm_clk_lock);
> +
> +static void s3c_rtc_alarm_clk_enable(bool enable)
> +{
> +	static bool alarm_clk_enabled;
> +	unsigned long irq_flags;
> +
> +	spin_lock_irqsave(&s3c_rtc_alarm_clk_lock, irq_flags);
> +	if (enable) {
> +		if (!alarm_clk_enabled) {
> +			clk_enable(rtc_clk);
> +			alarm_clk_enabled = true;
> +		}
> +	} else {
> +		if (alarm_clk_enabled) {
> +			clk_disable(rtc_clk);
> +			alarm_clk_enabled = false;
> +		}
> +	}
> +	spin_unlock_irqrestore(&s3c_rtc_alarm_clk_lock, irq_flags);
> +}

s3c_rtc_alarm_clk_lock is only used within s3c_rtc_alarm_clk_enable(),
so we can reduce its scope:

Patch

--- a/drivers/rtc/rtc-s3c.c~rtc-rtc-s3c-fix-no-occurrence-of-alarm-interrupt-fix
+++ a/drivers/rtc/rtc-s3c.c
@@ -50,10 +50,10 @@  static bool wake_en;
 static enum s3c_cpu_type s3c_rtc_cpu_type;
 
 static DEFINE_SPINLOCK(s3c_rtc_pie_lock);
-static DEFINE_SPINLOCK(s3c_rtc_alarm_clk_lock);
 
 static void s3c_rtc_alarm_clk_enable(bool enable)
 {
+	static DEFINE_SPINLOCK(s3c_rtc_alarm_clk_lock);
 	static bool alarm_clk_enabled;
 	unsigned long irq_flags;