Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy...
[pandora-kernel.git] / drivers / char / hw_random / intel-rng.c
index 4ae9811..5cc651e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/stop_machine.h>
+#include <linux/delay.h>
 #include <asm/io.h>
 
 
@@ -162,11 +163,19 @@ static inline u8 hwstatus_set(void __iomem *mem,
        return hwstatus_get(mem);
 }
 
-static int intel_rng_data_present(struct hwrng *rng)
+static int intel_rng_data_present(struct hwrng *rng, int wait)
 {
        void __iomem *mem = (void __iomem *)rng->priv;
-
-       return !!(readb(mem + INTEL_RNG_STATUS) & INTEL_RNG_DATA_PRESENT);
+       int data, i;
+
+       for (i = 0; i < 20; i++) {
+               data = !!(readb(mem + INTEL_RNG_STATUS) &
+                         INTEL_RNG_DATA_PRESENT);
+               if (data || !wait)
+                       break;
+               udelay(10);
+       }
+       return data;
 }
 
 static int intel_rng_data_read(struct hwrng *rng, u32 *data)
@@ -296,12 +305,10 @@ static int __init intel_init_hw_struct(struct intel_rng_hw *intel_rng_hw,
             (BIOS_CNTL_LOCK_ENABLE_MASK|BIOS_CNTL_WRITE_ENABLE_MASK))
            == BIOS_CNTL_LOCK_ENABLE_MASK) {
                static __initdata /*const*/ char warning[] =
-                       KERN_WARNING PFX "Firmware space is locked read-only. "
-                       KERN_WARNING PFX "If you can't or\n don't want to "
-                       KERN_WARNING PFX "disable this in firmware setup, and "
-                       KERN_WARNING PFX "if\n you are certain that your "
-                       KERN_WARNING PFX "system has a functional\n RNG, try"
-                       KERN_WARNING PFX "using the 'no_fwh_detect' option.\n";
+                       KERN_WARNING PFX "Firmware space is locked read-only. If you can't or\n"
+                       KERN_WARNING PFX "don't want to disable this in firmware setup, and if\n"
+                       KERN_WARNING PFX "you are certain that your system has a functional\n"
+                       KERN_WARNING PFX "RNG, try using the 'no_fwh_detect' option.\n";
 
                if (no_fwh_detect)
                        return -ENODEV;