From patchwork Thu Oct 26 15:34:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PrasannaKumar Muralidharan X-Patchwork-Id: 10028585 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 69B0A6032C for ; Thu, 26 Oct 2017 15:35:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BDF228E27 for ; Thu, 26 Oct 2017 15:35:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5097F28E37; Thu, 26 Oct 2017 15:35:45 +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 42DA528E27 for ; Thu, 26 Oct 2017 15:35:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932127AbdJZPfn (ORCPT ); Thu, 26 Oct 2017 11:35:43 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:52127 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932275AbdJZPfn (ORCPT ); Thu, 26 Oct 2017 11:35:43 -0400 Received: by mail-pf0-f194.google.com with SMTP id n14so2763396pfh.8 for ; Thu, 26 Oct 2017 08:35:42 -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=K5AuZxudvJ434+HhU8CEtnRpqteN2FHJIr48TmRFVzM=; b=Mx5e/ps3LyCBJZ3PJkDRggNwEcmcanJRQO4eTIOrFcXZWLow+rq6O/ALN1rnHDzVJU VWKTZ8wgd4p+rfw4y5860syZ2NNRN0KNocuwm4Ko2LYHrgLeEE9enq9OkJ0272CfjI2f CLb2bwWcQNfzO24FJK5lJ2UGgVnBl6ecAM6DtBN3XHDwFB+rJQdSQXtaguYYanDJM48g u6Ad6HiDS8whfOjSNEep9/AgA6afuFr0WlwhispRLKetb8sYwI4CMUeOK3R1CPGsxG7+ McBzYrDxF17GTQR10r9Y8ZYu1962LGJ18FCm6qVAf+NP0zgo7isVJVmRRsaESoK+hIAX uLkg== 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=K5AuZxudvJ434+HhU8CEtnRpqteN2FHJIr48TmRFVzM=; b=g3RX6AhKEXHkySuAuPFoZQy20vV3Z70qi6fwNvYQDxlm/qYcrW1yGn55XQMg4GSUtB k+ErYyfpS89fg87bcvtETd4yAKFMRo+oKdSJfjD/Bx6nGspnEDyHVjiNe1H2rt+BdRyn t2tkIxl1zpNtUtTkU/gdtz6xgAsjmNTiGhOmLObU93CUwr9JkCs3M5tJ69v/bcDRwZIk aLOoEVJtDVmHNaMDrdSa9Dqp9ZZTMBD0qIeht3GCjaHvQ4BpT2JFKaraGMGQq5DT38gG t3sU7x3rYwRVy80cVLtSSsY1Yr3V3AajqhHs/L10vsFJztUmdwKV3bgPXCTf8m98OtJK OVVg== X-Gm-Message-State: AMCzsaXYO5IrwF7ZVXv9S5RHWlS4bozG+Hf+xpcBC0VeCrcWmPj8uEWo 5jndY7KhzOoPDKHPhIyLHxQX6yFBpa0= X-Google-Smtp-Source: ABhQp+SLCSljLN4aljxgwXn2WDMD7DAvvnAn+f/EIZNBkHj2JSQ2UQjJC7AaVUtUj7dvRlxd8CW1AA== X-Received: by 10.84.131.109 with SMTP id 100mr4885811pld.140.1509032142554; Thu, 26 Oct 2017 08:35:42 -0700 (PDT) Received: from linux.local ([43.224.131.52]) by smtp.gmail.com with ESMTPSA id n19sm10391618pfj.52.2017.10.26.08.35.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Oct 2017 08:35:41 -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 3/4] hw_random: core: Rearranging start_khwrngd to remove forward declaration Date: Thu, 26 Oct 2017 21:04:26 +0530 Message-Id: <20171026153427.22334-4-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 start_khwrngd such that its forward declaration is not required. Signed-off-by: PrasannaKumar Muralidharan --- drivers/char/hw_random/core.c | 75 +++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 7e2b1a7..534c2ae 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -50,7 +50,6 @@ MODULE_PARM_DESC(default_quality, "default entropy content of hwrng per mill"); static int hwrng_init(struct hwrng *rng); -static void start_khwrngd(void); static size_t rng_buffer_size(void) { @@ -153,6 +152,43 @@ static void put_rng(struct hwrng *rng) mutex_unlock(&rng_mutex); } +static int hwrng_fillfn(void *unused) +{ + long rc; + + while (!kthread_should_stop()) { + struct hwrng *rng; + + rng = get_current_rng(); + if (IS_ERR(rng) || !rng) + break; + mutex_lock(&reading_mutex); + rc = rng_get_data(rng, rng_fillbuf, + rng_buffer_size(), 1); + mutex_unlock(&reading_mutex); + put_rng(rng); + if (rc <= 0) { + pr_warn("hwrng: no data available\n"); + msleep_interruptible(10000); + continue; + } + /* Outside lock, sure, but y'know: randomness. */ + add_hwgenerator_randomness((void *)rng_fillbuf, rc, + rc * current_quality * 8 >> 10); + } + hwrng_fill = NULL; + return 0; +} + +static void start_khwrngd(void) +{ + hwrng_fill = kthread_run(hwrng_fillfn, NULL, "hwrng"); + if (IS_ERR(hwrng_fill)) { + pr_err("hwrng_fill thread creation failed"); + hwrng_fill = NULL; + } +} + static int hwrng_init(struct hwrng *rng) { if (kref_get_unless_zero(&rng->ref)) @@ -387,43 +423,6 @@ static int __init register_miscdev(void) return misc_register(&rng_miscdev); } -static int hwrng_fillfn(void *unused) -{ - long rc; - - while (!kthread_should_stop()) { - struct hwrng *rng; - - rng = get_current_rng(); - if (IS_ERR(rng) || !rng) - break; - mutex_lock(&reading_mutex); - rc = rng_get_data(rng, rng_fillbuf, - rng_buffer_size(), 1); - mutex_unlock(&reading_mutex); - put_rng(rng); - if (rc <= 0) { - pr_warn("hwrng: no data available\n"); - msleep_interruptible(10000); - continue; - } - /* Outside lock, sure, but y'know: randomness. */ - add_hwgenerator_randomness((void *)rng_fillbuf, rc, - rc * current_quality * 8 >> 10); - } - hwrng_fill = NULL; - return 0; -} - -static void start_khwrngd(void) -{ - hwrng_fill = kthread_run(hwrng_fillfn, NULL, "hwrng"); - if (IS_ERR(hwrng_fill)) { - pr_err("hwrng_fill thread creation failed"); - hwrng_fill = NULL; - } -} - int hwrng_register(struct hwrng *rng) { int err = -EINVAL;