Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1613472
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3/9] clocksource: em_sti: Split clock prepare and enable steps |
| Date | 2017-03-30 23:10 +0200 |
| Message-ID | <tqPuq-3KZ-19@gated-at.bofh.it> (permalink) |
| References | <tqPup-3KZ-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Nicolai Stange <nicstange@gmail.com>
Currently, the em_sti driver prepares and enables the needed clock in
em_sti_enable(), potentially called through its clockevent device's
->set_state_oneshot().
However, the clk_prepare() step may sleep whereas tick_program_event() and
thus, ->set_state_oneshot(), can be called in atomic context.
Split the clk_prepare_enable() in em_sti_enable() into two steps:
- prepare the clock at device probing via clk_prepare()
- and enable it in em_sti_enable() via clk_enable().
Slightly reorder resource initialization in em_sti_probe() in order to
facilitate error handling in later patches.
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
drivers/clocksource/em_sti.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
index aff87df..6c0955a 100644
--- a/drivers/clocksource/em_sti.c
+++ b/drivers/clocksource/em_sti.c
@@ -78,7 +78,7 @@ static int em_sti_enable(struct em_sti_priv *p)
int ret;
/* enable clock */
- ret = clk_prepare_enable(p->clk);
+ ret = clk_enable(p->clk);
if (ret) {
dev_err(&p->pdev->dev, "cannot enable clock\n");
return ret;
@@ -107,7 +107,7 @@ static void em_sti_disable(struct em_sti_priv *p)
em_sti_write(p, STI_INTENCLR, 3);
/* stop clock */
- clk_disable_unprepare(p->clk);
+ clk_disable(p->clk);
}
static u64 em_sti_count(struct em_sti_priv *p)
@@ -303,6 +303,7 @@ static int em_sti_probe(struct platform_device *pdev)
struct em_sti_priv *p;
struct resource *res;
int irq;
+ int ret;
p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
if (p == NULL)
@@ -323,6 +324,13 @@ static int em_sti_probe(struct platform_device *pdev)
if (IS_ERR(p->base))
return PTR_ERR(p->base);
+ if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+ IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+ dev_name(&pdev->dev), p)) {
+ dev_err(&pdev->dev, "failed to request low IRQ\n");
+ return -ENOENT;
+ }
+
/* get hold of clock */
p->clk = devm_clk_get(&pdev->dev, "sclk");
if (IS_ERR(p->clk)) {
@@ -330,11 +338,10 @@ static int em_sti_probe(struct platform_device *pdev)
return PTR_ERR(p->clk);
}
- if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
- IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
- dev_name(&pdev->dev), p)) {
- dev_err(&pdev->dev, "failed to request low IRQ\n");
- return -ENOENT;
+ ret = clk_prepare(p->clk);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "cannot prepare clock\n");
+ return ret;
}
raw_spin_lock_init(&p->lock);
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL][PATCH 0/9] Timekeeping changes for 4.12 John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 5/9] clocksource: h8300_timer8: Don't reset rate in ->set_state_oneshot() John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 3/9] clocksource: em_sti: Split clock prepare and enable steps John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 9/9] sysrq: Reset the watchdog timers while displaying high-resolution timers John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 7/9] MAINTAINERS: Add Stephen Boyd as timekeeping reviewer John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 8/9] timers, sched_clock: Update timeout for clock wrap John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 2/9] clocksource: sh_tmu: Compute rate before registration again John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 4/9] clocksource: em_sti: Compute rate before registration John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 1/9] clocksource: sh_cmt: Compute rate before registration again John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200 [PATCH 6/9] clockevents: Make clockevents_config() static John Stultz <john.stultz@linaro.org> - 2017-03-30 23:10 +0200
csiph-web