From patchwork Mon Dec 24 02:14:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 208005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2F4A12C0084 for ; Mon, 24 Dec 2012 13:16:24 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TmxZP-0000la-Kx; Mon, 24 Dec 2012 02:15:11 +0000 Received: from mail-da0-f53.google.com ([209.85.210.53]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TmxZM-0000kf-60 for linux-mtd@lists.infradead.org; Mon, 24 Dec 2012 02:15:09 +0000 Received: by mail-da0-f53.google.com with SMTP id x6so2932361dac.12 for ; Sun, 23 Dec 2012 18:15:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ngzNLkpWHO+/NLsZfwTKm9tLoy4bI/iVLWlAdgSym1Y=; b=aWWdVZIgqkfY9pZCDRgwrJnrvfSp8AaENdRcA8/Vdx+LcxLILwpZi3kUvC98fS/wU+ na1sCCWBUzMGafJBYb0KOEafNjteZtiXSLf9NT7cJFZh7+LlP4uPAZRdClPHFKXkH29Z 2ojFKUoEvQ57580GKpjS0AtI0V0WeFs2oukB/SWwJSmFEQW8a/O2tLpiMuq9XqI0NVkw 7YZ7eRKaZ+CA5sjeL1qWuX/bUpvnIJaZJDqibBLWqBAGSyvPsYwosYY+cyR+m9NjuBcM u3EyUsTmfKAYmJ3qxRJi7DXjJvHI3IZuhXDjGMcW8p2lZ+EnqeSwObjQOTNv8zJtyN3E qBhw== X-Received: by 10.66.80.70 with SMTP id p6mr58963235pax.23.1356315306348; Sun, 23 Dec 2012 18:15:06 -0800 (PST) Received: from localhost.localdomain (p2126-ipbf3106hodogaya.kanagawa.ocn.ne.jp. [114.149.157.126]) by mx.google.com with ESMTPS id wr4sm11379909pbc.72.2012.12.23.18.15.04 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 23 Dec 2012 18:15:05 -0800 (PST) From: Akinobu Mita To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: [PATCH 17/29] mtd: rename random32() to prandom_u32() Date: Mon, 24 Dec 2012 11:14:04 +0900 Message-Id: <1356315256-6572-18-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1356315256-6572-1-git-send-email-akinobu.mita@gmail.com> References: <1356315256-6572-1-git-send-email-akinobu.mita@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121223_211508_372703_52C9ACAD X-CRM114-Status: GOOD ( 15.80 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.53 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (akinobu.mita[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linux-mtd@lists.infradead.org, David Woodhouse , Akinobu Mita , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use more preferable function name which implies using a pseudo-random number generator. Signed-off-by: Akinobu Mita Cc: David Woodhouse Cc: Artem Bityutskiy 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; }