diff options
Diffstat (limited to 'drivers/char/hw_random/amd-rng.c')
-rw-r--r-- | drivers/char/hw_random/amd-rng.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c index 556fd81fa815..c422e870dc52 100644 --- a/drivers/char/hw_random/amd-rng.c +++ b/drivers/char/hw_random/amd-rng.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/hw_random.h> | 30 | #include <linux/hw_random.h> |
31 | #include <linux/delay.h> | ||
31 | #include <asm/io.h> | 32 | #include <asm/io.h> |
32 | 33 | ||
33 | 34 | ||
@@ -52,11 +53,18 @@ MODULE_DEVICE_TABLE(pci, pci_tbl); | |||
52 | static struct pci_dev *amd_pdev; | 53 | static struct pci_dev *amd_pdev; |
53 | 54 | ||
54 | 55 | ||
55 | static int amd_rng_data_present(struct hwrng *rng) | 56 | static int amd_rng_data_present(struct hwrng *rng, int wait) |
56 | { | 57 | { |
57 | u32 pmbase = (u32)rng->priv; | 58 | u32 pmbase = (u32)rng->priv; |
59 | int data, i; | ||
58 | 60 | ||
59 | return !!(inl(pmbase + 0xF4) & 1); | 61 | for (i = 0; i < 20; i++) { |
62 | data = !!(inl(pmbase + 0xF4) & 1); | ||
63 | if (data || !wait) | ||
64 | break; | ||
65 | udelay(10); | ||
66 | } | ||
67 | return data; | ||
60 | } | 68 | } |
61 | 69 | ||
62 | static int amd_rng_data_read(struct hwrng *rng, u32 *data) | 70 | static int amd_rng_data_read(struct hwrng *rng, u32 *data) |