556 cycles_t last_time; |
556 cycles_t last_time; |
557 long last_delta, last_delta2; |
557 long last_delta, last_delta2; |
558 unsigned dont_count_entropy:1; |
558 unsigned dont_count_entropy:1; |
559 }; |
559 }; |
560 |
560 |
|
561 #ifndef CONFIG_SPARSE_IRQ |
|
562 |
561 static struct timer_rand_state *irq_timer_state[NR_IRQS]; |
563 static struct timer_rand_state *irq_timer_state[NR_IRQS]; |
562 |
564 |
563 static struct timer_rand_state *get_timer_rand_state(unsigned int irq) |
565 static struct timer_rand_state *get_timer_rand_state(unsigned int irq) |
564 { |
566 { |
565 if (irq >= nr_irqs) |
|
566 return NULL; |
|
567 |
|
568 return irq_timer_state[irq]; |
567 return irq_timer_state[irq]; |
569 } |
568 } |
570 |
569 |
571 static void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state) |
570 static void set_timer_rand_state(unsigned int irq, |
572 { |
571 struct timer_rand_state *state) |
573 if (irq >= nr_irqs) |
572 { |
574 return; |
|
575 |
|
576 irq_timer_state[irq] = state; |
573 irq_timer_state[irq] = state; |
577 } |
574 } |
|
575 |
|
576 #else |
|
577 |
|
578 static struct timer_rand_state *get_timer_rand_state(unsigned int irq) |
|
579 { |
|
580 struct irq_desc *desc; |
|
581 |
|
582 desc = irq_to_desc(irq); |
|
583 |
|
584 return desc->timer_rand_state; |
|
585 } |
|
586 |
|
587 static void set_timer_rand_state(unsigned int irq, |
|
588 struct timer_rand_state *state) |
|
589 { |
|
590 struct irq_desc *desc; |
|
591 |
|
592 desc = irq_to_desc(irq); |
|
593 |
|
594 desc->timer_rand_state = state; |
|
595 } |
|
596 #endif |
578 |
597 |
579 static struct timer_rand_state input_timer_state; |
598 static struct timer_rand_state input_timer_state; |
580 |
599 |
581 /* |
600 /* |
582 * This function adds entropy to the entropy "pool" by using timing |
601 * This function adds entropy to the entropy "pool" by using timing |
745 |
764 |
746 static size_t account(struct entropy_store *r, size_t nbytes, int min, |
765 static size_t account(struct entropy_store *r, size_t nbytes, int min, |
747 int reserved) |
766 int reserved) |
748 { |
767 { |
749 unsigned long flags; |
768 unsigned long flags; |
750 |
|
751 BUG_ON(r->entropy_count > r->poolinfo->POOLBITS); |
|
752 #ifdef CONFIG_NSC |
769 #ifdef CONFIG_NSC |
753 /* |
770 /* |
754 * prevent infinite loop: if a code path calls get_random_bytes |
771 * prevent infinite loop: if a code path calls get_random_bytes |
755 * and we've run out of entropy, this calls wake_up_interruptible(), |
772 * and we've run out of entropy, this calls wake_up_interruptible(), |
756 * which calls the code path again, which calls get_random_bytes, |
773 * which calls the code path again, which calls get_random_bytes, |
759 return nbytes; |
776 return nbytes; |
760 #endif |
777 #endif |
761 /* Hold lock while accounting */ |
778 /* Hold lock while accounting */ |
762 spin_lock_irqsave(&r->lock, flags); |
779 spin_lock_irqsave(&r->lock, flags); |
763 |
780 |
|
781 BUG_ON(r->entropy_count > r->poolinfo->POOLBITS); |
764 DEBUG_ENT("trying to extract %d bits from %s\n", |
782 DEBUG_ENT("trying to extract %d bits from %s\n", |
765 nbytes * 8, r->name); |
783 nbytes * 8, r->name); |
766 |
784 |
767 /* Can we pull enough? */ |
785 /* Can we pull enough? */ |
768 if (r->entropy_count / 8 < min + reserved) { |
786 if (r->entropy_count / 8 < min + reserved) { |