rename random32 to prandom
Subsystems (29)
Akinobu Mita
maintainercover 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 v2
- ubifs, batman-adv, and mtd patches are merged upstream
- add Acked-by: and Reviewed-by: lines
- add rename for brcm80211
* 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 (23):
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()
uwb: rename random32() to prandom_u32()
lguest: rename random32() to prandom_u32()
scsi: rename random32() to prandom_u32() drivers/net: 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/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/brcm80211/brcmfmac/p2p.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/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/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 +-- 36 files changed, 74 insertions(+), 91 deletions(-)
Signature · 1 line
1.8.1.2
Akinobu Mita
maintainerPATCH 1/23 raid6test: use prandom_bytes()
Use prandom_bytes() to generate random bytes for test data.
---
No change from v2
crypto/async_tx/raid6test.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
crypto/async_tx/raid6test.c +2 -7
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 2/23 uuid: use prandom_bytes()
In reply to Akinobu MitaUse prandom_bytes() to generate 16 bytes of pseudo-random bytes.
---
No change from v2
lib/uuid.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
lib/uuid.c +1 -7
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 3/23 x86: pageattr-test: remove srandom32 call
In reply to Akinobu Mitapageattr-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().
---
* Change from v2
- add Acked-by: line
arch/x86/mm/pageattr-test.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/mm/pageattr-test.c +0 -1
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 4/23 x86: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
* Changes from v2
- add Acked-by: line
arch/x86/mm/pageattr-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/pageattr-test.c +2 -2
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 5/23 lib/: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
lib/fault-inject.c | 2 +- lib/list_sort.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
lib/fault-inject.c +1 -1
@@ -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
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 6/23 mm/: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
mm/swapfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/swapfile.c +1 -1
@@ -2120,7 +2120,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.8.1.2 -- 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>
Akinobu Mita
maintainerPATCH 7/23 kernel/: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
kernel/rcutree.c | 2 +- kernel/test_kprobes.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/rcutree.c +1 -1
@@ -1319,7 +1319,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
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 8/23 drbd: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
drivers/block/drbd/drbd_receiver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_receiver.c +3 -2
@@ -757,7 +757,8 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct accrcu_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.8.1.2
Akinobu Mita
maintainerPATCH 9/23 infiniband: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
* Change from v2
- add Reviewed-by: line
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
@@ -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
@@ -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
@@ -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
@@ -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 · 1 line
1.8.1.2
Re: [PATCH -v3 09/23] infiniband: rename random32() to prandom_u32()
Akinobu Mita
maintainerPATCH 10/23 mmc: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
drivers/mmc/core/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/core/core.c +2 -2
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 11/23 video/uvesafb: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
drivers/video/uvesafb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/uvesafb.c +1 -1
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 12/23 xfs: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
* Change from v2
- add Acked-by: line
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
@@ -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
@@ -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
@@ -369,7 +369,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
@@ -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 · 6 lines
1.8.1.2 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Ben Myers
AppliedRe: [PATCH -v3 12/23] xfs: rename random32() to prandom_u32()
Akinobu,
Quoted 8 lines · Akinobu Mita
Use more preferable function name which implies using a pseudo-random number generator.
Signed-off-by Akinobu Mita <[email protected]>Acked-by <[email protected]>Cc Ben Myers <[email protected]>Cc Alex Elder <[email protected]>
Applied this to git://oss.sgi.com/xfs/xfs.git, master branch.
Thanks!
-Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Akinobu Mita
maintainerPATCH 13/23 uwb: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
drivers/uwb/rsv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/uwb/rsv.c +2 -2
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 14/23 lguest: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
drivers/lguest/page_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/lguest/page_tables.c +1 -1
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 15/23 scsi: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
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
@@ -2161,7 +2161,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));
@@ -2794,7 +2794,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
@@ -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
@@ -1940,8 +1940,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.8.1.2
Akinobu Mita
maintainerPATCH 16/23 drivers/net: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
* Changes from v2
- add Acked-by: line
- add rename for brcm80211
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/brcm80211/brcmfmac/p2p.c | 2 +- drivers/net/wireless/mwifiex/cfg80211.c | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +2 -2
@@ -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
@@ -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
@@ -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
@@ -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/brcm80211/brcmfmac/p2p.c +1 -1
@@ -1118,7 +1118,7 @@ static void brcmf_p2p_afx_handler(struct work_struct *work)if (afx_hdl->is_listen && afx_hdl->my_listen_chan)/* 100ms ~ 300ms */ err =brcmf_p2p_discover_listen (p2p, afx_hdl->my_listen_chan, -100 * (1 + (random32 () %3 ))); +100 * (1 + (prandom_u32 () %3 )));else err =brcmf_p2p_act_frm_search (p2p, afx_hdl->peer_listen_chan);
drivers/net/wireless/mwifiex/cfg80211.c +2 -2
@@ -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.8.1.2
Re: [PATCH -v3 16/23] drivers/net: rename random32() to prandom_u32()
Quoted 37 lines · Akinobu Mita
Use more preferable function name which implies using a pseudo-random number generator.
Signed-off-by Akinobu Mita<[email protected]>Acked-by Thomas Sailer<[email protected]>Cc "David S. Miller"<davem-fT/PcQaiUtIeIZ0/[email protected]>Cc Michael Chan<mchan-dY08KVG/lbpWk0Htik3J/[email protected]>Cc Thomas Sailer<[email protected]>Cc Jean-Paul Roubelat<[email protected]>Cc Bing Zhao<[email protected]>Cc Brett Rudley<brudley-dY08KVG/lbpWk0Htik3J/[email protected]>Cc Arend van Spriel<arend-dY08KVG/lbpWk0Htik3J/[email protected]>Cc "Franky (Zhenhui) Lin"<frankyl-dY08KVG/lbpWk0Htik3J/[email protected]>Cc Hante Meuleman<meuleman-dY08KVG/lbpWk0Htik3J/[email protected]>Cc brcm80211-dev-list-dY08KVG/lbpWk0Htik3J/[email protected]---
* Changes from v2
- add Acked-by: line
- add rename for brcm80211drivers/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/brcm80211/brcmfmac/p2p.c | 2 +- drivers/net/wireless/mwifiex/cfg80211.c | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-)drivers/net/wireless/brcm80211/brcmfmac/p2p.c +0
-0
drivers/net/wireless/brcm80211/brcmfmac/p2p.c static void brcmf_p2p_afx_handler(struct work_struct *work) · line 1121
Quoted 5 lines
drivers/net/wireless/brcm80211/brcmfmac/p2p.c +1
-1@@ -1118,7 +1118,7 @@ static void brcmf_p2p_afx_handler(struct work_struct *work)if (afx_hdl->is_listen&& afx_hdl->my_listen_chan)/* 100ms ~ 300ms */ err =brcmf_p2p_discover_listen (p2p, afx_hdl->my_listen_chan, -100 * (1 + (random32 () %3 ))); +100 * (1 + (prandom_u32 () %3 )));
Seems like indentation is wrong now. Please retain the alignment.
Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Akinobu Mita
maintainerRe: [PATCH -v3 16/23] drivers/net: rename random32() to prandom_u32()
2013/3/4 Arend van Spriel <[email protected]>
Quoted 11 lines
drivers/net/wireless/brcm80211/brcmfmac/p2p.c static void brcmf_p2p_afx_handler(struct work_struct *work) · line 1122
Quoted 8 lines
drivers/net/wireless/brcm80211/brcmfmac/p2p.c +1
-1@@ -1118,7 +1118,7 @@ static void brcmf_p2p_afx_handler(struct work_struct *work)if (afx_hdl->is_listen&& afx_hdl->my_listen_chan)/* 100ms ~ 300ms */ err =brcmf_p2p_discover_listen (p2p, afx_hdl->my_listen_chan, -100 * (1 + (random32 () %3 ))); +100 * (1 + (prandom_u32 () %3 )));Seems like indentation is wrong now. Please retain the alignment.
OK, I'll fix it.
Akinobu Mita
maintainerPATCH 17/23 net/sunrpc: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
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
@@ -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.8.1.2
Re: [PATCH -v3 17/23] net/sunrpc: rename random32() to prandom_u32()
Quoted 21 lines · Akinobu Mita
Use more preferable function name which implies using a pseudo-random number generator.
Signed-off-by Akinobu Mita <[email protected]>Cc "J. Bruce Fields" <[email protected]>Cc Trond Myklebust <[email protected]>Cc "David S. Miller" <[email protected]>---
No change from v2
net/sunrpc/auth_gss/gss_krb5_wrap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/sunrpc/auth_gss/gss_krb5_wrap.c +0
-0
net/sunrpc/auth_gss/gss_krb5_wrap.c gss_krb5_make_confounder(char *p, u32 conflen) · line 137
Quoted 10 lines
net/sunrpc/auth_gss/gss_krb5_wrap.c +2
-2@@ -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) {
Akinobu Mita
maintainerPATCH 18/23 net/sched: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
net/sched/sch_choke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_choke.c +1 -1
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 19/23 net/netfilter: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
net/netfilter/nf_conntrack_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_core.c +2 -2
@@ -264,7 +264,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 ; }
@@ -283,7 +283,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.8.1.2
Akinobu Mita
maintainerPATCH 20/23 net/core: rename random32() to prandom_u32()
In reply to Akinobu MitaUse more preferable function name which implies using a pseudo-random number generator.
---
No change from v2
net/core/pktgen.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
net/core/pktgen.c +15 -14
@@ -2198,7 +2198,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) {
@@ -2246,7 +2246,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;
@@ -2278,7 +2278,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 >=
@@ -2304,7 +2304,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++;
@@ -2331,21 +2331,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;
@@ -2358,7 +2358,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 {
@@ -2375,7 +2375,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++;
@@ -2396,7 +2396,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) ||
@@ -2404,7 +2404,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;
@@ -2437,7 +2438,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]); }
@@ -2447,7 +2448,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.8.1.2
Akinobu Mita
maintainerPATCH 21/23 net/core: remove duplicate statements by do-while loop
In reply to Akinobu MitaRemove duplicate statements by using do-while loop instead of while loop.
- A;
- while (e) {
+ do {
A;- }
+ } while (e);
---
No change from v2
net/core/pktgen.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
net/core/pktgen.c +6 -9
@@ -2396,18 +2396,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.8.1.2
Akinobu Mita
maintainerPATCH 22/23 net: rename random32 to prandom
In reply to Akinobu MitaCommit 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.
---
No change from v2
include/linux/net.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/net.h +2 -2
@@ -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.8.1.2
Akinobu Mita
maintainerPATCH 23/23 remove unused random32() and srandom32()
In reply to Akinobu MitaAfter finishing a naming transition, remove unused backward compatibility wrapper macros
---
No change from v2
include/linux/random.h | 7 ------- 1 file changed, 7 deletions(-)
include/linux/random.h +0 -7
@@ -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.8.1.2