mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v1 26/50] drivers/nfc/nfcsim: use prandom_32() for time delay
@ 2019-03-21  2:50 George Spelvin
  0 siblings, 0 replies; only message in thread
From: George Spelvin @ 2019-03-21  2:50 UTC (permalink / raw)
  To: linux-kernel, lkml; +Cc: Thierry Escande, Samuel Ortiz, linux-nfc

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@sdf.org>
Cc: Thierry Escande <thierry.escande@collabora.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: linux-nfc@lists.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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-28 16:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21  2:50 [RFC PATCH v1 26/50] drivers/nfc/nfcsim: use prandom_32() for time delay George Spelvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®