[<prev] [next>] [day] [month] [year] [list]
Message-Id: <202003281643.02SGhHox023138@sdf.org>
Date: Wed, 20 Mar 2019 22:50:00 -0400
From: George Spelvin <lkml@....org>
To: linux-kernel@...r.kernel.org, lkml@....org
Cc: Thierry Escande <thierry.escande@...labora.com>,
Samuel Ortiz <sameo@...ux.intel.com>, linux-nfc@...ts.01.org
Subject: [RFC PATCH v1 26/50] drivers/nfc/nfcsim: use prandom_32() for time
delay
get_random_bytes() is expensive crypto-quality seed material.
That's not needed for a simple simulation.
(Also, a 3-10 ms delay, when converted to jiffies, isn't a lot of
granularity. It's 1 jiffy at HZ=100 and 3 jiffies at HZ=250
or HZ=300.)
Signed-off-by: George Spelvin <lkml@....org>
Cc: Thierry Escande <thierry.escande@...labora.com>
Cc: Samuel Ortiz <sameo@...ux.intel.com>
Cc: linux-nfc@...ts.01.org
---
drivers/nfc/nfcsim.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c
index a9864fcdfba6b..eb0a909a25487 100644
--- a/drivers/nfc/nfcsim.c
+++ b/drivers/nfc/nfcsim.c
@@ -229,8 +229,7 @@ static int nfcsim_send(struct nfc_digital_dev *ddev, struct sk_buff *skb,
dev->mode);
/* Add random delay (between 3 and 10 ms) before sending data */
- get_random_bytes(&delay, 1);
- delay = 3 + (delay & 0x07);
+ delay = 3 + prandom_u32_max(8);
schedule_delayed_work(&dev->send_work, msecs_to_jiffies(delay));
}
--
2.26.0
Powered by blists - more mailing lists