From patchwork Thu Oct 26 15:34:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PrasannaKumar Muralidharan X-Patchwork-Id: 10028583 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F4AF6032C for ; Thu, 26 Oct 2017 15:35:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4179328E27 for ; Thu, 26 Oct 2017 15:35:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3677D28E37; Thu, 26 Oct 2017 15:35:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFF0828E27 for ; Thu, 26 Oct 2017 15:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932309AbdJZPfk (ORCPT ); Thu, 26 Oct 2017 11:35:40 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:51062 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932255AbdJZPfj (ORCPT ); Thu, 26 Oct 2017 11:35:39 -0400 Received: by mail-pf0-f195.google.com with SMTP id b6so2769906pfh.7 for ; Thu, 26 Oct 2017 08:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vwTFY9CDRTUHJjC2xzV6+iG+hTCHuwqQqQ2ak/24hK8=; b=U7KkL6CBkzSoTiyJaDUWJNagFokBuyfSBlgmR1yyv8oB6WuY9jqXafjQBbcuwlp4Hl X0bnXajWMGYQ4AI7I38xPDEZibgn3p6b6jfmYHFMyAwKcgivqmYYlwyRNXu/Ob5RPcPy SMcT6xwyc4hoRYv03CQkcTzWgk7SPa1mDJI7C66e1CCDZB6K4+sl9cxmu8ixolFbDRez EPpyMV/HcM6EqgkZUGjBjUH1Bl3OEbbWbatBrHNNOk4RkLHKwqahl8xTkhpBUQw6s3BW WPGAWfSH9xV8gWbmefsymTmnbbeqhzcyOCU/sx1ShiHFu2F9WqWLDFM7/I+iqx39KTy6 7ppQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vwTFY9CDRTUHJjC2xzV6+iG+hTCHuwqQqQ2ak/24hK8=; b=Z3RWLPlLyRQakvCw/4/+8GsWFwXg6pxtu2NCHugUxstS/AoEwhM16jhjSpi7ZmO9Pw DgpyJ45xccw81+iqzcGvcPlovyLgb33En4jQnm/Pnp6mXKOxLXxEOGJXhItEc4M3emOU 1sN7Ox4p3vrN0eD+KuixB4tK+jGOanfhCUPYGx4/pYlS32YBL9oXTytgoScprVtMyTgP oSu9mNFclW/39ga2ypHojndHv53ZuQTyDw+yrIAi8KFpzlGBtLJBHrD0k1xze7JU+Qqz GdrkqOVFsF7SbuHqgUx7yIIZ4aNsZ+50wHSN35zjEQ3q9M1qmjlIwcq51yn6ywwn2aU+ QedA== X-Gm-Message-State: AMCzsaVvnK/ECO0YLNAts7ynITOZETHVWc2aM4TLExaWdJQoJHUoljL1 K0gSvsa8o3HDLYtyL0Cdo4g= X-Google-Smtp-Source: ABhQp+T+hPslxFi1jhBpAHyuKxiPcJBv7pjluEFfg2fbmNpLFeJ1GKTvNtMr7Qyye2sx2LDtM9l30g== X-Received: by 10.98.16.211 with SMTP id 80mr5716872pfq.72.1509032139111; Thu, 26 Oct 2017 08:35:39 -0700 (PDT) Received: from linux.local ([43.224.131.52]) by smtp.gmail.com with ESMTPSA id n19sm10391618pfj.52.2017.10.26.08.35.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Oct 2017 08:35:38 -0700 (PDT) From: PrasannaKumar Muralidharan 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 Subject: [PATCH 2/4] hw_random: core: Rearranging rng_get_data to remove forward declaration Date: Thu, 26 Oct 2017 21:04:25 +0530 Message-Id: <20171026153427.22334-3-prasannatsmkumar@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20171026153427.22334-1-prasannatsmkumar@gmail.com> References: <20171026153427.22334-1-prasannatsmkumar@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rearrange rng_get_data such that its forward declaration is not required. Signed-off-by: PrasannaKumar Muralidharan --- 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) {