From patchwork Mon May 22 21:12:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick Altherr X-Patchwork-Id: 9741401 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 418546034C for ; Mon, 22 May 2017 21:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3459B2872A for ; Mon, 22 May 2017 21:12:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 290112873C; Mon, 22 May 2017 21:12:48 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 C8BEA2872A for ; Mon, 22 May 2017 21:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935837AbdEVVMp (ORCPT ); Mon, 22 May 2017 17:12:45 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:34242 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935792AbdEVVM3 (ORCPT ); Mon, 22 May 2017 17:12:29 -0400 Received: by mail-pf0-f180.google.com with SMTP id 9so93435190pfj.1 for ; Mon, 22 May 2017 14:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GZmMxRpXLvujsr6Nvjy630Ef1QsBKQe2u5YYlSeB+Nc=; b=fO3fN3ekxXNph/9UZmo1wB+26uGIOiKHZr4UCZC+LYaglR1y3tQxG6ZhsOyIguu92g YTfr2THdt9vZ7/PA+7RUtSxbj1u9A3yDD8Sz74s8QDgarRn+PBt+hZTvp+k79CaOGMP9 UiSaPyFtBKJuK/d31CCzEixbMTfveUsh3ZtB1H42COZxwoCKq5pOBwQz+IPR5NH5XN4b WwPp3+vHoiR2m/u08cUxp1CoSTnVZiuA/ClNRFreWbddlzOskQDEa3u1kM3N6AxqsJ3S nVf59+7U5WOBWxEGajAQsLf8J7zU2KMK8A38tBOS058AnwMTIIClOo8P5JQf82wkBoi7 A+zA== 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=GZmMxRpXLvujsr6Nvjy630Ef1QsBKQe2u5YYlSeB+Nc=; b=saICnV2d/n3Xt8VcJHJnHc5yL0dAiqx+oS0EVND4BPc+Z5jaWL6MPMJiMoFgyV+mzO MFPYxdlC8/WoTOPkDct3G+UiSNcnFNb+dkyvVEzM/fTNCXiHnSR5nELmCgtqBPEJYNzs jA886NubLhs56/fD1gmEVYl3ifD7QxMRoM61jkdfo0sY1G05nkywjtpwPTIe8xH/C4/F ldxvBM+hDlQHMoDrqGSStXN3IUQL+bEv4xKuuGdgq/clgmr4vVKRSfCn8G74/u/qmzGt cShR3zyjQPBtay7i/mDubC/P8xWbZhxMvKz9NpqX0xt7WGaqo5rK4mRHdtyxLbwdVPs8 3+IA== X-Gm-Message-State: AODbwcBBZBObDz9FMpwlUZKadv8CBgWPAXzDmGmzNIBbqorewx7+CZPD xouXSXm29+4XSahW X-Received: by 10.99.165.70 with SMTP id r6mr6551993pgu.121.1495487549040; Mon, 22 May 2017 14:12:29 -0700 (PDT) Received: from raltherr-linux.svl.corp.google.com ([100.123.242.49]) by smtp.gmail.com with ESMTPSA id p3sm33395240pgd.36.2017.05.22.14.12.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 May 2017 14:12:27 -0700 (PDT) From: Rick Altherr To: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Herbert Xu , Matt Mackall Subject: [PATCH v2 2/2] hw_random: timeriomem_rng: Allow setting RNG quality from platform data Date: Mon, 22 May 2017 14:12:24 -0700 Message-Id: <20170522211224.12202-2-raltherr@google.com> X-Mailer: git-send-email 2.13.0.303.g4ebf302169-goog In-Reply-To: <20170522211224.12202-1-raltherr@google.com> References: <20170522211224.12202-1-raltherr@google.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 When a hw_random device's quality is non-zero, it will automatically be used to fill the kernel's entropy pool. Since timeriomem_rng is used by many different devices, the quality needs to be provided by platform data or device tree. Signed-off-by: Rick Altherr --- Changes in v2: - Adjust header comment for platform data quality property to match code and DT bindings drivers/char/hw_random/timeriomem-rng.c | 7 +++++++ include/linux/timeriomem-rng.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c index a0faa5f05deb..03ff5483d865 100644 --- a/drivers/char/hw_random/timeriomem-rng.c +++ b/drivers/char/hw_random/timeriomem-rng.c @@ -151,8 +151,15 @@ static int timeriomem_rng_probe(struct platform_device *pdev) dev_err(&pdev->dev, "missing period\n"); return -EINVAL; } + + if (!of_property_read_u32(pdev->dev.of_node, + "quality", &i)) + priv->rng_ops.quality = i; + else + priv->rng_ops.quality = 0; } else { period = pdata->period; + priv->rng_ops.quality = pdata->quality; } priv->period = ns_to_ktime(period * NSEC_PER_USEC); diff --git a/include/linux/timeriomem-rng.h b/include/linux/timeriomem-rng.h index 46eb27ddbfab..3e00122bcf88 100644 --- a/include/linux/timeriomem-rng.h +++ b/include/linux/timeriomem-rng.h @@ -13,4 +13,7 @@ struct timeriomem_rng_data { /* measures in usecs */ unsigned int period; + + /* bits of entropy per 1024 bits read */ + unsigned int quality; };