]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/random.c
V4L/DVB (10626): ivtv: fix regression in get sliced vbi format
[linux-2.6-omap-h63xx.git] / drivers / char / random.c
index 705a839f1796125b257925dc8c3aac722d992018..7c13581ca9cd6ac1ea4a2d54e80397831cebd75f 100644 (file)
@@ -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)
@@ -1139,18 +1154,12 @@ static int random_fasync(int fd, struct file *filp, int on)
        return fasync_helper(fd, filp, on, &fasync);
 }
 
-static int random_release(struct inode *inode, struct file *filp)
-{
-       return fasync_helper(-1, filp, 0, &fasync);
-}
-
 const struct file_operations random_fops = {
        .read  = random_read,
        .write = random_write,
        .poll  = random_poll,
        .unlocked_ioctl = random_ioctl,
        .fasync = random_fasync,
-       .release = random_release,
 };
 
 const struct file_operations urandom_fops = {
@@ -1158,7 +1167,6 @@ const struct file_operations urandom_fops = {
        .write = random_write,
        .unlocked_ioctl = random_ioctl,
        .fasync = random_fasync,
-       .release = random_release,
 };
 
 /***************************************************************