From: Yangtao Li <tiny.windzz@gmail.com>
To: tytso@mit.edu, arnd@arndb.de, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Yangtao Li <tiny.windzz@gmail.com>
Subject: [PATCH 2/5] random: convert to ENTROPY_BITS
Date: Fri, 7 Jun 2019 14:25:14 -0400 [thread overview]
Message-ID: <20190607182517.28266-2-tiny.windzz@gmail.com> (raw)
In-Reply-To: <20190607182517.28266-1-tiny.windzz@gmail.com>
Use DEFINE_SHOW_ATTRIBUTE macro to enhance code readability.
Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
drivers/char/random.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index bebf622c61c4..d714a458f088 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -788,7 +788,7 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
if (entropy_bits < 128)
return;
crng_reseed(&primary_crng, r);
- entropy_bits = r->entropy_count >> ENTROPY_SHIFT;
+ entropy_bits = ENTROPY_BITS(r);
}
/* initialize the blocking pool if necessary */
@@ -1396,8 +1396,7 @@ EXPORT_SYMBOL_GPL(add_disk_randomness);
static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes);
static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
{
- if (!r->pull ||
- r->entropy_count >= (nbytes << (ENTROPY_SHIFT + 3)) ||
+ if (!r->pull || ENTROPY_BITS(r) >= (nbytes << 3) ||
r->entropy_count > r->poolinfo->poolfracbits)
return;
@@ -1435,8 +1434,7 @@ static void push_to_pool(struct work_struct *work)
push_work);
BUG_ON(!r);
_xfer_secondary_pool(r, random_read_wakeup_bits/8);
- trace_push_to_pool(r->name, r->entropy_count >> ENTROPY_SHIFT,
- r->pull->entropy_count >> ENTROPY_SHIFT);
+ trace_push_to_pool(r->name, ENTROPY_BITS(r), ENTROPY_BITS(r->pull));
}
/*
@@ -1479,8 +1477,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
goto retry;
trace_debit_entropy(r->name, 8 * ibytes);
- if (ibytes &&
- (r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) {
+ if (ibytes && ENTROPY_BITS(r) < random_write_wakeup_bits) {
wake_up_interruptible(&random_write_wait);
kill_fasync(&fasync, SIGIO, POLL_OUT);
}
--
2.17.0
next prev parent reply other threads:[~2019-06-07 18:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-07 18:25 [PATCH 1/5] random: remove unnecessary unlikely() Yangtao Li
2019-06-07 18:25 ` Yangtao Li [this message]
2020-01-07 21:37 ` [PATCH 2/5] random: convert to ENTROPY_BITS Theodore Y. Ts'o
2019-06-07 18:25 ` [PATCH 3/5] random: Add and use pr_fmt() Yangtao Li
2019-06-10 19:12 ` Joe Perches
2020-01-07 21:45 ` Theodore Y. Ts'o
2019-06-07 18:25 ` [PATCH 4/5] random: fix typo in add_timer_randomness() Yangtao Li
2020-01-07 22:08 ` Theodore Y. Ts'o
2019-06-07 18:25 ` [PATCH 5/5] random: remove some dead code of poolinfo Yangtao Li
2020-01-07 22:20 ` Theodore Y. Ts'o
2019-07-11 14:49 ` [PATCH 1/5] random: remove unnecessary unlikely() Frank Lee
2019-10-29 7:14 ` Joe Perches
2019-11-09 0:54 ` Joe Perches
2019-12-14 18:15 ` Frank Lee
2020-01-07 21:10 ` Theodore Y. Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190607182517.28266-2-tiny.windzz@gmail.com \
--to=tiny.windzz@gmail.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).