]> err.no Git - linux-2.6/blobdiff - drivers/char/hw_random/amd-rng.c
Merge branch 'avr32-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemo...
[linux-2.6] / drivers / char / hw_random / amd-rng.c
index 71e4e0f3fd54ea404ac9658117d863de50eb131f..c422e870dc52705cf779fe7742706bca3eaad86c 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/hw_random.h>
+#include <linux/delay.h>
 #include <asm/io.h>
 
 
@@ -52,11 +53,18 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
 static struct pci_dev *amd_pdev;
 
 
-static int amd_rng_data_present(struct hwrng *rng)
+static int amd_rng_data_present(struct hwrng *rng, int wait)
 {
        u32 pmbase = (u32)rng->priv;
+       int data, i;
 
-       return !!(inl(pmbase + 0xF4) & 1);
+       for (i = 0; i < 20; i++) {
+               data = !!(inl(pmbase + 0xF4) & 1);
+               if (data || !wait)
+                       break;
+               udelay(10);
+       }
+       return data;
 }
 
 static int amd_rng_data_read(struct hwrng *rng, u32 *data)
@@ -144,7 +152,7 @@ static void __exit mod_exit(void)
        hwrng_unregister(&amd_rng);
 }
 
-subsys_initcall(mod_init);
+module_init(mod_init);
 module_exit(mod_exit);
 
 MODULE_AUTHOR("The Linux Kernel team");