Skip to contentSkip to conversation

rename random32 to prandom

PATCH Applied Akinobu Mita 7 participants 42 messages Jan 3, 2013 – Jan 15, 2013

Subsystems (34)
lore
Share & tools
lore

Akinobu Mita

author maintainer
#0 lore raw

cover rename random32 to prandom

Commit 496f2f93b1cc286f5a4f4f9acdc1e5314978683f ("random32: rename random32 to prandom") renamed random32() and srandom32() to prandom_u32() and prandom_seed() respectively. Due to the volume of existing random32() callers, they were preserved as backword compatibility wrapper macros.

This patch series aims for finishing the naming transition and removing the backword compatibility wrapper macros.

The naming transition is mainly simple substitution work for random32() and srandom32(). But this patch series also includes minor cleanup which was found while I was working on the substitution.

* Changes from v1
- leave all net_random() and net_srandom callers as-is and preserve the macro definisions. Because that is a useful indirection. Spotted by Neil Horman.
- remove batman-adv fix which has been applied to net
- collect Acked-by:

Akinobu Mita (26):
raid6test: use prandom_bytes()
uuid: use prandom_bytes()
x86: pageattr-test: remove srandom32 call
x86: rename random32() to prandom_u32()
lib/: rename random32() to prandom_u32()
mm/: rename random32() to prandom_u32() kernel/: rename random32() to prandom_u32()
drbd: rename random32() to prandom_u32()
infiniband: rename random32() to prandom_u32()
mmc: rename random32() to prandom_u32() video/uvesafb: rename random32() to prandom_u32()
xfs: rename random32() to prandom_u32()
ubifs: rename random32() to prandom_u32()
uwb: rename random32() to prandom_u32()
lguest: rename random32() to prandom_u32()
scsi: rename random32() to prandom_u32()
mtd: rename random32() to prandom_u32() drivers/net: rename random32() to prandom_u32()
batman-adv: rename random32() to prandom_u32() net/sunrpc: rename random32() to prandom_u32() net/sched: rename random32() to prandom_u32() net/netfilter: rename random32() to prandom_u32() net/core: rename random32() to prandom_u32() net/core: remove duplicate statements by do-while loop
net: rename random32 to prandom
remove unused random32() and srandom32()

 arch/x86/mm/pageattr-test.c                 |  5 ++--
 crypto/async_tx/raid6test.c                 |  9 ++-----
 drivers/block/drbd/drbd_receiver.c          |  5 ++--
 drivers/infiniband/hw/cxgb3/cxio_resource.c |  4 +--
 drivers/infiniband/hw/cxgb4/id_table.c      |  4 +--
 drivers/infiniband/hw/mlx4/mad.c            |  2 +-
 drivers/infiniband/ulp/ipoib/ipoib_cm.c     |  2 +-
 drivers/lguest/page_tables.c                |  2 +-
 drivers/mmc/core/core.c                     |  4 +--
 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 ++---
 drivers/net/ethernet/broadcom/cnic.c        |  4 +--
 drivers/net/hamradio/baycom_epp.c           |  2 +-
 drivers/net/hamradio/hdlcdrv.c              |  2 +-
 drivers/net/hamradio/yam.c                  |  2 +-
 drivers/net/wireless/mwifiex/cfg80211.c     |  4 +--
 drivers/scsi/fcoe/fcoe_ctlr.c               |  4 +--
 drivers/scsi/lpfc/lpfc_hbadisc.c            |  6 ++---
 drivers/scsi/qla2xxx/qla_attr.c             |  7 +++--
 drivers/uwb/rsv.c                           |  4 +--
 drivers/video/uvesafb.c                     |  2 +-
 fs/ubifs/debug.c                            |  8 +++---
 fs/ubifs/lpt_commit.c                       | 14 +++++-----
 fs/ubifs/tnc_commit.c                       |  2 +-
 fs/xfs/xfs_alloc.c                          |  2 +-
 fs/xfs/xfs_error.c                          |  2 +-
 fs/xfs/xfs_ialloc.c                         |  2 +-
 fs/xfs/xfs_log.c                            |  2 +-
 include/linux/net.h                         |  4 +--
 include/linux/random.h                      |  7 -----
 kernel/rcutree.c                            |  2 +-
 kernel/test_kprobes.c                       |  2 +-
 lib/fault-inject.c                          |  2 +-
 lib/list_sort.c                             |  2 +-
 lib/uuid.c                                  |  8 +-----
 mm/swapfile.c                               |  2 +-
 net/batman-adv/bat_iv_ogm.c                 |  4 +--
 net/core/pktgen.c                           | 42 ++++++++++++++---------------
 net/netfilter/nf_conntrack_core.c           |  4 +--
 net/sched/sch_choke.c                       |  2 +-
 net/sunrpc/auth_gss/gss_krb5_wrap.c         |  4 +--
 43 files changed, 102 insertions(+), 119 deletions(-)
Cc "Theodore Ts'o" <[email protected]>
Cc "David S. Miller" <[email protected]>
Signature · 1 line
1.7.11.7
author maintainer
#1 lore raw

PATCH 1/26 raid6test: use prandom_bytes()

Use prandom_bytes() to generate random bytes for test data.

Cc Dan Williams <[email protected]>
Cc Vinod Koul <[email protected]>

---

No change from v1

 crypto/async_tx/raid6test.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
crypto/async_tx/raid6test.c +2 -7
index aa2b027..4a92bac 100644
@@ -46,15 +46,10 @@ static void callback(void *param)
 
 static void makedata(int disks)
 {
-	int i, j;
+	int i;
 
 	for (i = 0; i < disks; i++) {
-		for (j = 0; j < PAGE_SIZE/sizeof(u32); j += sizeof(u32)) {
-			u32 *p = page_address(data[i]) + j;
-
-			*p = random32();
-		}
-
+		prandom_bytes(page_address(data[i]), PAGE_SIZE);
 		dataptrs[i] = data[i];
 	}
 }
Signature · 1 line
1.7.11.7
author maintainer
#2 lore raw

PATCH 2/26 uuid: use prandom_bytes()

In reply to Akinobu Mita

Use prandom_bytes() to generate 16 bytes of pseudo-random bytes.

Cc "Theodore Ts'o" <[email protected]>
Cc Huang Ying <[email protected]>

---

No change from v1

 lib/uuid.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
lib/uuid.c +1 -7
index 52a6fe6..398821e 100644
@@ -25,13 +25,7 @@
 
 static void __uuid_gen_common(__u8 b[16])
 {
-	int i;
-	u32 r;
-
-	for (i = 0; i < 4; i++) {
-		r = random32();
-		memcpy(b + i * 4, &r, 4);
-	}
+	prandom_bytes(b, 16);
 	/* reversion 0b10 */
 	b[8] = (b[8] & 0x3F) | 0x80;
 }
Signature · 1 line
1.7.11.7
author maintainer
#3 lore raw

PATCH 3/26 x86: pageattr-test: remove srandom32 call

In reply to Akinobu Mita

