aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2013-01-03 07:19:13 -0500
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-02-04 02:26:28 -0500
commitaca662a3b1c9b178536267da9fb2f0faa798cb7f (patch)
treee75eea8674411ec01fd03d689d59f0727a487fca /drivers/mtd
parentbd6ce5ef913a7b4dfe5cd5028309346d32a8c404 (diff)
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nandsim.c6
-rw-r--r--drivers/mtd/tests/mtd_nandecctest.c10
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c8
-rw-r--r--drivers/mtd/ubi/debug.h6
4 files changed, 15 insertions, 15 deletions
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 818b65c85d12..4c317982fce5 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -1476,12 +1476,12 @@ int do_read_error(struct nandsim *ns, int num)
1476 1476
1477void do_bit_flips(struct nandsim *ns, int num) 1477void do_bit_flips(struct nandsim *ns, int num)
1478{ 1478{
1479 if (bitflips && random32() < (1 << 22)) { 1479 if (bitflips && prandom_u32() < (1 << 22)) {
1480 int flips = 1; 1480 int flips = 1;
1481 if (bitflips > 1) 1481 if (bitflips > 1)
1482 flips = (random32() % (int) bitflips) + 1; 1482 flips = (prandom_u32() % (int) bitflips) + 1;
1483 while (flips--) { 1483 while (flips--) {
1484 int pos = random32() % (num * 8); 1484 int pos = prandom_u32() % (num * 8);
1485 ns->buf.byte[pos / 8] ^= (1 << (pos % 8)); 1485 ns->buf.byte[pos / 8] ^= (1 << (pos % 8));
1486 NS_WARN("read_page: flipping bit %d in page %d " 1486 NS_WARN("read_page: flipping bit %d in page %d "
1487 "reading from %d ecc: corrected=%u failed=%u\n", 1487 "reading from %d ecc: corrected=%u failed=%u\n",
diff --git a/drivers/mtd/tests/mtd_nandecctest.c b/drivers/mtd/tests/mtd_nandecctest.c
index 1eee264509a8..5015d10591d9 100644
--- a/drivers/mtd/tests/mtd_nandecctest.c
+++ b/drivers/mtd/tests/mtd_nandecctest.c
@@ -44,7 +44,7 @@ struct nand_ecc_test {
44static void single_bit_error_data(void *error_data, void *correct_data, 44static void single_bit_error_data(void *error_data, void *correct_data,
45 size_t size) 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 memcpy(error_data, correct_data, size); 49 memcpy(error_data, correct_data, size);
50 __change_bit_le(offset, error_data); 50 __change_bit_le(offset, error_data);
@@ -55,9 +55,9 @@ static void double_bit_error_data(void *error_data, void *correct_data,
55{ 55{
56 unsigned int offset[2]; 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 do { 59 do {
60 offset[1] = random32() % (size * BITS_PER_BYTE); 60 offset[1] = prandom_u32() % (size * BITS_PER_BYTE);
61 } while (offset[0] == offset[1]); 61 } while (offset[0] == offset[1]);
62 62
63 memcpy(error_data, correct_data, size); 63 memcpy(error_data, correct_data, size);
@@ -68,7 +68,7 @@ static void double_bit_error_data(void *error_data, void *correct_data,
68 68
69static unsigned int random_ecc_bit(size_t size) 69static 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 if (size == 256) { 73 if (size == 256) {
74 /* 74 /*
@@ -76,7 +76,7 @@ static unsigned int random_ecc_bit(size_t size)
76 * and 17th bit) in ECC code for 256 byte data block 76 * and 17th bit) in ECC code for 256 byte data block
77 */ 77 */
78 while (offset == 16 || offset == 17) 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 return offset; 82 return offset;
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 3729f679ae5d..1d29739db916 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -55,7 +55,7 @@ static int rand_eb(void)
55 unsigned int eb; 55 unsigned int eb;
56 56
57again: 57again:
58 eb = random32(); 58 eb = prandom_u32();
59 /* 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' */
60 eb %= (ebcnt - 1); 60 eb %= (ebcnt - 1);
61 if (bbt[eb]) 61 if (bbt[eb])
@@ -67,7 +67,7 @@ static int rand_offs(void)
67{ 67{
68 unsigned int offs; 68 unsigned int offs;
69 69
70 offs = random32(); 70 offs = prandom_u32();
71 offs %= bufsize; 71 offs %= bufsize;
72 return offs; 72 return offs;
73} 73}
@@ -76,7 +76,7 @@ static int rand_len(int offs)
76{ 76{
77 unsigned int len; 77 unsigned int len;
78 78
79 len = random32(); 79 len = prandom_u32();
80 len %= (bufsize - offs); 80 len %= (bufsize - offs);
81 return len; 81 return len;
82} 82}
@@ -191,7 +191,7 @@ static int do_write(void)
191 191
192static int do_operation(void) 192static int do_operation(void)
193{ 193{
194 if (random32() & 1) 194 if (prandom_u32() & 1)
195 return do_read(); 195 return do_read();
196 else 196 else
197 return do_write(); 197 return do_write();
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 33f8f3b2c9b2..cba89fcd1587 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -86,7 +86,7 @@ static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
86static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) 86static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
87{ 87{
88 if (ubi->dbg.emulate_bitflips) 88 if (ubi->dbg.emulate_bitflips)
89 return !(random32() % 200); 89 return !(prandom_u32() % 200);
90 return 0; 90 return 0;
91} 91}
92 92
@@ -100,7 +100,7 @@ static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
100static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) 100static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
101{ 101{
102 if (ubi->dbg.emulate_io_failures) 102 if (ubi->dbg.emulate_io_failures)
103 return !(random32() % 500); 103 return !(prandom_u32() % 500);
104 return 0; 104 return 0;
105} 105}
106 106
@@ -114,7 +114,7 @@ static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
114static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) 114static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
115{ 115{
116 if (ubi->dbg.emulate_io_failures) 116 if (ubi->dbg.emulate_io_failures)
117 return !(random32() % 400); 117 return !(prandom_u32() % 400);
118 return 0; 118 return 0;
119} 119}
120 120