Skip to content

Commit

Permalink
rtc: s3c: fix disabled clocks for alarm
Browse files Browse the repository at this point in the history
The clock enable/disable codes for alarm have been removed from
commit 24e1455 ("drivers/rtc/rtc-s3c.c: delete duplicate clock
control") and the clocks are disabled even if alarm is set, so alarm
interrupt can't happen.

The s3c_rtc_setaie function can be called several times with 'enabled'
argument having same value, so it needs to check whether clocks are
enabled or not.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: <stable@vger.kernel.org> # v4.1
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
  • Loading branch information
Joonyoung Shim authored and Alexandre Belloni committed Sep 5, 2015
1 parent 80e274e commit 1fb1c35
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions drivers/rtc/rtc-s3c.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct s3c_rtc {
void __iomem *base;
struct clk *rtc_clk;
struct clk *rtc_src_clk;
bool clk_disabled;

struct s3c_rtc_data *data;

Expand Down Expand Up @@ -71,9 +72,12 @@ static void s3c_rtc_enable_clk(struct s3c_rtc *info)
unsigned long irq_flags;

spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
clk_enable(info->rtc_clk);
if (info->data->needs_src_clk)
clk_enable(info->rtc_src_clk);
if (info->clk_disabled) {
clk_enable(info->rtc_clk);
if (info->data->needs_src_clk)
clk_enable(info->rtc_src_clk);
info->clk_disabled = false;
}
spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags);
}

Expand All @@ -82,9 +86,12 @@ static void s3c_rtc_disable_clk(struct s3c_rtc *info)
unsigned long irq_flags;

spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
if (info->data->needs_src_clk)
clk_disable(info->rtc_src_clk);
clk_disable(info->rtc_clk);
if (!info->clk_disabled) {
if (info->data->needs_src_clk)
clk_disable(info->rtc_src_clk);
clk_disable(info->rtc_clk);
info->clk_disabled = true;
}
spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags);
}

Expand Down Expand Up @@ -128,6 +135,11 @@ static int s3c_rtc_setaie(struct device *dev, unsigned int enabled)

s3c_rtc_disable_clk(info);

if (enabled)
s3c_rtc_enable_clk(info);
else
s3c_rtc_disable_clk(info);

return 0;
}

Expand Down

0 comments on commit 1fb1c35

Please sign in to comment.