This commit makes the very boring simplifications so that the next
commit, which is a little trickier, is isolated and easy to review.
No change in behavior here at all.

Cc: "Theodore Ts'o" <ty...@mit.edu>
Cc: Jiri Kosina <jkos...@suse.cz>
Signed-off-by: Greg Price <pr...@mit.edu>
---
 drivers/char/random.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 8ec4a9a..8824e8d 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -858,18 +858,16 @@ static size_t account(struct entropy_store *r, size_t 
nbytes, int min,
 retry:
                entropy_count = orig = ACCESS_ONCE(r->entropy_count);
                /* If limited, never pull more than available */
-               if (r->limit && nbytes + reserved >= entropy_count / 8)
-                       nbytes = entropy_count/8 - reserved;
+               if (r->limit)
+                       nbytes = min_t(size_t, nbytes, entropy_count/8 - 
reserved);
 
                if (entropy_count / 8 >= nbytes + reserved) {
                        entropy_count -= nbytes*8;
-                       if (cmpxchg(&r->entropy_count, orig, entropy_count) != 
orig)
-                               goto retry;
                } else {
                        entropy_count = reserved;
-                       if (cmpxchg(&r->entropy_count, orig, entropy_count) != 
orig)
-                               goto retry;
                }
+               if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
+                       goto retry;
 
                if (entropy_count < random_write_wakeup_thresh)
                        wakeup_write = 1;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to