pageattr-test calls srandom32() once every test iteration. But calling srandom32() after late_initcalls is not meaningfull. Because the random states for random32() is mixed by good random numbers in late_initcall prandom_reseed().

So this removes the call to srandom32().

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---

No change from v1

 arch/x86/mm/pageattr-test.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/mm/pageattr-test.c +0 -1
index b008656..8b8c381 100644
@@ -130,7 +130,6 @@ static int pageattr_test(void)
 	}
 
 	failed += print_split(&sa);
-	srandom32(100);
 
 	for (i = 0; i < NTEST; i++) {
 		unsigned long pfn = random32() % max_pfn_mapped;
Signature · 1 line
1.7.11.7
reviewer Acked-by on v1 3/26
#4 lore raw

Re: [PATCH -v2 03/26] x86: pageattr-test: remove srandom32 call

Quoted 7 lines · Akinobu Mita

pageattr-test calls srandom32() once every test iteration. But calling srandom32() after late_initcalls is not meaningfull. Because the random states for random32() is mixed by good random numbers in late_initcall prandom_reseed().

So this removes the call to srandom32().

Quoted 9 lines
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---

No change from v1

... for this and the other patch. Do you need me to pick it up or are you pushing this directly as part of your bigger patchset?

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
author maintainer
#5 lore raw

Re: [PATCH -v2 03/26] x86: pageattr-test: remove srandom32 call

2013/1/4 H. Peter Anvin <[email protected]>:

Quoted 16 lines · Akinobu Mita
Quoted 15 lines

pageattr-test calls srandom32() once every test iteration. But calling srandom32() after late_initcalls is not meaningfull. Because the random states for random32() is mixed by good random numbers in late_initcall prandom_reseed().

So this removes the call to srandom32().

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---

Quoted 7 lines
Quoted 2 lines

No change from v1

... for this and the other patch. Do you need me to pick it up or are you pushing this directly as part of your bigger patchset?

Please pick up the patches for x86.
Thanks for taking care of it.

author maintainer
#6 lore raw

PATCH 4/26 x86: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---

No change from v1

 arch/x86/mm/pageattr-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/pageattr-test.c +2 -2
index 8b8c381..9346108 100644
@@ -132,10 +132,10 @@ static int pageattr_test(void)
 	failed += print_split(&sa);
 
 	for (i = 0; i < NTEST; i++) {
-		unsigned long pfn = random32() % max_pfn_mapped;
+		unsigned long pfn = prandom_u32() % max_pfn_mapped;
 
 		addr[i] = (unsigned long)__va(pfn << PAGE_SHIFT);
-		len[i] = random32() % 100;
+		len[i] = prandom_u32() % 100;
 		len[i] = min_t(unsigned long, len[i], max_pfn_mapped - pfn - 1);
 
 		if (len[i] == 0)
Signature · 1 line
1.7.11.7
author maintainer
#7 lore raw

PATCH 5/26 lib/: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 lib/fault-inject.c | 2 +-
 lib/list_sort.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/fault-inject.c +1 -1
index f7210ad..c5c7a76 100644
@@ -122,7 +122,7 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
 			return false;
 	}
 
-	if (attr->probability <= random32() % 100)
+	if (attr->probability <= prandom_u32() % 100)
 		return false;
 
 	if (!fail_stacktrace(attr))
lib/list_sort.c +1 -1
index d7325c6..1183fa7 100644
@@ -229,7 +229,7 @@ static int __init list_sort_test(void)
 			goto exit;
 		}
 		 /* force some equivalencies */
-		el->value = random32() % (TEST_LIST_LEN/3);
+		el->value = prandom_u32() % (TEST_LIST_LEN / 3);
 		el->serial = i;
 		el->poison1 = TEST_POISON1;
 		el->poison2 = TEST_POISON2;
Signature · 1 line
1.7.11.7
author maintainer
#8 lore raw

PATCH 6/26 mm/: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 mm/swapfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/swapfile.c +1 -1
index e97a0e5..3af83bf 100644
@@ -2044,7 +2044,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 	if (p->bdev) {
 		if (blk_queue_nonrot(bdev_get_queue(p->bdev))) {
 			p->flags |= SWP_SOLIDSTATE;
-			p->cluster_next = 1 + (random32() % p->highest_bit);
+			p->cluster_next = 1 + (prandom_u32() % p->highest_bit);
 		}
 		if ((swap_flags & SWAP_FLAG_DISCARD) && discard_swap(p) == 0)
 			p->flags |= SWP_DISCARDABLE;
Signature · 7 lines
1.7.11.7

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author maintainer
#9 lore raw

PATCH 7/26 kernel/: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 kernel/rcutree.c      | 2 +-
 kernel/test_kprobes.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/rcutree.c +1 -1
index e441b77..5b88db8 100644
@@ -1206,7 +1206,7 @@ static int rcu_gp_init(struct rcu_state *rsp)
 					    rnp->grphi, rnp->qsmask);
 		raw_spin_unlock_irq(&rnp->lock);
 #ifdef CONFIG_PROVE_RCU_DELAY
-		if ((random32() % (rcu_num_nodes * 8)) == 0)
+		if ((prandom_u32() % (rcu_num_nodes * 8)) == 0)
 			schedule_timeout_uninterruptible(2);
 #endif /* #ifdef CONFIG_PROVE_RCU_DELAY */
 		cond_resched();
kernel/test_kprobes.c +1 -1
index f8b11a2..12d6ebb 100644
@@ -365,7 +365,7 @@ int init_test_probes(void)
 	target2 = kprobe_target2;
 
 	do {
-		rand1 = random32();
+		rand1 = prandom_u32();
 	} while (rand1 <= div_factor);
 
 	printk(KERN_INFO "Kprobe smoke test started\n");
Signature · 1 line
1.7.11.7
author maintainer
#10 lore raw

PATCH 8/26 drbd: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 drivers/block/drbd/drbd_receiver.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_receiver.c +3 -2
index a9eccfc..83c5ae0 100644
@@ -757,7 +757,8 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct acc
 	rcu_read_unlock();
 
 	timeo = connect_int * HZ;
-	timeo += (random32() & 1) ? timeo / 7 : -timeo / 7; /* 28.5% random jitter */
+	/* 28.5% random jitter */
+	timeo += (prandom_u32() & 1) ? timeo / 7 : -timeo / 7;
 
 	err = wait_for_completion_interruptible_timeout(&ad->door_bell, timeo);
 	if (err <= 0)
@@ -953,7 +954,7 @@ retry:
 				conn_warn(tconn, "Error receiving initial packet\n");
 				sock_release(s);
 randomize:
-				if (random32() & 1)
+				if (prandom_u32() & 1)
 					goto retry;
 			}
 		}
Signature · 1 line
1.7.11.7
author maintainer
#11 lore raw

PATCH 9/26 infiniband: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

Cc Roland Dreier <[email protected]>
Cc Sean Hefty <[email protected]>
Cc Hal Rosenstock <[email protected]>
Cc Steve Wise <[email protected]>

---

