clocksource: sh_cmt: Remove nested spinlock fix

There are control flow that sh_cmt_set_next() does double
spin-lock. The callers sh_cmt_{start,stop}() already have
lock. But another callers sh_cmt_clock_event_{start,next}()
does not.

Now sh_cmt_set_next() does not lock by itself. All the
callers should hold spin-lock before calling it.

[damm@opensource.se: use __sh_cmt_set_next() to simplify code]
[damm@opensource.se: added stable, suitable for v2.6.35 + v2.6.36]
Cc: stable@kernel.org
Signed-off-by: Takashi YOSHII <takashi.yoshii.zj@renesas.com>
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by Takashi YOSHII and committed by Paul Mundt 65ada547 b3444d16

+12 -7
+12 -7
drivers/clocksource/sh_cmt.c
··· 283 } while (delay); 284 } 285 286 static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) 287 { 288 unsigned long flags; 289 290 - if (delta > p->max_match_value) 291 - dev_warn(&p->pdev->dev, "delta out of range\n"); 292 - 293 spin_lock_irqsave(&p->lock, flags); 294 - p->next_match_value = delta; 295 - sh_cmt_clock_event_program_verify(p, 0); 296 spin_unlock_irqrestore(&p->lock, flags); 297 } 298 ··· 364 365 /* setup timeout if no clockevent */ 366 if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT))) 367 - sh_cmt_set_next(p, p->max_match_value); 368 out: 369 spin_unlock_irqrestore(&p->lock, flags); 370 ··· 386 387 /* adjust the timeout to maximum if only clocksource left */ 388 if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE)) 389 - sh_cmt_set_next(p, p->max_match_value); 390 391 spin_unlock_irqrestore(&p->lock, flags); 392 }
··· 283 } while (delay); 284 } 285 286 + static void __sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) 287 + { 288 + if (delta > p->max_match_value) 289 + dev_warn(&p->pdev->dev, "delta out of range\n"); 290 + 291 + p->next_match_value = delta; 292 + sh_cmt_clock_event_program_verify(p, 0); 293 + } 294 + 295 static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) 296 { 297 unsigned long flags; 298 299 spin_lock_irqsave(&p->lock, flags); 300 + __sh_cmt_set_next(p, delta); 301 spin_unlock_irqrestore(&p->lock, flags); 302 } 303 ··· 359 360 /* setup timeout if no clockevent */ 361 if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT))) 362 + __sh_cmt_set_next(p, p->max_match_value); 363 out: 364 spin_unlock_irqrestore(&p->lock, flags); 365 ··· 381 382 /* adjust the timeout to maximum if only clocksource left */ 383 if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE)) 384 + __sh_cmt_set_next(p, p->max_match_value); 385 386 spin_unlock_irqrestore(&p->lock, flags); 387 }