Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.29-rc6 /drivers/char/random.c

Filename:/drivers/char/random.c
Lines Added:28
Lines Deleted:13
Also changed in: (Previous) 2.6.29-rc5  2.6.29-rc4  2.6.29-rc3  2.6.29-rc2  2.6.29-rc1  2.6.28-git14 
(Following) 2.6.29-rc7  2.6.29-rc8  2.6.29  2.6.29-git1  2.6.29-git2  2.6.29-git3 

Location
[  2.6.29-rc6
  [  drivers
    [  char
       o  random.c

Patch

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 675076f..7c13581 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -407,7 +407,7 @@ struct entropy_store {
    /* read-write data: */
    spinlock_t lock;
    unsigned add_ptr;
-   int entropy_count;   /* Must at no time exceed ->POOLBITS! */
+   int entropy_count;
    int input_rotate;
 };
 
@@ -558,24 +558,43 @@ struct timer_rand_state {
    unsigned dont_count_entropy:1;
 };
 
+#ifndef CONFIG_SPARSE_IRQ
+
 static struct timer_rand_state *irq_timer_state[NR_IRQS];
 
 static struct timer_rand_state *get_timer_rand_state(unsigned int irq)
 {
-   if (irq >= nr_irqs)
-      return NULL;
-
    return irq_timer_state[irq];
 }
 
-static void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state)
+static void set_timer_rand_state(unsigned int irq,
+             struct timer_rand_state *state)
 {
-   if (irq >= nr_irqs)
-      return;
-
    irq_timer_state[irq] = state;
 }
 
+#else
+
+static struct timer_rand_state *get_timer_rand_state(unsigned int irq)
+{
+   struct irq_desc *desc;
+
+   desc = irq_to_desc(irq);
+
+   return desc->timer_rand_state;
+}
+
+static void set_timer_rand_state(unsigned int irq,
+             struct timer_rand_state *state)
+{
+   struct irq_desc *desc;
+
+   desc = irq_to_desc(irq);
+
+   desc->timer_rand_state = state;
+}
+#endif
+
 static struct timer_rand_state input_timer_state;
 
 /*
@@ -748,11 +767,10 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
 {
    unsigned long flags;
 
-   BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
-
    /* Hold lock while accounting */
    spin_lock_irqsave(&r->lock, flags);
 
+   BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
    DEBUG_ENT("trying to extract %d bits from %s\n",
         nbytes * 8, r->name);
 
@@ -933,9 +951,6 @@ void rand_initialize_irq(int irq)
 {
    struct timer_rand_state *state;
 
-   if (irq >= nr_irqs)
-      return;
-
    state = get_timer_rand_state(irq);
 
    if (state)


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.