* Change from v1
- leave net_random() callers as-is because that is a useful indirection

 drivers/infiniband/hw/cxgb3/cxio_resource.c | 4 ++--
 drivers/infiniband/hw/cxgb4/id_table.c      | 4 ++--
 drivers/infiniband/hw/mlx4/mad.c            | 2 +-
 drivers/infiniband/ulp/ipoib/ipoib_cm.c     | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/infiniband/hw/cxgb3/cxio_resource.c +2 -2
index 31f9201..c40088e 100644
@@ -62,13 +62,13 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo,
 		kfifo_in(fifo, (unsigned char *) &entry, sizeof(u32));
 	if (random) {
 		j = 0;
-		random_bytes = random32();
+		random_bytes = prandom_u32();
 		for (i = 0; i < RANDOM_SIZE; i++)
 			rarray[i] = i + skip_low;
 		for (i = skip_low + RANDOM_SIZE; i < nr - skip_high; i++) {
 			if (j >= RANDOM_SIZE) {
 				j = 0;
-				random_bytes = random32();
+				random_bytes = prandom_u32();
 			}
 			idx = (random_bytes >> (j * 2)) & 0xF;
 			kfifo_in(fifo,
drivers/infiniband/hw/cxgb4/id_table.c +2 -2
index f95e5df..0161ae6 100644
@@ -54,7 +54,7 @@ u32 c4iw_id_alloc(struct c4iw_id_table *alloc)
 
 	if (obj < alloc->max) {
 		if (alloc->flags & C4IW_ID_TABLE_F_RANDOM)
-			alloc->last += random32() % RANDOM_SKIP;
+			alloc->last += prandom_u32() % RANDOM_SKIP;
 		else
 			alloc->last = obj + 1;
 		if (alloc->last >= alloc->max)
@@ -88,7 +88,7 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num,
 	alloc->start = start;
 	alloc->flags = flags;
 	if (flags & C4IW_ID_TABLE_F_RANDOM)
-		alloc->last = random32() % RANDOM_SKIP;
+		alloc->last = prandom_u32() % RANDOM_SKIP;
 	else
 		alloc->last = 0;
 	alloc->max  = num;
drivers/infiniband/hw/mlx4/mad.c +1 -1
index 0a903c1..b247c5b 100644
@@ -93,7 +93,7 @@ static void __propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
 __be64 mlx4_ib_gen_node_guid(void)
 {
 #define NODE_GUID_HI	((u64) (((u64)IB_OPENIB_OUI) << 40))
-	return cpu_to_be64(NODE_GUID_HI | random32());
+	return cpu_to_be64(NODE_GUID_HI | prandom_u32());
 }
 
 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
drivers/infiniband/ulp/ipoib/ipoib_cm.c +1 -1
index 03103d2..0e0016d 100644
@@ -460,7 +460,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even
 		goto err_qp;
 	}
 
-	psn = random32() & 0xffffff;
+	psn = prandom_u32() & 0xffffff;
 	ret = ipoib_cm_modify_rx_qp(dev, cm_id, p->qp, psn);
 	if (ret)
 		goto err_modify;
Signature · 6 lines
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw

Re: [PATCH -v2 09/26] infiniband: rename random32() to prandom_u32()

Are there other "non pseudo-random" services that warrant this rename?

Quoted 80 lines · Akinobu Mita

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

Cc Roland Dreier <[email protected]>
Cc Sean Hefty <[email protected]>
Cc Hal Rosenstock <[email protected]>
Cc Steve Wise <[email protected]>

---

* Change from v1
- leave net_random() callers as-is because that is a useful indirection

  drivers/infiniband/hw/cxgb3/cxio_resource.c | 4 ++--
  drivers/infiniband/hw/cxgb4/id_table.c      | 4 ++--
  drivers/infiniband/hw/mlx4/mad.c            | 2 +-
  drivers/infiniband/ulp/ipoib/ipoib_cm.c     | 2 +-
  4 files changed, 6 insertions(+), 6 deletions(-)
drivers/infiniband/hw/cxgb3/cxio_resource.c +2 -2
index 31f9201..c40088e 100644
@@ -62,13 +62,13 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo,
  		kfifo_in(fifo, (unsigned char *) &entry, sizeof(u32));
  	if (random) {
  		j = 0;
-		random_bytes = random32();
+		random_bytes = prandom_u32();
  		for (i = 0; i < RANDOM_SIZE; i++)
  			rarray[i] = i + skip_low;
  		for (i = skip_low + RANDOM_SIZE; i < nr - skip_high; i++) {
  			if (j >= RANDOM_SIZE) {
  				j = 0;
-				random_bytes = random32();
+				random_bytes = prandom_u32();
  			}
  			idx = (random_bytes >> (j * 2)) & 0xF;
  			kfifo_in(fifo,
drivers/infiniband/hw/cxgb4/id_table.c +2 -2
index f95e5df..0161ae6 100644
@@ -54,7 +54,7 @@ u32 c4iw_id_alloc(struct c4iw_id_table *alloc)
 
  	if (obj < alloc->max) {
  		if (alloc->flags & C4IW_ID_TABLE_F_RANDOM)
-			alloc->last += random32() % RANDOM_SKIP;
+			alloc->last += prandom_u32() % RANDOM_SKIP;
  		else
  			alloc->last = obj + 1;
  		if (alloc->last >= alloc->max)
@@ -88,7 +88,7 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num,
  	alloc->start = start;
  	alloc->flags = flags;
  	if (flags & C4IW_ID_TABLE_F_RANDOM)
-		alloc->last = random32() % RANDOM_SKIP;
+		alloc->last = prandom_u32() % RANDOM_SKIP;
  	else
  		alloc->last = 0;
  	alloc->max  = num;
drivers/infiniband/hw/mlx4/mad.c +1 -1
index 0a903c1..b247c5b 100644
@@ -93,7 +93,7 @@ static void __propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
  __be64 mlx4_ib_gen_node_guid(void)
  {
  #define NODE_GUID_HI	((u64) (((u64)IB_OPENIB_OUI) << 40))
-	return cpu_to_be64(NODE_GUID_HI | random32());
+	return cpu_to_be64(NODE_GUID_HI | prandom_u32());
  }
 
  __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
drivers/infiniband/ulp/ipoib/ipoib_cm.c +0 -0
index 03103d2..0e0016d 100644

drivers/infiniband/ulp/ipoib/ipoib_cm.c static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even · line 466

Quoted 8 lines
drivers/infiniband/ulp/ipoib/ipoib_cm.c +1 -1
@@ -460,7 +460,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even
  		goto err_qp;
  	}
 
-	psn = random32() & 0xffffff;
+	psn = prandom_u32() & 0xffffff;
  	ret = ipoib_cm_modify_rx_qp(dev, cm_id, p->qp, psn);
  	if (ret)
  		goto err_modify;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#13 lore raw

Re: [PATCH -v2 09/26] infiniband: rename random32() to prandom_u32()

2013/1/4 Steve Wise <[email protected]>:

Quoted 1 line

Are there other "non pseudo-random" services that warrant this rename?

I couldn't understand your question very well. So I'm not sure this is the expected answer:
I only renamed pseudo-random functions defined in lib/random32.c in the commit 496f2f93 ("random32: rename random32 to prandom"). This patch series aims for finishing the naming transition and removing the backword compatibility wrapper macros. Non pseudo-random functions are unrelated to this patch series.

#14 lore raw

Re: [PATCH -v2 09/26] infiniband: rename random32() to prandom_u32()

I'm asking: why are you bothering with renaming the functions? This seems like a needless change, _unless_ there are really non-pseudo-random services being added.

Quoted 9 lines · Akinobu Mita

2013/1/4 Steve Wise <[email protected]>:

Quoted 1 line

Are there other "non pseudo-random" services that warrant this rename?

I couldn't understand your question very well. So I'm not sure this is the expected answer:
I only renamed pseudo-random functions defined in lib/random32.c in the commit 496f2f93 ("random32: rename random32 to prandom"). This patch series aims for finishing the naming transition and removing the backword compatibility wrapper macros. Non pseudo-random functions are unrelated to this patch series.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#15 lore raw

Re: [PATCH -v2 09/26] infiniband: rename random32() to prandom_u32()

2013/1/5 Steve Wise <[email protected]>:

Quoted 3 lines

I'm asking: why are you bothering with renaming the functions? This seems like a needless change, _unless_ there are really non-pseudo-random services being added.

We already have get_random_byte() which is not pseudo-random number generator.

Apart from that, the naming scheme was confusing without "prandom" prefix. Because I introduced new functions in the commit 6582c665 ("prandom:
introduce prandom_bytes() and prandom_bytes_state()").

#16 lore raw

Re: [PATCH -v2 09/26] infiniband: rename random32() to prandom_u32()

Quoted 10 lines · Akinobu Mita

2013/1/5 Steve Wise <[email protected]>:

Quoted 3 lines

I'm asking: why are you bothering with renaming the functions? This seems like a needless change, _unless_ there are really non-pseudo-random services being added.

We already have get_random_byte() which is not pseudo-random number generator.

Apart from that, the naming scheme was confusing without "prandom" prefix. Because I introduced new functions in the commit 6582c665 ("prandom:
introduce prandom_bytes() and prandom_bytes_state()").

Ok, thanks for the explanation.

author maintainer
#18 lore raw

PATCH 10/26 mmc: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 drivers/mmc/core/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/core/core.c +2 -2
index aaed768..4b05da5 100644
@@ -120,8 +120,8 @@ static void mmc_should_fail_request(struct mmc_host *host,
 	    !should_fail(&host->fail_mmc_request, data->blksz * data->blocks))
 		return;
 
-	data->error = data_errors[random32() % ARRAY_SIZE(data_errors)];
-	data->bytes_xfered = (random32() % (data->bytes_xfered >> 9)) << 9;
+	data->error = data_errors[prandom_u32() % ARRAY_SIZE(data_errors)];
+	data->bytes_xfered = (prandom_u32() % (data->bytes_xfered >> 9)) << 9;
 }
 
 #else /* CONFIG_FAIL_MMC_REQUEST */
Signature · 1 line
1.7.11.7
author maintainer
#19 lore raw

PATCH 11/26 video/uvesafb: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

Cc Michal Januszewski <[email protected]>
Cc Florian Tobias Schandinat <[email protected]>

---

No change from v1

 drivers/video/uvesafb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/uvesafb.c +1 -1
index 2f8f82d..d120b11 100644
@@ -166,7 +166,7 @@ static int uvesafb_exec(struct uvesafb_ktask *task)
 	memcpy(&m->id, &uvesafb_cn_id, sizeof(m->id));
 	m->seq = seq;
 	m->len = len;
-	m->ack = random32();
+	m->ack = prandom_u32();
 
 	/* uvesafb_task structure */
 	memcpy(m + 1, &task->t, sizeof(task->t));
Signature · 1 line
1.7.11.7
author maintainer
#20 lore raw

PATCH 12/26 xfs: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 fs/xfs/xfs_alloc.c  | 2 +-
 fs/xfs/xfs_error.c  | 2 +-
 fs/xfs/xfs_ialloc.c | 2 +-
 fs/xfs/xfs_log.c    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
fs/xfs/xfs_alloc.c +1 -1
index 393055f..d2dd19d 100644
@@ -842,7 +842,7 @@ xfs_alloc_ag_vextent_near(
 	 */
 	int		dofirst;	/* set to do first algorithm */
 
-	dofirst = random32() & 1;
+	dofirst = prandom_u32() & 1;
 #endif
 
 restart:
fs/xfs/xfs_error.c +1 -1
index 6104560..07bf3b9 100644
@@ -66,7 +66,7 @@ xfs_error_test(int error_tag, int *fsidp, char *expression,
 	int i;
 	int64_t fsid;
 
-	if (random32() % randfactor)
+	if (prandom_u32() % randfactor)
 		return 0;
 
 	memcpy(&fsid, fsidp, sizeof(xfs_fsid_t));
fs/xfs/xfs_ialloc.c +1 -1
index a815412..6c75865 100644
@@ -373,7 +373,7 @@ xfs_ialloc_ag_alloc(
 	 * number from being easily guessable.
 	 */
 	error = xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno,
-			args.len, random32());
+			args.len, prandom_u32());
 
 	if (error)
 		return error;
fs/xfs/xfs_log.c +1 -1
index 46bd9d5..92e036b 100644
@@ -3485,7 +3485,7 @@ xlog_ticket_alloc(
 	tic->t_curr_res		= unit_bytes;
 	tic->t_cnt		= cnt;
 	tic->t_ocnt		= cnt;
-	tic->t_tid		= random32();
+	tic->t_tid		= prandom_u32();
 	tic->t_clientid		= client;
 	tic->t_flags		= XLOG_TIC_INITED;
 	tic->t_trans_type	= 0;
Signature · 1 line
1.7.11.7
author maintainer
#22 lore raw

PATCH 13/26 ubifs: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

Cc Artem Bityutskiy <[email protected]>
Cc Adrian Hunter <[email protected]>

---

No change from v1

 fs/ubifs/debug.c      |  8 ++++----
 fs/ubifs/lpt_commit.c | 14 +++++++-------
 fs/ubifs/tnc_commit.c |  2 +-
 3 files changed, 12 insertions(+), 12 deletions(-)
fs/ubifs/debug.c +4 -4
index 12817ff..7f60e90 100644
@@ -2459,7 +2459,7 @@ error_dump:
 
 static inline int chance(unsigned int n, unsigned int out_of)
 {
-	return !!((random32() % out_of) + 1 <= n);
+	return !!((prandom_u32() % out_of) + 1 <= n);
 
 }
 
@@ -2477,13 +2477,13 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write)
 			if (chance(1, 2)) {
 				d->pc_delay = 1;
 				/* Fail withing 1 minute */
-				delay = random32() % 60000;
+				delay = prandom_u32() % 60000;
 				d->pc_timeout = jiffies;
 				d->pc_timeout += msecs_to_jiffies(delay);
 				ubifs_warn("failing after %lums", delay);
 			} else {
 				d->pc_delay = 2;
-				delay = random32() % 10000;
+				delay = prandom_u32() % 10000;
 				/* Fail within 10000 operations */
 				d->pc_cnt_max = delay;
 				ubifs_warn("failing after %lu calls", delay);
@@ -2563,7 +2563,7 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf,
 	unsigned int from, to, ffs = chance(1, 2);
 	unsigned char *p = (void *)buf;
 
-	from = random32() % (len + 1);
+	from = prandom_u32() % (len + 1);
 	/* Corruption may only span one max. write unit */
 	to = min(len, ALIGN(from, c->max_write_size));
 
fs/ubifs/lpt_commit.c +7 -7
index 9daaeef..4b826ab 100644
@@ -2007,28 +2007,28 @@ static int dbg_populate_lsave(struct ubifs_info *c)
 
 	if (!dbg_is_chk_gen(c))
 		return 0;
-	if (random32() & 3)
+	if (prandom_u32() & 3)
 		return 0;
 
 	for (i = 0; i < c->lsave_cnt; i++)
 		c->lsave[i] = c->main_first;
 
 	list_for_each_entry(lprops, &c->empty_list, list)
-		c->lsave[random32() % c->lsave_cnt] = lprops->lnum;
+		c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
 	list_for_each_entry(lprops, &c->freeable_list, list)
-		c->lsave[random32() % c->lsave_cnt] = lprops->lnum;
+		c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
 	list_for_each_entry(lprops, &c->frdi_idx_list, list)
-		c->lsave[random32() % c->lsave_cnt] = lprops->lnum;
+		c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
 
 	heap = &c->lpt_heap[LPROPS_DIRTY_IDX - 1];
 	for (i = 0; i < heap->cnt; i++)
-		c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum;
+		c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
 	heap = &c->lpt_heap[LPROPS_DIRTY - 1];
 	for (i = 0; i < heap->cnt; i++)
-		c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum;
+		c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
 	heap = &c->lpt_heap[LPROPS_FREE - 1];
 	for (i = 0; i < heap->cnt; i++)
-		c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum;
+		c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
 
 	return 1;
 }
fs/ubifs/tnc_commit.c +1 -1
index 523bbad..52a6559 100644
@@ -683,7 +683,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt)
 		c->ilebs[c->ileb_cnt++] = lnum;
 		dbg_cmt("LEB %d", lnum);
 	}
-	if (dbg_is_chk_index(c) && !(random32() & 7))
+	if (dbg_is_chk_index(c) && !(prandom_u32() & 7))
 		return -ENOSPC;
 	return 0;
 }
Signature · 1 line
1.7.11.7
#23 lore raw

Re: [PATCH -v2 13/26] ubifs: rename random32() to prandom_u32()

Quoted 4 lines · Akinobu Mita

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

Pushed to linux-ubifs.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
author maintainer
#24 lore raw

PATCH 14/26 uwb: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 drivers/uwb/rsv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/uwb/rsv.c +2 -2
index 0b0d8bc..f4ae05f 100644
@@ -231,7 +231,7 @@ void uwb_rsv_backoff_win_increment(struct uwb_rc *rc)
 		return;
 
 	bow->window <<= 1;
-	bow->n = random32() & (bow->window - 1);
+	bow->n = prandom_u32() & (bow->window - 1);
 	dev_dbg(dev, "new_window=%d, n=%d\n: ", bow->window, bow->n);
 
 	/* reset the timer associated variables */
@@ -557,7 +557,7 @@ int uwb_rsv_establish(struct uwb_rsv *rsv)
 	if (ret)
 		goto out;
 
-	rsv->tiebreaker = random32() & 1;
+	rsv->tiebreaker = prandom_u32() & 1;
 	/* get available mas bitmap */
 	uwb_drp_available(rc, &available);
 
Signature · 1 line
1.7.11.7
author maintainer
#25 lore raw

PATCH 15/26 lguest: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 drivers/lguest/page_tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/lguest/page_tables.c +1 -1
index 3b62be16..864baab 100644
@@ -686,7 +686,7 @@ static unsigned int new_pgdir(struct lg_cpu *cpu,
 	 * We pick one entry at random to throw out.  Choosing the Least
 	 * Recently Used might be better, but this is easy.
 	 */
-	next = random32() % ARRAY_SIZE(cpu->lg->pgdirs);
+	next = prandom_u32() % ARRAY_SIZE(cpu->lg->pgdirs);
 	/* If it's never been allocated at all before, try now. */
 	if (!cpu->lg->pgdirs[next].pgdir) {
 		cpu->lg->pgdirs[next].pgdir =
Signature · 1 line
1.7.11.7
author maintainer
#26 lore raw

PATCH 16/26 scsi: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 drivers/scsi/fcoe/fcoe_ctlr.c    | 4 ++--
 drivers/scsi/lpfc/lpfc_hbadisc.c | 6 +++---
 drivers/scsi/qla2xxx/qla_attr.c  | 7 +++++--
 3 files changed, 10 insertions(+), 7 deletions(-)
drivers/scsi/fcoe/fcoe_ctlr.c +2 -2
index 4a909d7..d870ccc 100644
@@ -2153,7 +2153,7 @@ static void fcoe_ctlr_vn_restart(struct fcoe_ctlr *fip)
 
 	if (fip->probe_tries < FIP_VN_RLIM_COUNT) {
 		fip->probe_tries++;
-		wait = random32() % FIP_VN_PROBE_WAIT;
+		wait = prandom_u32() % FIP_VN_PROBE_WAIT;
 	} else
 		wait = FIP_VN_RLIM_INT;
 	mod_timer(&fip->timer, jiffies + msecs_to_jiffies(wait));
@@ -2786,7 +2786,7 @@ static void fcoe_ctlr_vn_timeout(struct fcoe_ctlr *fip)
 					  fcoe_all_vn2vn, 0);
 			fip->port_ka_time = jiffies +
 				 msecs_to_jiffies(FIP_VN_BEACON_INT +
-					(random32() % FIP_VN_BEACON_FUZZ));
+					(prandom_u32() % FIP_VN_BEACON_FUZZ));
 		}
 		if (time_before(fip->port_ka_time, next_time))
 			next_time = fip->port_ka_time;
drivers/scsi/lpfc/lpfc_hbadisc.c +3 -3
index d7096ad..bfda184 100644
@@ -1732,7 +1732,7 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf)
  * use through a sequence of @fcf_cnt eligible FCF records with equal
  * probability. To perform integer manunipulation of random numbers with
  * size unit32_t, the lower 16 bits of the 32-bit random number returned
- * from random32() are taken as the random random number generated.
+ * from prandom_u32() are taken as the random random number generated.
  *
  * Returns true when outcome is for the newly read FCF record should be
  * chosen; otherwise, return false when outcome is for keeping the previously
@@ -1744,7 +1744,7 @@ lpfc_sli4_new_fcf_random_select(struct lpfc_hba *phba, uint32_t fcf_cnt)
 	uint32_t rand_num;
 
 	/* Get 16-bit uniform random number */
-	rand_num = (0xFFFF & random32());
+	rand_num = 0xFFFF & prandom_u32();
 
 	/* Decision with probability 1/fcf_cnt */
 	if ((fcf_cnt * rand_num) < 0xFFFF)
@@ -2380,7 +2380,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 		phba->fcf.eligible_fcf_cnt = 1;
 		/* Seeding the random number generator for random selection */
 		seed = (uint32_t)(0xFFFFFFFF & jiffies);
-		srandom32(seed);
+		prandom_seed(seed);
 	}
 	spin_unlock_irq(&phba->hbalock);
 	goto read_next_fcf;
drivers/scsi/qla2xxx/qla_attr.c +5 -2
index 83d7984..3658e9f 100644
@@ -1933,8 +1933,11 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
 
 	/* No pending activities shall be there on the vha now */
 	if (ql2xextended_error_logging & ql_dbg_user)
-		msleep(random32()%10);  /* Just to see if something falls on
-					* the net we have placed below */
+		msleep(prandom_u32() % 10);
+		/*
+		 * Just to see if something falls on the net we have placed
+		 * below
+		 */
 
 	BUG_ON(atomic_read(&vha->vref_count));
 
Signature · 1 line
1.7.11.7
author maintainer
#27 lore raw

PATCH 17/26 mtd: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

Cc David Woodhouse <[email protected]>
Cc Artem Bityutskiy <[email protected]>

---

No change from v1

 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(-)
drivers/mtd/nand/nandsim.c +3 -3
index 818b65c..4c31798 100644
@@ -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",
drivers/mtd/tests/mtd_nandecctest.c +5 -5
index ceb261f..2e6b41e 100644
@@ -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;
drivers/mtd/tests/mtd_stresstest.c +4 -4
index dc89e32..4e9fc1f 100644
@@ -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();
drivers/mtd/ubi/debug.h +3 -3
index 33f8f3b..cba89fc 100644
@@ -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;
 }
 
Signature · 1 line
1.7.11.7
#28 lore raw

Re: [PATCH -v2 17/26] mtd: rename random32() to prandom_u32()

Quoted 4 lines · Akinobu Mita

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

Pushed to l2-mtd.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
author maintainer
#29 lore raw

PATCH 18/26 drivers/net: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 drivers/net/ethernet/broadcom/cnic.c    | 4 ++--
 drivers/net/hamradio/baycom_epp.c       | 2 +-
 drivers/net/hamradio/hdlcdrv.c          | 2 +-
 drivers/net/hamradio/yam.c              | 2 +-
 drivers/net/wireless/mwifiex/cfg80211.c | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +2 -2
index df8c30d..27d7a32 100644
@@ -4085,7 +4085,7 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
 	if (!cp->csk_tbl)
 		return -ENOMEM;
 
-	port_id = random32();
+	port_id = prandom_u32();
 	port_id %= CNIC_LOCAL_PORT_RANGE;
 	if (cnic_init_id_tbl(&cp->csk_port_tbl, CNIC_LOCAL_PORT_RANGE,
 			     CNIC_LOCAL_PORT_MIN, port_id)) {
@@ -4145,7 +4145,7 @@ static int cnic_cm_init_bnx2_hw(struct cnic_dev *dev)
 {
 	u32 seed;
 
-	seed = random32();
+	seed = prandom_u32();
 	cnic_ctx_wr(dev, 45, 0, seed);
 	return 0;
 }
drivers/net/hamradio/baycom_epp.c +1 -1
index 49b8b58..484f77e 100644
@@ -449,7 +449,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
 			if ((--bc->hdlctx.slotcnt) > 0)
 				return 0;
 			bc->hdlctx.slotcnt = bc->ch_params.slottime;
-			if ((random32() % 256) > bc->ch_params.ppersist)
+			if ((prandom_u32() % 256) > bc->ch_params.ppersist)
 				return 0;
 		}
 	}
