public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Artem Bityutskiy <dedekind1@gmail.com>,
	linux-mtd@lists.infradead.org
Subject: [PATCH 17/29] mtd: rename random32() to prandom_u32()
Date: Mon, 24 Dec 2012 11:14:04 +0900	[thread overview]
Message-ID: <1356315256-6572-18-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1356315256-6572-1-git-send-email-akinobu.mita@gmail.com>

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

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org
---
 drivers/mtd/nand/nandsim.c          |  6 +++---
 drivers/mtd/tests/mtd_nandecctest.c | 10 +++++-----
 drivers/mtd/tests/mtd_stresstest.c  |  8 ++++----
 drivers/mtd/ubi/debug.h             |  6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 818b65c..4c31798 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)
 
 void do_bit_flips(struct nandsim *ns, int num)
 {
-	if (bitflips && random32() < (1 << 22)) {
+	if (bitflips && prandom_u32() < (1 << 22)) {
 		int flips = 1;
 		if (bitflips > 1)
-			flips = (random32() % (int) bitflips) + 1;
+			flips = (prandom_u32() % (int) bitflips) + 1;
 		while (flips--) {
-			int pos = random32() % (num * 8);
+			int pos = prandom_u32() % (num * 8);
 			ns->buf.byte[pos / 8] ^= (1 << (pos % 8));
 			NS_WARN("read_page: flipping bit %d in page %d "
 				"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 ceb261f..2e6b41e 100644
--- a/drivers/mtd/tests/mtd_nandecctest.c
+++ b/drivers/mtd/tests/mtd_nandecctest.c
@@ -43,7 +43,7 @@ struct nand_ecc_test {
 static void single_bit_error_data(void *error_data, void *correct_data,
 				size_t size)
 {
-	unsigned int offset = random32() % (size * BITS_PER_BYTE);
+	unsigned int offset = prandom_u32() % (size * BITS_PER_BYTE);
 
 	memcpy(error_data, correct_data, size);
 	__change_bit_le(offset, error_data);
@@ -54,9 +54,9 @@ static void double_bit_error_data(void *error_data, void *correct_data,
 {
 	unsigned int offset[2];
 
-	offset[0] = random32() % (size * BITS_PER_BYTE);
+	offset[0] = prandom_u32() % (size * BITS_PER_BYTE);
 	do {
-		offset[1] = random32() % (size * BITS_PER_BYTE);
+		offset[1] = prandom_u32() % (size * BITS_PER_BYTE);
 	} while (offset[0] == offset[1]);
 
 	memcpy(error_data, correct_data, size);
@@ -67,7 +67,7 @@ static void double_bit_error_data(void *error_data, void *correct_data,
 
 static unsigned int random_ecc_bit(size_t size)
 {
-	unsigned int offset = random32() % (3 * BITS_PER_BYTE);
+	unsigned int offset = prandom_u32() % (3 * BITS_PER_BYTE);
 
 	if (size == 256) {
 		/*
@@ -75,7 +75,7 @@ static unsigned int random_ecc_bit(size_t size)
 		 * and 17th bit) in ECC code for 256 byte data block
 		 */
 		while (offset == 16 || offset == 17)
-			offset = random32() % (3 * BITS_PER_BYTE);
+			offset = prandom_u32() % (3 * BITS_PER_BYTE);
 	}
 
 	return offset;
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index dc89e32..4e9fc1f 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -57,7 +57,7 @@ static int rand_eb(void)
 	unsigned int eb;
 
 again:
-	eb = random32();
+	eb = prandom_u32();
 	/* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */
 	eb %= (ebcnt - 1);
 	if (bbt[eb])
@@ -69,7 +69,7 @@ static int rand_offs(void)
 {
 	unsigned int offs;
 
-	offs = random32();
+	offs = prandom_u32();
 	offs %= bufsize;
 	return offs;
 }
@@ -78,7 +78,7 @@ static int rand_len(int offs)
 {
 	unsigned int len;
 
-	len = random32();
+	len = prandom_u32();
 	len %= (bufsize - offs);
 	return len;
 }
@@ -148,7 +148,7 @@ static int do_write(void)
 
 static int do_operation(void)
 {
-	if (random32() & 1)
+	if (prandom_u32() & 1)
 		return do_read();
 	else
 		return do_write();
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 33f8f3b..cba89fc 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)
 static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
 {
 	if (ubi->dbg.emulate_bitflips)
-		return !(random32() % 200);
+		return !(prandom_u32() % 200);
 	return 0;
 }
 
@@ -100,7 +100,7 @@ static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
 static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
 {
 	if (ubi->dbg.emulate_io_failures)
-		return !(random32() % 500);
+		return !(prandom_u32() % 500);
 	return 0;
 }
 
@@ -114,7 +114,7 @@ static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
 static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
 {
 	if (ubi->dbg.emulate_io_failures)
-		return !(random32() % 400);
+		return !(prandom_u32() % 400);
 	return 0;
 }
 
-- 
1.7.11.7


  parent reply	other threads:[~2012-12-24  2:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-24  2:13 [PATCH 00/29] rename random32 and net_random to prandom Akinobu Mita
2012-12-24  2:13 ` [PATCH 01/29] raid6test: use prandom_bytes() Akinobu Mita
2012-12-24  2:13 ` [PATCH 02/29] uuid: " Akinobu Mita
2012-12-24  2:13 ` [PATCH 03/29] x86: pageattr-test: remove srandom32 call Akinobu Mita
2012-12-24  2:13 ` [PATCH 04/29] x86: rename random32() to prandom_u32() Akinobu Mita
2012-12-24  2:13 ` [PATCH 05/29] lib/: " Akinobu Mita
2012-12-24  2:13 ` [PATCH 06/29] mm/: " Akinobu Mita
2012-12-24  2:13 ` [PATCH 07/29] kernel/: " Akinobu Mita
2012-12-24  2:13 ` [PATCH 08/29] drbd: " Akinobu Mita
2012-12-24  2:13 ` [PATCH 09/29] infiniband: rename random32() and net_random() " Akinobu Mita
2012-12-24  2:13 ` [PATCH 10/29] mmc: rename random32() " Akinobu Mita
2012-12-24  2:13 ` [PATCH 11/29] video/uvesafb: " Akinobu Mita
2012-12-24  2:13 ` [PATCH 12/29] xfs: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 13/29] ubifs: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 14/29] uwb: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 15/29] lguest: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 16/29] scsi: " Akinobu Mita
2012-12-24  2:14 ` Akinobu Mita [this message]
2012-12-24  2:14 ` [PATCH 18/29] drivers/net: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 19/29] batman-adv: fix random jitter calculation Akinobu Mita
2012-12-25 11:26   ` Antonio Quartulli
2012-12-25 21:35     ` Akinobu Mita
2012-12-25 21:37       ` David Miller
2012-12-24  2:14 ` [PATCH 20/29] batman-adv: rename random32() to prandom_u32() Akinobu Mita
2012-12-25 11:30   ` Antonio Quartulli
2013-01-02 11:52     ` [B.A.T.M.A.N.] " Marek Lindner
2012-12-24  2:14 ` [PATCH 21/29] net/sunrpc: rename random32() and net_random() " Akinobu Mita
2012-12-24  2:14 ` [PATCH 22/29] net/sched: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 23/29] net/ipv4: rename " Akinobu Mita
2012-12-24  2:14 ` [PATCH 24/29] net/ipv6: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 25/29] net/netfilter: rename random32() and " Akinobu Mita
2012-12-24  2:14 ` [PATCH 26/29] net/core: " Akinobu Mita
2012-12-24  2:14 ` [PATCH 27/29] net/core: remove duplicate statements by do-while loop Akinobu Mita
2012-12-24  2:14 ` [PATCH 28/29] net/: rename net_random() to prandom_u32() Akinobu Mita
2012-12-25  0:21   ` Neil Horman
2012-12-25 11:47     ` Akinobu Mita
2012-12-26  0:42       ` Neil Horman
2012-12-24  2:14 ` [PATCH 29/29] remove unused net_random(), net_srandom(), random32(), and srandom32() Akinobu Mita

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1356315256-6572-18-git-send-email-akinobu.mita@gmail.com \
    --to=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox