Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: rename random32() to prandom_u32()

Use more preferable function name which implies using a pseudo-random
number generator.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

authored by

Akinobu Mita and committed by
Artem Bityutskiy
aca662a3 bd6ce5ef

+15 -15
+3 -3
drivers/mtd/nand/nandsim.c
··· 1476 1476 1477 1477 void do_bit_flips(struct nandsim *ns, int num) 1478 1478 { 1479 - if (bitflips && random32() < (1 << 22)) { 1479 + if (bitflips && prandom_u32() < (1 << 22)) { 1480 1480 int flips = 1; 1481 1481 if (bitflips > 1) 1482 - flips = (random32() % (int) bitflips) + 1; 1482 + flips = (prandom_u32() % (int) bitflips) + 1; 1483 1483 while (flips--) { 1484 - int pos = random32() % (num * 8); 1484 + int pos = prandom_u32() % (num * 8); 1485 1485 ns->buf.byte[pos / 8] ^= (1 << (pos % 8)); 1486 1486 NS_WARN("read_page: flipping bit %d in page %d " 1487 1487 "reading from %d ecc: corrected=%u failed=%u\n",
+5 -5
drivers/mtd/tests/mtd_nandecctest.c
··· 44 44 static void single_bit_error_data(void *error_data, void *correct_data, 45 45 size_t size) 46 46 { 47 - unsigned int offset = random32() % (size * BITS_PER_BYTE); 47 + unsigned int offset = prandom_u32() % (size * BITS_PER_BYTE); 48 48 49 49 memcpy(error_data, correct_data, size); 50 50 __change_bit_le(offset, error_data); ··· 55 55 { 56 56 unsigned int offset[2]; 57 57 58 - offset[0] = random32() % (size * BITS_PER_BYTE); 58 + offset[0] = prandom_u32() % (size * BITS_PER_BYTE); 59 59 do { 60 - offset[1] = random32() % (size * BITS_PER_BYTE); 60 + offset[1] = prandom_u32() % (size * BITS_PER_BYTE); 61 61 } while (offset[0] == offset[1]); 62 62 63 63 memcpy(error_data, correct_data, size); ··· 68 68 69 69 static unsigned int random_ecc_bit(size_t size) 70 70 { 71 - unsigned int offset = random32() % (3 * BITS_PER_BYTE); 71 + unsigned int offset = prandom_u32() % (3 * BITS_PER_BYTE); 72 72 73 73 if (size == 256) { 74 74 /* ··· 76 76 * and 17th bit) in ECC code for 256 byte data block 77 77 */ 78 78 while (offset == 16 || offset == 17) 79 - offset = random32() % (3 * BITS_PER_BYTE); 79 + offset = prandom_u32() % (3 * BITS_PER_BYTE); 80 80 } 81 81 82 82 return offset;
+4 -4
drivers/mtd/tests/mtd_stresstest.c
··· 55 55 unsigned int eb; 56 56 57 57 again: 58 - eb = random32(); 58 + eb = prandom_u32(); 59 59 /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */ 60 60 eb %= (ebcnt - 1); 61 61 if (bbt[eb]) ··· 67 67 { 68 68 unsigned int offs; 69 69 70 - offs = random32(); 70 + offs = prandom_u32(); 71 71 offs %= bufsize; 72 72 return offs; 73 73 } ··· 76 76 { 77 77 unsigned int len; 78 78 79 - len = random32(); 79 + len = prandom_u32(); 80 80 len %= (bufsize - offs); 81 81 return len; 82 82 } ··· 191 191 192 192 static int do_operation(void) 193 193 { 194 - if (random32() & 1) 194 + if (prandom_u32() & 1) 195 195 return do_read(); 196 196 else 197 197 return do_write();
+3 -3
drivers/mtd/ubi/debug.h
··· 86 86 static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) 87 87 { 88 88 if (ubi->dbg.emulate_bitflips) 89 - return !(random32() % 200); 89 + return !(prandom_u32() % 200); 90 90 return 0; 91 91 } 92 92 ··· 100 100 static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) 101 101 { 102 102 if (ubi->dbg.emulate_io_failures) 103 - return !(random32() % 500); 103 + return !(prandom_u32() % 500); 104 104 return 0; 105 105 } 106 106 ··· 114 114 static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) 115 115 { 116 116 if (ubi->dbg.emulate_io_failures) 117 - return !(random32() % 400); 117 + return !(prandom_u32() % 400); 118 118 return 0; 119 119 } 120 120