drivers/net/hamradio/hdlcdrv.c +1 -1
index a4a3516..3169252 100644
@@ -389,7 +389,7 @@ void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
 	if ((--s->hdlctx.slotcnt) > 0)
 		return;
 	s->hdlctx.slotcnt = s->ch_params.slottime;
-	if ((random32() % 256) > s->ch_params.ppersist)
+	if ((prandom_u32() % 256) > s->ch_params.ppersist)
 		return;
 	start_tx(dev, s);
 }
drivers/net/hamradio/yam.c +1 -1
index c6645f1..21f231a 100644
@@ -638,7 +638,7 @@ static void yam_arbitrate(struct net_device *dev)
 	yp->slotcnt = yp->slot / 10;
 
 	/* is random > persist ? */
-	if ((random32() % 256) > yp->pers)
+	if ((prandom_u32() % 256) > yp->pers)
 		return;
 
 	yam_start_tx(dev, yp);
drivers/net/wireless/mwifiex/cfg80211.c +2 -2
index a875499..78dbc18 100644
@@ -216,7 +216,7 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 	mwifiex_form_mgmt_frame(skb, buf, len);
 	mwifiex_queue_tx_pkt(priv, skb);
 
-	*cookie = random32() | 1;
+	*cookie = prandom_u32() | 1;
 	cfg80211_mgmt_tx_status(wdev, *cookie, buf, len, true, GFP_ATOMIC);
 
 	wiphy_dbg(wiphy, "info: management frame transmitted\n");
