@@ -64,19 +64,6 @@ static size_t rng_buffer_size(void)
6464 return RNG_BUFFER_SIZE ;
6565}
6666
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-
8067static inline void cleanup_rng (struct kref * kref )
8168{
8269 struct hwrng * rng = container_of (kref , struct hwrng , ref );
@@ -340,13 +327,12 @@ static ssize_t rng_current_store(struct device *dev,
340327 const char * buf , size_t len )
341328{
342329 int err ;
343- struct hwrng * rng , * old_rng , * new_rng ;
330+ struct hwrng * rng , * new_rng ;
344331
345332 err = mutex_lock_interruptible (& rng_mutex );
346333 if (err )
347334 return - ERESTARTSYS ;
348335
349- old_rng = current_rng ;
350336 if (sysfs_streq (buf , "" )) {
351337 err = enable_best_rng ();
352338 } else {
@@ -362,11 +348,8 @@ static ssize_t rng_current_store(struct device *dev,
362348 new_rng = get_current_rng_nolock ();
363349 mutex_unlock (& rng_mutex );
364350
365- if (new_rng ) {
366- if (new_rng != old_rng )
367- add_early_randomness (new_rng );
351+ if (new_rng )
368352 put_rng (new_rng );
369- }
370353
371354 return err ? : len ;
372355}
@@ -544,7 +527,6 @@ int hwrng_register(struct hwrng *rng)
544527{
545528 int err = - EINVAL ;
546529 struct hwrng * tmp ;
547- bool is_new_current = false;
548530
549531 if (!rng -> name || (!rng -> data_read && !rng -> read ))
550532 goto out ;
@@ -573,25 +555,8 @@ int hwrng_register(struct hwrng *rng)
573555 err = set_current_rng (rng );
574556 if (err )
575557 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 );
581558 }
582559 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 );
595560 return 0 ;
596561out_unlock :
597562 mutex_unlock (& rng_mutex );
@@ -602,12 +567,11 @@ EXPORT_SYMBOL_GPL(hwrng_register);
602567
603568void hwrng_unregister (struct hwrng * rng )
604569{
605- struct hwrng * old_rng , * new_rng ;
570+ struct hwrng * new_rng ;
606571 int err ;
607572
608573 mutex_lock (& rng_mutex );
609574
610- old_rng = current_rng ;
611575 list_del (& rng -> list );
612576 complete_all (& rng -> dying );
613577 if (current_rng == rng ) {
@@ -626,11 +590,8 @@ void hwrng_unregister(struct hwrng *rng)
626590 } else
627591 mutex_unlock (& rng_mutex );
628592
629- if (new_rng ) {
630- if (old_rng != new_rng )
631- add_early_randomness (new_rng );
593+ if (new_rng )
632594 put_rng (new_rng );
633- }
634595
635596 wait_for_completion (& rng -> cleanup_done );
636597}
0 commit comments