Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp721789pxk; Wed, 23 Sep 2020 14:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFBmjcrfU2L09/NJzSuRwhSPd/TdBC+hmkL0B2AFsH5fMW6UKxQGuAChyo3JNQuuNF7SNS X-Received: by 2002:aa7:cd05:: with SMTP id b5mr1341236edw.283.1600896499118; Wed, 23 Sep 2020 14:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600896499; cv=none; d=google.com; s=arc-20160816; b=hes5OiA0ly26/IMn/1Su9VZYqEWCv55ZIiJ/8+gAJJqTbe/OV+Obt6n9SNvuOyIeBr vIvgr8UGK9Kqrj3dijMQG+WsvgVfFqBuY0DUDyEhhb94NdWiERhqCQEVgnWhci10rugn VAsW+y63bji1L4mJ45FlfaeodEpIAN18etnt32qpaKjIZmEMRKT0+nV1oL06F+3BOrTN f0e0j1vifZSKocqMKq9Ic/APQtb0jn8mjcbGBjm8CwnC2SEUHjsLk01ir0LUVLP4qMa3 dLY9SQex9ZPN5uAgiIaVrbZrMmhTS7J/b1V7jINCG8RwuYGrAyn08SeRUwhEWeke9U+b GK8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zjUKAs9wAfx3korB1Nfzq3BRWTY4CvwN6fVXRcpyDaU=; b=w/M9eY1kUgQ0WOPGhJoK3Fi1mQKDvGF6wfKkWmBp+iwSbNWRvBYeoDMKx/taHSwwWO XH07G8FZelJIjW5p1r++1/n/11/RZvX/+GRSB1q+pwFLtLMBF46yhCPyfNsDKw3icIN5 luzsUZQv1G3e7ZG6sxRupJMw8Na9SQXSVVpQc9LFIu8xDRYD3NT0EIkVWONfRK8hlVHG 31ZjhN+zU75r47mSyMkdUfSEMFohJzPBUJ0sxGAEeB8caOlGQERrpJfrdQOYYMJZoSV2 mLNboguuHfAhnxinXcojilnfFZzZqS2SF3bveX6suD2Wk1yvdyVSK+SG/20xMk6waRmc bF/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si677436edy.595.2020.09.23.14.27.54; Wed, 23 Sep 2020 14:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726650AbgIWVYO (ORCPT + 99 others); Wed, 23 Sep 2020 17:24:14 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:55839 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726476AbgIWVYN (ORCPT ); Wed, 23 Sep 2020 17:24:13 -0400 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id 08NLN8mr026845; Thu, 24 Sep 2020 00:23:08 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id EBDB3639D6; Thu, 24 Sep 2020 00:23:07 +0300 (IDT) From: Tomer Maimon To: mpm@selenic.com, herbert@gondor.apana.org.au, arnd@arndb.de, gregkh@linuxfoundation.org, avifishman70@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, joel@jms.id.au Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, tmaimon77@gmail.com Subject: [PATCH v1] hw_random: npcm: modify readl to readb Date: Thu, 24 Sep 2020 00:23:05 +0300 Message-Id: <20200923212305.198485-1-tmaimon77@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Modify the read size to the correct HW random registers size, 8bit. The incorrect read size caused and faulty HW random value. Signed-off-by: Tomer Maimon --- drivers/char/hw_random/npcm-rng.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c index 5d0d13f891b7..1ec5f267a656 100644 --- a/drivers/char/hw_random/npcm-rng.c +++ b/drivers/char/hw_random/npcm-rng.c @@ -58,24 +58,24 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) pm_runtime_get_sync((struct device *)priv->rng.priv); - while (max >= sizeof(u32)) { + while (max) { if (wait) { - if (readl_poll_timeout(priv->base + NPCM_RNGCS_REG, + if (readb_poll_timeout(priv->base + NPCM_RNGCS_REG, ready, ready & NPCM_RNG_DATA_VALID, NPCM_RNG_POLL_USEC, NPCM_RNG_TIMEOUT_USEC)) break; } else { - if ((readl(priv->base + NPCM_RNGCS_REG) & + if ((readb(priv->base + NPCM_RNGCS_REG) & NPCM_RNG_DATA_VALID) == 0) break; } - *(u32 *)buf = readl(priv->base + NPCM_RNGD_REG); - retval += sizeof(u32); - buf += sizeof(u32); - max -= sizeof(u32); + *(u8 *)buf = readb(priv->base + NPCM_RNGD_REG); + retval++; + buf++; + max--; } pm_runtime_mark_last_busy((struct device *)priv->rng.priv); -- 2.22.0