@@ -271,7 +271,7 @@ mwifiex_cfg80211_remain_on_channel(struct wiphy *wiphy,
 					 duration);
 
 	if (!ret) {
-		*cookie = random32() | 1;
+		*cookie = prandom_u32() | 1;
 		priv->roc_cfg.cookie = *cookie;
 		priv->roc_cfg.chan = *chan;
 
Signature · 1 line
1.7.11.7
Acked-by on v1 18/26
#30 lore raw

RE: [PATCH -v2 18/26] drivers/net: rename random32() to prandom_u32()

Hi Akinobu,

Quoted 13 lines

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

Thanks,
Bing

Quoted 10 lines

---

No change from v1

 drivers/net/ethernet/broadcom/cnic.c    | 4 ++--
 drivers/net/hamradio/baycom_epp.c       | 2 +-
 drivers/net/hamradio/hdlcdrv.c          | 2 +-
 drivers/net/hamradio/yam.c              | 2 +-
 drivers/net/wireless/mwifiex/cfg80211.c | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)
author maintainer
#31 lore raw

PATCH 19/26 batman-adv: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

No change from v1

 net/batman-adv/bat_iv_ogm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/batman-adv/bat_iv_ogm.c +2 -2
index 7d02ebd..bc434c4 100644
@@ -123,7 +123,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
 	unsigned int msecs;
 
 	msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
-	msecs += random32() % (2 * BATADV_JITTER);
+	msecs += prandom_u32() % (2 * BATADV_JITTER);
 
 	return jiffies + msecs_to_jiffies(msecs);
 }
@@ -131,7 +131,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
 /* when do we schedule a ogm packet to be sent */
 static unsigned long batadv_iv_ogm_fwd_send_time(void)
 {
-	return jiffies + msecs_to_jiffies(random32() % (BATADV_JITTER / 2));
+	return jiffies + msecs_to_jiffies(prandom_u32() % (BATADV_JITTER / 2));
 }
 
 /* apply hop penalty for a normal link */
Signature · 1 line
1.7.11.7
#32 lore raw

Re: [PATCH -v2 19/26] batman-adv: rename random32() to prandom_u32()

Quoted 11 lines · Akinobu Mita

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

Quoted 1 line

---

Hello Akinobu,

as you can see in <[email protected]>, Marek Lindner already applied this change onto our tree. You didn't need to resend this patch to netdev, it will be sent by us through a future pull request.

Thanks a lot.
Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
author maintainer
#33 lore raw

Re: [PATCH -v2 19/26] batman-adv: rename random32() to prandom_u32()

2013/1/4 Antonio Quartulli <[email protected]>:

Quoted 14 lines · Akinobu Mita
Quoted 11 lines

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

