aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-08-19 23:50:08 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-16 10:52:31 -0400
commit3060d6fe28570640c2d7d66d38b9eaa848c3b9e3 (patch)
tree838027c0f8ac336d82b606ba9a61e02453a6de68 /drivers
parente5a53714acfc7b5f868d07d27c5f02cb00b118db (diff)
x86: put timer_rand_state pointer into irq_desc
irq_timer_state[] is a NR_IRQS sized array that is a side-by array to the real irq_desc[] array. Integrate that field into the (now dynamic) irq_desc dynamic array and save some RAM. v2: keep the old way to support arch not support irq_desc Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/random.c66
1 files changed, 61 insertions, 5 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 1610aa64c7cf..60c9c7ee6b2c 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -558,7 +558,7 @@ struct timer_rand_state {
558 unsigned dont_count_entropy:1; 558 unsigned dont_count_entropy:1;
559}; 559};
560 560
561static struct timer_rand_state input_timer_state; 561#ifndef CONFIG_HAVE_SPARSE_IRQ
562 562
563#ifdef CONFIG_HAVE_DYN_ARRAY 563#ifdef CONFIG_HAVE_DYN_ARRAY
564static struct timer_rand_state **irq_timer_state; 564static struct timer_rand_state **irq_timer_state;
@@ -567,6 +567,51 @@ DEFINE_DYN_ARRAY(irq_timer_state, sizeof(struct timer_rand_state *), nr_irqs, PA
567static struct timer_rand_state *irq_timer_state[NR_IRQS]; 567static struct timer_rand_state *irq_timer_state[NR_IRQS];
568#endif 568#endif
569 569
570static struct timer_rand_state *get_timer_rand_state(unsigned int irq)
571{
572 if (irq >= nr_irqs)
573 return NULL;
574
575 return irq_timer_state[irq];
576}
577
578static void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state)
579{
580 if (irq >= nr_irqs)
581 return;
582
583 irq_timer_state[irq] = state;
584}
585
586#else
587
588static struct timer_rand_state *get_timer_rand_state(unsigned int irq)
589{
590 struct irq_desc *desc;
591
592 desc = irq_to_desc(irq);
593
594 if (!desc)
595 return NULL;
596
597 return desc->timer_rand_state;
598}
599
600static void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state)
601{
602 struct irq_desc *desc;
603
604 desc = irq_to_desc(irq);
605
606 if (!desc)
607 return;
608
609 desc->timer_rand_state = state;
610}
611#endif
612
613static struct timer_rand_state input_timer_state;
614
570/* 615/*
571 * This function adds entropy to the entropy "pool" by using timing 616 * This function adds entropy to the entropy "pool" by using timing
572 * delays. It uses the timer_rand_state structure to make an estimate 617 * delays. It uses the timer_rand_state structure to make an estimate
@@ -654,11 +699,15 @@ EXPORT_SYMBOL_GPL(add_input_randomness);
654 699
655void add_interrupt_randomness(int irq) 700void add_interrupt_randomness(int irq)
656{ 701{
657 if (irq >= nr_irqs || irq_timer_state[irq] == NULL) 702 struct timer_rand_state *state;
703
704 state = get_timer_rand_state(irq);
705
706 if (state == NULL)
658 return; 707 return;
659 708
660 DEBUG_ENT("irq event %d\n", irq); 709 DEBUG_ENT("irq event %d\n", irq);
661 add_timer_randomness(irq_timer_state[irq], 0x100 + irq); 710 add_timer_randomness(state, 0x100 + irq);
662} 711}
663 712
664#ifdef CONFIG_BLOCK 713#ifdef CONFIG_BLOCK
@@ -918,7 +967,14 @@ void rand_initialize_irq(int irq)
918{ 967{
919 struct timer_rand_state *state; 968 struct timer_rand_state *state;
920 969
921 if (irq >= nr_irqs || irq_timer_state[irq]) 970#ifndef CONFIG_HAVE_SPARSE_IRQ
971 if (irq >= nr_irqs)
972 return;
973#endif
974
975 state = get_timer_rand_state(irq);
976
977 if (state)
922 return; 978 return;
923 979
924 /* 980 /*
@@ -927,7 +983,7 @@ void rand_initialize_irq(int irq)
927 */ 983 */
928 state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL); 984 state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL);
929 if (state) 985 if (state)
930 irq_timer_state[irq] = state; 986 set_timer_rand_state(irq, state);
931} 987}
932 988
933#ifdef CONFIG_BLOCK 989#ifdef CONFIG_BLOCK