total_weight += tgt->ltd_qos.ltq_weight;
}
- if (total_weight) {
-#if BITS_PER_LONG == 32
- rand = prandom_u32_max((u32)total_weight);
- /*
- * If total_weight > 32-bit, first generate the high
- * 32 bits of the random number, then add in the low
- * 32 bits (truncated to the upper limit, if needed)
- */
- if (total_weight > 0xffffffffULL)
- rand = prandom_u32_max((u32)(total_weight >> 32)) << 32;
- else
- rand = 0;
-
- if (rand == (total_weight & 0xffffffff00000000ULL))
- rand |= prandom_u32_max((u32)total_weight);
- else
- rand |= prandom_u32();
-
-#else
- rand = prandom_u32() | prandom_u32_max((u32)total_weight);
-#endif
- } else {
- rand = 0;
- }
+ rand = lu_prandom_u64_max(total_weight);
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
tgt = lmv->tgts[i];