Quoted 1 line

---

Quoted 5 lines

Hello Akinobu,

as you can see in <[email protected]>, Marek Lindner already applied this change onto our tree. You didn't need to resend this patch to netdev, it will be sent by us through a future pull request.

Yes. I read Marek's email. But I included it in v2 again in order not to break the build. Because it doesn't show up the latest linux-next yet and the last patch 26/26 removes random32() and srandom32().

But I should have mentioned it and trimmed the Cc list. Sorry for the confusion.

#34 lore raw

Re: [PATCH -v2 19/26] batman-adv: rename random32() to prandom_u32()

Quoted 21 lines · Akinobu Mita

2013/1/4 Antonio Quartulli <[email protected]>:

Quoted 14 lines · Akinobu Mita
Quoted 11 lines

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

Quoted 1 line

---

Quoted 5 lines

Hello Akinobu,

as you can see in <[email protected]>, Marek Lindner already applied this change onto our tree. You didn't need to resend this patch to netdev, it will be sent by us through a future pull request.

Quoted 6 lines

Yes. I read Marek's email. But I included it in v2 again in order not to break the build. Because it doesn't show up the latest linux-next yet and the last patch 26/26 removes random32() and srandom32().

But I should have mentioned it and trimmed the Cc list. Sorry for the confusion.

Ok..everything is fine as soon David won't apply this patch. Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
author maintainer
#35 lore raw

PATCH 20/26 net/sunrpc: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

Cc "J. Bruce Fields" <[email protected]>
Cc Trond Myklebust <[email protected]>
Cc "David S. Miller" <[email protected]>

---

* Change from v1
- leave net_random() callers as-is because that is a useful indirection

 net/sunrpc/auth_gss/gss_krb5_wrap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/auth_gss/gss_krb5_wrap.c +2 -2
