clk: rockchip: add clock ids for efuse on RK3366
[firefly-linux-kernel-4.4.55.git] / drivers / char / random.c
index e511f34be17749f5fb658d2ce35d81305617eb93..d93dfebae0bba58a7634d8dfc8e76aa97c0e515c 100644 (file)
@@ -948,6 +948,7 @@ void add_interrupt_randomness(int irq, int irq_flags)
        /* award one bit for the contents of the fast pool */
        credit_entropy_bits(r, credit + 1);
 }
+EXPORT_SYMBOL_GPL(add_interrupt_randomness);
 
 #ifdef CONFIG_BLOCK
 void add_disk_randomness(struct gendisk *disk)
@@ -1460,12 +1461,16 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 static ssize_t
 urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
+       static int maxwarn = 10;
        int ret;
 
-       if (unlikely(nonblocking_pool.initialized == 0))
-               printk_once(KERN_NOTICE "random: %s urandom read "
-                           "with %d bits of entropy available\n",
-                           current->comm, nonblocking_pool.entropy_total);
+       if (unlikely(nonblocking_pool.initialized == 0) &&
+           maxwarn > 0) {
+               maxwarn--;
+               printk(KERN_NOTICE "random: %s: uninitialized urandom read "
+                      "(%zd bytes read, %d bits of entropy available)\n",
+                      current->comm, nbytes, nonblocking_pool.entropy_total);
+       }
 
        nbytes = min_t(size_t, nbytes, INT_MAX >> (ENTROPY_SHIFT + 3));
        ret = extract_entropy_user(&nonblocking_pool, buf, nbytes);
@@ -1869,12 +1874,18 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
 {
        struct entropy_store *poolp = &input_pool;
 
-       /* Suspend writing if we're above the trickle threshold.
-        * We'll be woken up again once below random_write_wakeup_thresh,
-        * or when the calling thread is about to terminate.
-        */
-       wait_event_interruptible(random_write_wait, kthread_should_stop() ||
+       if (unlikely(nonblocking_pool.initialized == 0))
+               poolp = &nonblocking_pool;
+       else {
+               /* Suspend writing if we're above the trickle
+                * threshold.  We'll be woken up again once below
+                * random_write_wakeup_thresh, or when the calling
+                * thread is about to terminate.
+                */
+               wait_event_interruptible(random_write_wait,
+                                        kthread_should_stop() ||
                        ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits);
+       }
        mix_pool_bytes(poolp, buffer, count);
        credit_entropy_bits(poolp, entropy);
 }