aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/tests/mtd_stresstest.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/tests/mtd_stresstest.c')
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 7b33f22d0b58..cb268cebf01a 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -27,6 +27,7 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/vmalloc.h> 29#include <linux/vmalloc.h>
30#include <linux/random.h>
30 31
31#define PRINT_PREF KERN_INFO "mtd_stresstest: " 32#define PRINT_PREF KERN_INFO "mtd_stresstest: "
32 33
@@ -48,28 +49,13 @@ static int pgsize;
48static int bufsize; 49static int bufsize;
49static int ebcnt; 50static int ebcnt;
50static int pgcnt; 51static int pgcnt;
51static unsigned long next = 1;
52
53static inline unsigned int simple_rand(void)
54{
55 next = next * 1103515245 + 12345;
56 return (unsigned int)((next / 65536) % 32768);
57}
58
59static inline void simple_srand(unsigned long seed)
60{
61 next = seed;
62}
63 52
64static int rand_eb(void) 53static int rand_eb(void)
65{ 54{
66 int eb; 55 unsigned int eb;
67 56
68again: 57again:
69 if (ebcnt < 32768) 58 eb = random32();
70 eb = simple_rand();
71 else
72 eb = (simple_rand() << 15) | simple_rand();
73 /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */ 59 /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */
74 eb %= (ebcnt - 1); 60 eb %= (ebcnt - 1);
75 if (bbt[eb]) 61 if (bbt[eb])
@@ -79,24 +65,18 @@ again:
79 65
80static int rand_offs(void) 66static int rand_offs(void)
81{ 67{
82 int offs; 68 unsigned int offs;
83 69
84 if (bufsize < 32768) 70 offs = random32();
85 offs = simple_rand();
86 else
87 offs = (simple_rand() << 15) | simple_rand();
88 offs %= bufsize; 71 offs %= bufsize;
89 return offs; 72 return offs;
90} 73}
91 74
92static int rand_len(int offs) 75static int rand_len(int offs)
93{ 76{
94 int len; 77 unsigned int len;
95 78
96 if (bufsize < 32768) 79 len = random32();
97 len = simple_rand();
98 else
99 len = (simple_rand() << 15) | simple_rand();
100 len %= (bufsize - offs); 80 len %= (bufsize - offs);
101 return len; 81 return len;
102} 82}
@@ -211,7 +191,7 @@ static int do_write(void)
211 191
212static int do_operation(void) 192static int do_operation(void)
213{ 193{
214 if (simple_rand() & 1) 194 if (random32() & 1)
215 return do_read(); 195 return do_read();
216 else 196 else
217 return do_write(); 197 return do_write();
@@ -302,9 +282,8 @@ static int __init mtd_stresstest_init(void)
302 } 282 }
303 for (i = 0; i < ebcnt; i++) 283 for (i = 0; i < ebcnt; i++)
304 offsets[i] = mtd->erasesize; 284 offsets[i] = mtd->erasesize;
305 simple_srand(current->pid);
306 for (i = 0; i < bufsize; i++) 285 for (i = 0; i < bufsize; i++)
307 writebuf[i] = simple_rand(); 286 writebuf[i] = random32();
308 287
309 err = scan_for_bad_eraseblocks(); 288 err = scan_for_bad_eraseblocks();
310 if (err) 289 if (err)