aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/vtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/kernel/vtime.c')
-rw-r--r--arch/s390/kernel/vtime.c56
1 files changed, 12 insertions, 44 deletions
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index eb08d04bc1ec..0fa5dc5d68e1 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -318,8 +318,7 @@ static void internal_add_vtimer(struct vtimer_list *timer)
318 vt_list = &per_cpu(virt_cpu_timer, timer->cpu); 318 vt_list = &per_cpu(virt_cpu_timer, timer->cpu);
319 spin_lock_irqsave(&vt_list->lock, flags); 319 spin_lock_irqsave(&vt_list->lock, flags);
320 320
321 if (timer->cpu != smp_processor_id()) 321 BUG_ON(timer->cpu != smp_processor_id());
322 printk("internal_add_vtimer: BUG, running on wrong CPU");
323 322
324 /* if list is empty we only have to set the timer */ 323 /* if list is empty we only have to set the timer */
325 if (list_empty(&vt_list->list)) { 324 if (list_empty(&vt_list->list)) {
@@ -353,25 +352,12 @@ static void internal_add_vtimer(struct vtimer_list *timer)
353 put_cpu(); 352 put_cpu();
354} 353}
355 354
356static inline int prepare_vtimer(struct vtimer_list *timer) 355static inline void prepare_vtimer(struct vtimer_list *timer)
357{ 356{
358 if (!timer->function) { 357 BUG_ON(!timer->function);
359 printk("add_virt_timer: uninitialized timer\n"); 358 BUG_ON(!timer->expires || timer->expires > VTIMER_MAX_SLICE);
360 return -EINVAL; 359 BUG_ON(vtimer_pending(timer));
361 }
362
363 if (!timer->expires || timer->expires > VTIMER_MAX_SLICE) {
364 printk("add_virt_timer: invalid timer expire value!\n");
365 return -EINVAL;
366 }
367
368 if (vtimer_pending(timer)) {
369 printk("add_virt_timer: timer pending\n");
370 return -EBUSY;
371 }
372
373 timer->cpu = get_cpu(); 360 timer->cpu = get_cpu();
374 return 0;
375} 361}
376 362
377/* 363/*
@@ -382,10 +368,7 @@ void add_virt_timer(void *new)
382 struct vtimer_list *timer; 368 struct vtimer_list *timer;
383 369
384 timer = (struct vtimer_list *)new; 370 timer = (struct vtimer_list *)new;
385 371 prepare_vtimer(timer);
386 if (prepare_vtimer(timer) < 0)
387 return;
388
389 timer->interval = 0; 372 timer->interval = 0;
390 internal_add_vtimer(timer); 373 internal_add_vtimer(timer);
391} 374}
@@ -399,10 +382,7 @@ void add_virt_timer_periodic(void *new)
399 struct vtimer_list *timer; 382 struct vtimer_list *timer;
400 383
401 timer = (struct vtimer_list *)new; 384 timer = (struct vtimer_list *)new;
402 385 prepare_vtimer(timer);
403 if (prepare_vtimer(timer) < 0)
404 return;
405
406 timer->interval = timer->expires; 386 timer->interval = timer->expires;
407 internal_add_vtimer(timer); 387 internal_add_vtimer(timer);
408} 388}
@@ -423,15 +403,8 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
423 unsigned long flags; 403 unsigned long flags;
424 int cpu; 404 int cpu;
425 405
426 if (!timer->function) { 406 BUG_ON(!timer->function);
427 printk("mod_virt_timer: uninitialized timer\n"); 407 BUG_ON(!expires || expires > VTIMER_MAX_SLICE);
428 return -EINVAL;
429 }
430
431 if (!expires || expires > VTIMER_MAX_SLICE) {
432 printk("mod_virt_timer: invalid expire range\n");
433 return -EINVAL;
434 }
435 408
436 /* 409 /*
437 * This is a common optimization triggered by the 410 * This is a common optimization triggered by the
@@ -444,6 +417,9 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
444 cpu = get_cpu(); 417 cpu = get_cpu();
445 vt_list = &per_cpu(virt_cpu_timer, cpu); 418 vt_list = &per_cpu(virt_cpu_timer, cpu);
446 419
420 /* check if we run on the right CPU */
421 BUG_ON(timer->cpu != cpu);
422
447 /* disable interrupts before test if timer is pending */ 423 /* disable interrupts before test if timer is pending */
448 spin_lock_irqsave(&vt_list->lock, flags); 424 spin_lock_irqsave(&vt_list->lock, flags);
449 425
@@ -458,14 +434,6 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
458 return 0; 434 return 0;
459 } 435 }
460 436
461 /* check if we run on the right CPU */
462 if (timer->cpu != cpu) {
463 printk("mod_virt_timer: running on wrong CPU, check your code\n");
464 spin_unlock_irqrestore(&vt_list->lock, flags);
465 put_cpu();
466 return -EINVAL;
467 }
468
469 list_del_init(&timer->entry); 437 list_del_init(&timer->entry);
470 timer->expires = expires; 438 timer->expires = expires;
471 439