From: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
To: herbert@gondor.apana.org.au, freude@linux.vnet.ibm.com,
david.daney@cavium.com, clabbe.montjoie@gmail.com,
linux-crypto@vger.kernel.org, mpm@selenic.com
Cc: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Subject: [PATCH 2/4] hw_random: core: Rearranging rng_get_data to remove forward declaration
Date: Thu, 26 Oct 2017 21:04:25 +0530 [thread overview]
Message-ID: <20171026153427.22334-3-prasannatsmkumar@gmail.com> (raw)
In-Reply-To: <20171026153427.22334-1-prasannatsmkumar@gmail.com>
Rearrange rng_get_data such that its forward declaration is not
required.
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
---
drivers/char/hw_random/core.c | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 8e1f43c..7e2b1a7 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -52,14 +52,30 @@ MODULE_PARM_DESC(default_quality,
static int hwrng_init(struct hwrng *rng);
static void start_khwrngd(void);
-static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
- int wait);
-
static size_t rng_buffer_size(void)
{
return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES;
}
+static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
+ int wait) {
+ int present;
+
+ BUG_ON(!mutex_is_locked(&reading_mutex));
+ if (rng->read)
+ return rng->read(rng, (void *)buffer, size, wait);
+
+ if (rng->data_present)
+ present = rng->data_present(rng, wait);
+ else
+ present = 1;
+
+ if (present)
+ return rng->data_read(rng, (u32 *)buffer);
+
+ return 0;
+}
+
static void add_early_randomness(struct hwrng *rng)
{
int bytes_read;
@@ -178,25 +194,6 @@ static int rng_dev_open(struct inode *inode, struct file *filp)
return 0;
}
-static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
- int wait) {
- int present;
-
- BUG_ON(!mutex_is_locked(&reading_mutex));
- if (rng->read)
- return rng->read(rng, (void *)buffer, size, wait);
-
- if (rng->data_present)
- present = rng->data_present(rng, wait);
- else
- present = 1;
-
- if (present)
- return rng->data_read(rng, (u32 *)buffer);
-
- return 0;
-}
-
static ssize_t rng_dev_read(struct file *filp, char __user *buf,
size_t size, loff_t *offp)
{
--
2.10.0
next prev parent reply other threads:[~2017-10-26 15:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 15:34 [PATCH 0/4] Rearrange functions to remove forward declarations PrasannaKumar Muralidharan
2017-10-26 15:34 ` [PATCH 1/4] hw_random: core: Remove forward declaration by rearranging code PrasannaKumar Muralidharan
2017-10-26 15:34 ` PrasannaKumar Muralidharan [this message]
2017-10-26 15:34 ` [PATCH 3/4] hw_random: core: Rearranging start_khwrngd to remove forward declaration PrasannaKumar Muralidharan
2017-10-26 15:34 ` [PATCH 4/4] hw_random: core: Remove forward declaration of hwrng_init PrasannaKumar Muralidharan
2017-10-26 16:48 ` [PATCH 0/4] Rearrange functions to remove forward declarations David Daney
2017-10-26 17:03 ` PrasannaKumar Muralidharan
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=20171026153427.22334-3-prasannatsmkumar@gmail.com \
--to=prasannatsmkumar@gmail.com \
--cc=clabbe.montjoie@gmail.com \
--cc=david.daney@cavium.com \
--cc=freude@linux.vnet.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=mpm@selenic.com \
/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).