index 107c452..daf301f 100644
@@ -130,8 +130,8 @@ gss_krb5_make_confounder(char *p, u32 conflen)
 
 	/* initialize to random value */
 	if (i == 0) {
-		i = random32();
-		i = (i << 32) | random32();
+		i = prandom_u32();
+		i = (i << 32) | prandom_u32();
 	}
 
 	switch (conflen) {
Signature · 1 line
1.7.11.7
author maintainer
#36 lore raw

PATCH 21/26 net/sched: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

* Change from v1
- leave net_random() callers as-is because that is a useful indirection

 net/sched/sch_choke.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_choke.c +1 -1
index cc37dd5..ef53ab8 100644
@@ -80,7 +80,7 @@ struct choke_sched_data {
 /* deliver a random number between 0 and N - 1 */
 static u32 random_N(unsigned int N)
 {
-	return reciprocal_divide(random32(), N);
+	return reciprocal_divide(prandom_u32(), N);
 }
 
 /* number of elements in queue including holes */
Signature · 1 line
1.7.11.7
author maintainer
#37 lore raw

PATCH 22/26 net/netfilter: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

* Change from v1
- leave net_random() callers as-is because that is a useful indirection

 net/netfilter/nf_conntrack_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_core.c +2 -2
index 08cdc71..a8f5c7a 100644
@@ -263,7 +263,7 @@ static void death_by_event(unsigned long ul_conntrack)
 	if (nf_conntrack_event(IPCT_DESTROY, ct) < 0) {
 		/* bad luck, let's retry again */
 		ecache->timeout.expires = jiffies +
-			(random32() % net->ct.sysctl_events_retry_timeout);
+			(prandom_u32() % net->ct.sysctl_events_retry_timeout);
 		add_timer(&ecache->timeout);
 		return;
 	}
@@ -282,7 +282,7 @@ void nf_ct_dying_timeout(struct nf_conn *ct)
 	/* set a new timer to retry event delivery */
 	setup_timer(&ecache->timeout, death_by_event, (unsigned long)ct);
 	ecache->timeout.expires = jiffies +
-		(random32() % net->ct.sysctl_events_retry_timeout);
+		(prandom_u32() % net->ct.sysctl_events_retry_timeout);
 	add_timer(&ecache->timeout);
 }
 EXPORT_SYMBOL_GPL(nf_ct_dying_timeout);
Signature · 1 line
1.7.11.7
author maintainer
#38 lore raw

PATCH 23/26 net/core: rename random32() to prandom_u32()

In reply to Akinobu Mita

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

---

* Change from v1
- leave net_random() callers as-is because that is a useful indirection

 net/core/pktgen.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
net/core/pktgen.c +15 -14
index b29dacf..d23ec86 100644
@@ -2182,7 +2182,7 @@ static inline int f_pick(struct pktgen_dev *pkt_dev)
 				pkt_dev->curfl = 0; /*reset */
 		}
 	} else {
-		flow = random32() % pkt_dev->cflows;
+		flow = prandom_u32() % pkt_dev->cflows;
 		pkt_dev->curfl = flow;
 
 		if (pkt_dev->flows[flow].count > pkt_dev->lflow) {
@@ -2229,7 +2229,7 @@ static void set_cur_queue_map(struct pktgen_dev *pkt_dev)
 	else if (pkt_dev->queue_map_min <= pkt_dev->queue_map_max) {
 		__u16 t;
 		if (pkt_dev->flags & F_QUEUE_MAP_RND) {
-			t = random32() %
+			t = prandom_u32() %
 				(pkt_dev->queue_map_max -
 				 pkt_dev->queue_map_min + 1)
 				+ pkt_dev->queue_map_min;
@@ -2261,7 +2261,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		__u32 tmp;
 
 		if (pkt_dev->flags & F_MACSRC_RND)
-			mc = random32() % pkt_dev->src_mac_count;
+			mc = prandom_u32() % pkt_dev->src_mac_count;
 		else {
 			mc = pkt_dev->cur_src_mac_offset++;
 			if (pkt_dev->cur_src_mac_offset >=
@@ -2287,7 +2287,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		__u32 tmp;
 
 		if (pkt_dev->flags & F_MACDST_RND)
-			mc = random32() % pkt_dev->dst_mac_count;
+			mc = prandom_u32() % pkt_dev->dst_mac_count;
 
 		else {
 			mc = pkt_dev->cur_dst_mac_offset++;
@@ -2314,21 +2314,21 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		for (i = 0; i < pkt_dev->nr_labels; i++)
 			if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
 				pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
-					     ((__force __be32)random32() &
+					     ((__force __be32)prandom_u32() &
 						      htonl(0x000fffff));
 	}
 
 	if ((pkt_dev->flags & F_VID_RND) && (pkt_dev->vlan_id != 0xffff)) {
-		pkt_dev->vlan_id = random32() & (4096-1);
+		pkt_dev->vlan_id = prandom_u32() & (4096 - 1);
 	}
 
 	if ((pkt_dev->flags & F_SVID_RND) && (pkt_dev->svlan_id != 0xffff)) {
-		pkt_dev->svlan_id = random32() & (4096 - 1);
+		pkt_dev->svlan_id = prandom_u32() & (4096 - 1);
 	}
 
 	if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) {
 		if (pkt_dev->flags & F_UDPSRC_RND)
-			pkt_dev->cur_udp_src = random32() %
+			pkt_dev->cur_udp_src = prandom_u32() %
 				(pkt_dev->udp_src_max - pkt_dev->udp_src_min)
 				+ pkt_dev->udp_src_min;
 
@@ -2341,7 +2341,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 
 	if (pkt_dev->udp_dst_min < pkt_dev->udp_dst_max) {
 		if (pkt_dev->flags & F_UDPDST_RND) {
-			pkt_dev->cur_udp_dst = random32() %
+			pkt_dev->cur_udp_dst = prandom_u32() %
 				(pkt_dev->udp_dst_max - pkt_dev->udp_dst_min)
 				+ pkt_dev->udp_dst_min;
 		} else {
@@ -2358,7 +2358,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 		if (imn < imx) {
 			__u32 t;
 			if (pkt_dev->flags & F_IPSRC_RND)
-				t = random32() % (imx - imn) + imn;
+				t = prandom_u32() % (imx - imn) + imn;
 			else {
 				t = ntohl(pkt_dev->cur_saddr);
 				t++;
@@ -2379,7 +2379,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 				__be32 s;
 				if (pkt_dev->flags & F_IPDST_RND) {
 
-					t = random32() % (imx - imn) + imn;
+					t = prandom_u32() % (imx - imn) + imn;
 					s = htonl(t);
 
 					while (ipv4_is_loopback(s) ||
@@ -2387,7 +2387,8 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 					       ipv4_is_lbcast(s) ||
 					       ipv4_is_zeronet(s) ||
 					       ipv4_is_local_multicast(s)) {
-						t = random32() % (imx - imn) + imn;
+						t = prandom_u32() %
+							(imx - imn) + imn;
 						s = htonl(t);
 					}
 					pkt_dev->cur_daddr = s;
@@ -2420,7 +2421,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 
 			for (i = 0; i < 4; i++) {
 				pkt_dev->cur_in6_daddr.s6_addr32[i] =
-				    (((__force __be32)random32() |
+				    (((__force __be32)prandom_u32() |
 				      pkt_dev->min_in6_daddr.s6_addr32[i]) &
 				     pkt_dev->max_in6_daddr.s6_addr32[i]);
 			}
@@ -2430,7 +2431,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 	if (pkt_dev->min_pkt_size < pkt_dev->max_pkt_size) {
 		__u32 t;
 		if (pkt_dev->flags & F_TXSIZE_RND) {
-			t = random32() %
+			t = prandom_u32() %
 				(pkt_dev->max_pkt_size - pkt_dev->min_pkt_size)
 				+ pkt_dev->min_pkt_size;
 		} else {
Signature · 1 line
1.7.11.7
author maintainer
#39 lore raw

PATCH 24/26 net/core: remove duplicate statements by do-while loop

In reply to Akinobu Mita

Remove duplicate statements by using do-while loop instead of while loop.

- A;
- while (e) {

+ do {
	A;

- }
+ } while (e);

---

No change from v1

 net/core/pktgen.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
net/core/pktgen.c +6 -9
index d23ec86..48a3a29 100644
@@ -2379,18 +2379,15 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 				__be32 s;
 				if (pkt_dev->flags & F_IPDST_RND) {
 
-					t = prandom_u32() % (imx - imn) + imn;
-					s = htonl(t);
-
-					while (ipv4_is_loopback(s) ||
-					       ipv4_is_multicast(s) ||
-					       ipv4_is_lbcast(s) ||
-					       ipv4_is_zeronet(s) ||
-					       ipv4_is_local_multicast(s)) {
+					do {
 						t = prandom_u32() %
 							(imx - imn) + imn;
 						s = htonl(t);
-					}
+					} while (ipv4_is_loopback(s) ||
+						ipv4_is_multicast(s) ||
+						ipv4_is_lbcast(s) ||
+						ipv4_is_zeronet(s) ||
+						ipv4_is_local_multicast(s));
 					pkt_dev->cur_daddr = s;
 				} else {
 					t = ntohl(pkt_dev->cur_daddr);
Signature · 1 line
1.7.11.7
author maintainer
#40 lore raw

PATCH 25/26 net: rename random32 to prandom

In reply to Akinobu Mita

Commit 496f2f93b1cc286f5a4f4f9acdc1e5314978683f ("random32: rename random32 to prandom") renamed random32() and srandom32() to prandom_u32() and prandom_seed() respectively.

net_random() and net_srandom() need to be redefined with prandom_* in order to finish the naming transition.

While I'm at it, enclose macro argument of net_srandom() with parenthesis.

---

* New patch from v2

 include/linux/net.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/net.h +2 -2
index aa16731..99c9f0c 100644
@@ -240,8 +240,8 @@ do {								\
 #define net_dbg_ratelimited(fmt, ...)				\
 	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
 
-#define net_random()		random32()
-#define net_srandom(seed)	srandom32((__force u32)seed)
+#define net_random()		prandom_u32()
+#define net_srandom(seed)	prandom_seed((__force u32)(seed))
 
 extern int   	     kernel_sendmsg(struct socket *sock, struct msghdr *msg,
 				    struct kvec *vec, size_t num, size_t len);
Signature · 1 line
1.7.11.7
author maintainer
#41 lore raw

PATCH 26/26 remove unused random32() and srandom32()

In reply to Akinobu Mita

After finishing a naming transition, remove unused backward compatibility wrapper macros

Cc "Theodore Ts'o" <[email protected]>

---

* Change from v1
- leave net_random() and net_srandom() definision

 include/linux/random.h | 7 -------
 1 file changed, 7 deletions(-)
include/linux/random.h +0 -7
index d984608..2ae2840 100644
@@ -29,13 +29,6 @@ u32 prandom_u32(void);
 void prandom_bytes(void *buf, int nbytes);
 void prandom_seed(u32 seed);
 
-/*
- * These macros are preserved for backward compatibility and should be
- * removed as soon as a transition is finished.
- */
-#define random32() prandom_u32()
-#define srandom32(seed) prandom_seed(seed)
-
 u32 prandom_u32_state(struct rnd_state *);
 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
 
Signature · 1 line
1.7.11.7