diff options
| -rw-r--r-- | drivers/mtd/tests/mtd_speedtest.c | 16 | ||||
| -rw-r--r-- | drivers/mtd/tests/mtd_stresstest.c | 39 |
2 files changed, 11 insertions, 44 deletions
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c index 2aec4f3b72be..42b0f7456fc4 100644 --- a/drivers/mtd/tests/mtd_speedtest.c +++ b/drivers/mtd/tests/mtd_speedtest.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/mtd/mtd.h> | 26 | #include <linux/mtd/mtd.h> |
| 27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 28 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
| 29 | #include <linux/random.h> | ||
| 29 | 30 | ||
| 30 | #define PRINT_PREF KERN_INFO "mtd_speedtest: " | 31 | #define PRINT_PREF KERN_INFO "mtd_speedtest: " |
| 31 | 32 | ||
| @@ -47,25 +48,13 @@ static int ebcnt; | |||
| 47 | static int pgcnt; | 48 | static int pgcnt; |
| 48 | static int goodebcnt; | 49 | static int goodebcnt; |
| 49 | static struct timeval start, finish; | 50 | static struct timeval start, finish; |
| 50 | static unsigned long next = 1; | ||
| 51 | |||
| 52 | static inline unsigned int simple_rand(void) | ||
| 53 | { | ||
| 54 | next = next * 1103515245 + 12345; | ||
| 55 | return (unsigned int)((next / 65536) % 32768); | ||
| 56 | } | ||
| 57 | |||
| 58 | static inline void simple_srand(unsigned long seed) | ||
| 59 | { | ||
| 60 | next = seed; | ||
| 61 | } | ||
| 62 | 51 | ||
| 63 | static void set_random_data(unsigned char *buf, size_t len) | 52 | static void set_random_data(unsigned char *buf, size_t len) |
| 64 | { | 53 | { |
| 65 | size_t i; | 54 | size_t i; |
| 66 | 55 | ||
| 67 | for (i = 0; i < len; ++i) | 56 | for (i = 0; i < len; ++i) |
| 68 | buf[i] = simple_rand(); | 57 | buf[i] = random32(); |
| 69 | } | 58 | } |
| 70 | 59 | ||
| 71 | static int erase_eraseblock(int ebnum) | 60 | static int erase_eraseblock(int ebnum) |
| @@ -407,7 +396,6 @@ static int __init mtd_speedtest_init(void) | |||
| 407 | goto out; | 396 | goto out; |
| 408 | } | 397 | } |
| 409 | 398 | ||
| 410 | simple_srand(1); | ||
| 411 | set_random_data(iobuf, mtd->erasesize); | 399 | set_random_data(iobuf, mtd->erasesize); |
| 412 | 400 | ||
| 413 | err = scan_for_bad_eraseblocks(); | 401 | err = scan_for_bad_eraseblocks(); |
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; | |||
| 48 | static int bufsize; | 49 | static int bufsize; |
| 49 | static int ebcnt; | 50 | static int ebcnt; |
| 50 | static int pgcnt; | 51 | static int pgcnt; |
| 51 | static unsigned long next = 1; | ||
| 52 | |||
| 53 | static inline unsigned int simple_rand(void) | ||
| 54 | { | ||
| 55 | next = next * 1103515245 + 12345; | ||
| 56 | return (unsigned int)((next / 65536) % 32768); | ||
| 57 | } | ||
| 58 | |||
| 59 | static inline void simple_srand(unsigned long seed) | ||
| 60 | { | ||
| 61 | next = seed; | ||
| 62 | } | ||
| 63 | 52 | ||
| 64 | static int rand_eb(void) | 53 | static int rand_eb(void) |
| 65 | { | 54 | { |
| 66 | int eb; | 55 | unsigned int eb; |
| 67 | 56 | ||
| 68 | again: | 57 | again: |
| 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 | ||
| 80 | static int rand_offs(void) | 66 | static 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 | ||
| 92 | static int rand_len(int offs) | 75 | static 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 | ||
| 212 | static int do_operation(void) | 192 | static 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) |
