@@ -64,19 +64,6 @@ static size_t rng_buffer_size(void)
64
64
return RNG_BUFFER_SIZE ;
65
65
}
66
66
67
- static void add_early_randomness (struct hwrng * rng )
68
- {
69
- int bytes_read ;
70
-
71
- mutex_lock (& reading_mutex );
72
- bytes_read = rng_get_data (rng , rng_fillbuf , 32 , 0 );
73
- mutex_unlock (& reading_mutex );
74
- if (bytes_read > 0 ) {
75
- size_t entropy = bytes_read * 8 * rng -> quality / 1024 ;
76
- add_hwgenerator_randomness (rng_fillbuf , bytes_read , entropy , false);
77
- }
78
- }
79
-
80
67
static inline void cleanup_rng (struct kref * kref )
81
68
{
82
69
struct hwrng * rng = container_of (kref , struct hwrng , ref );
@@ -340,13 +327,12 @@ static ssize_t rng_current_store(struct device *dev,
340
327
const char * buf , size_t len )
341
328
{
342
329
int err ;
343
- struct hwrng * rng , * old_rng , * new_rng ;
330
+ struct hwrng * rng , * new_rng ;
344
331
345
332
err = mutex_lock_interruptible (& rng_mutex );
346
333
if (err )
347
334
return - ERESTARTSYS ;
348
335
349
- old_rng = current_rng ;
350
336
if (sysfs_streq (buf , "" )) {
351
337
err = enable_best_rng ();
352
338
} else {
@@ -362,11 +348,8 @@ static ssize_t rng_current_store(struct device *dev,
362
348
new_rng = get_current_rng_nolock ();
363
349
mutex_unlock (& rng_mutex );
364
350
365
- if (new_rng ) {
366
- if (new_rng != old_rng )
367
- add_early_randomness (new_rng );
351
+ if (new_rng )
368
352
put_rng (new_rng );
369
- }
370
353
371
354
return err ? : len ;
372
355
}
@@ -544,7 +527,6 @@ int hwrng_register(struct hwrng *rng)
544
527
{
545
528
int err = - EINVAL ;
546
529
struct hwrng * tmp ;
547
- bool is_new_current = false;
548
530
549
531
if (!rng -> name || (!rng -> data_read && !rng -> read ))
550
532
goto out ;
@@ -573,25 +555,8 @@ int hwrng_register(struct hwrng *rng)
573
555
err = set_current_rng (rng );
574
556
if (err )
575
557
goto out_unlock ;
576
- /* to use current_rng in add_early_randomness() we need
577
- * to take a ref
578
- */
579
- is_new_current = true;
580
- kref_get (& rng -> ref );
581
558
}
582
559
mutex_unlock (& rng_mutex );
583
- if (is_new_current || !rng -> init ) {
584
- /*
585
- * Use a new device's input to add some randomness to
586
- * the system. If this rng device isn't going to be
587
- * used right away, its init function hasn't been
588
- * called yet by set_current_rng(); so only use the
589
- * randomness from devices that don't need an init callback
590
- */
591
- add_early_randomness (rng );
592
- }
593
- if (is_new_current )
594
- put_rng (rng );
595
560
return 0 ;
596
561
out_unlock :
597
562
mutex_unlock (& rng_mutex );
@@ -602,12 +567,11 @@ EXPORT_SYMBOL_GPL(hwrng_register);
602
567
603
568
void hwrng_unregister (struct hwrng * rng )
604
569
{
605
- struct hwrng * old_rng , * new_rng ;
570
+ struct hwrng * new_rng ;
606
571
int err ;
607
572
608
573
mutex_lock (& rng_mutex );
609
574
610
- old_rng = current_rng ;
611
575
list_del (& rng -> list );
612
576
complete_all (& rng -> dying );
613
577
if (current_rng == rng ) {
@@ -626,11 +590,8 @@ void hwrng_unregister(struct hwrng *rng)
626
590
} else
627
591
mutex_unlock (& rng_mutex );
628
592
629
- if (new_rng ) {
630
- if (old_rng != new_rng )
631
- add_early_randomness (new_rng );
593
+ if (new_rng )
632
594
put_rng (new_rng );
633
- }
634
595
635
596
wait_for_completion (& rng -> cleanup_done );
636
597
}
0 commit comments