stresstest.c (002c6ca75289a4ac4f6738213dd2d258704886e4) | stresstest.c (8032bf1233a74627ce69b803608e650f3f35971c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2006-2008 Nokia Corporation 4 * 5 * Test random reads, writes and erases on MTD device. 6 * 7 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com> 8 */ --- 32 unchanged lines hidden (view full) --- 41static int pgcnt; 42 43static int rand_eb(void) 44{ 45 unsigned int eb; 46 47again: 48 /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2006-2008 Nokia Corporation 4 * 5 * Test random reads, writes and erases on MTD device. 6 * 7 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com> 8 */ --- 32 unchanged lines hidden (view full) --- 41static int pgcnt; 42 43static int rand_eb(void) 44{ 45 unsigned int eb; 46 47again: 48 /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */ |
49 eb = prandom_u32_max(ebcnt - 1); | 49 eb = get_random_u32_below(ebcnt - 1); |
50 if (bbt[eb]) 51 goto again; 52 return eb; 53} 54 55static int rand_offs(void) 56{ | 50 if (bbt[eb]) 51 goto again; 52 return eb; 53} 54 55static int rand_offs(void) 56{ |
57 return prandom_u32_max(bufsize); | 57 return get_random_u32_below(bufsize); |
58} 59 60static int rand_len(int offs) 61{ | 58} 59 60static int rand_len(int offs) 61{ |
62 return prandom_u32_max(bufsize - offs); | 62 return get_random_u32_below(bufsize - offs); |
63} 64 65static int do_read(void) 66{ 67 int eb = rand_eb(); 68 int offs = rand_offs(); 69 int len = rand_len(offs); 70 loff_t addr; --- 42 unchanged lines hidden (view full) --- 113 offs -= mtd->erasesize; 114 } 115 offsets[eb] = offs; 116 return 0; 117} 118 119static int do_operation(void) 120{ | 63} 64 65static int do_read(void) 66{ 67 int eb = rand_eb(); 68 int offs = rand_offs(); 69 int len = rand_len(offs); 70 loff_t addr; --- 42 unchanged lines hidden (view full) --- 113 offs -= mtd->erasesize; 114 } 115 offsets[eb] = offs; 116 return 0; 117} 118 119static int do_operation(void) 120{ |
121 if (prandom_u32_max(2)) | 121 if (get_random_u32_below(2)) |
122 return do_read(); 123 else 124 return do_write(); 125} 126 127static int __init mtd_stresstest_init(void) 128{ 129 int err; --- 103 unchanged lines hidden --- | 122 return do_read(); 123 else 124 return do_write(); 125} 126 127static int __init mtd_stresstest_init(void) 128{ 129 int err; --- 103 unchanged lines hidden --- |