Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1100181rwr; Thu, 27 Apr 2023 12:18:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Hxju9rJEQyksgsO4kHvfU1+zRmzAmzWmOxNAs1T9lo0kgzmTAvkPlISd8veptfLoYQdby X-Received: by 2002:a17:902:ea10:b0:1a9:1b4:9fdd with SMTP id s16-20020a170902ea1000b001a901b49fddmr26156plg.2.1682623111136; Thu, 27 Apr 2023 12:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682623111; cv=none; d=google.com; s=arc-20160816; b=QGpe3xlNSPsokSw4ItmhyXwL9fpjLd0WshnXTcGquciDsleNIPLn0QYigT7nfTKwrU BhiWjeK9pU11IOKAA87s/+3SRNfws8flTUKd4DCMb0nvgRasIKMdQsdh+jWfGGTDZf9F phCDCOnFniavTX0qma9Lere9rpUHYG/Dp/4G3KmzFofH2eb/waZ/48a4UpGAzBwgiwxj +yApRYdIogINIm+1nUWKS3tt+gN1iu3PJWjxXhEzANcWvzAeOg++aOZDUnJ5pFu+lO4d s3qaa+ouICnobf1nbZ0qfHCBE+Oe83e/+rJ9gOPdG+6FJzzFGuAi0epMUjXoZxMEBxfK KihA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=P8+SFoJqzVzdbYGPatIdgSQiQRONNeakg88oiaw0JR4=; b=AKp6OFcB+reYnMMFDvm8jGnNKyOYnZCbJOnV6UVr8MIZZTSpTE4H11I0FcaDs7BGke yKZDjRFpfTBrPgg2ExBJ6JDAwMTDV+y76fAdYUA6HokHP/cEjkqMXywCtHIq1njOVp29 Z5XZE80s4gw31z0g94/rpBylxi2jZdHvsORIZIdGxX9Nxd3sBF/Ee1vYasdwzai+kBYa zGucN61ZQrrhqjp4DblwFTxBc5JyWoEH4K1l1EtQqaGzdIfHF/zMM3fSQ8YftjHEjsxm BbFZZK1xztzlyIvOfOp+GTdGcd5S+6BGq6yKfPydAxmxBJ7K/dRvqOiAjya8SIKk4owl +96w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a170902e84900b001a804319df8si21748864plg.391.2023.04.27.12.18.12; Thu, 27 Apr 2023 12:18:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244476AbjD0TIe (ORCPT + 99 others); Thu, 27 Apr 2023 15:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244664AbjD0TIc (ORCPT ); Thu, 27 Apr 2023 15:08:32 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F72049DA; Thu, 27 Apr 2023 12:08:10 -0700 (PDT) Received: from ipservice-092-217-081-249.092.217.pools.vodafone-ip.de ([92.217.81.249] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1ps6l4-0003RX-PD; Thu, 27 Apr 2023 20:54:22 +0200 From: Martin Kaiser To: Herbert Xu Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 1/3] hwrng: imx-rngc - use bitfield macros to read fifo level Date: Thu, 27 Apr 2023 20:53:55 +0200 Message-Id: <20230427185357.923412-2-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230427185357.923412-1-martin@kaiser.cx> References: <20230427185357.923412-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use the mechanism from bitfield.h to read the fifo level field in the status register. This makes the code a tiny bit simpler. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/imx-rngc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c index a1c24148ed31..861a615ac7df 100644 --- a/drivers/char/hw_random/imx-rngc.c +++ b/drivers/char/hw_random/imx-rngc.c @@ -17,6 +17,7 @@ #include #include #include +#include #define RNGC_VER_ID 0x0000 #define RNGC_COMMAND 0x0004 @@ -44,8 +45,7 @@ #define RNGC_CTRL_AUTO_SEED 0x00000010 #define RNGC_STATUS_ERROR 0x00010000 -#define RNGC_STATUS_FIFO_LEVEL_MASK 0x00000f00 -#define RNGC_STATUS_FIFO_LEVEL_SHIFT 8 +#define RNGC_STATUS_FIFO_LEVEL GENMASK(11, 8) #define RNGC_STATUS_SEED_DONE 0x00000020 #define RNGC_STATUS_ST_DONE 0x00000010 @@ -133,9 +133,7 @@ static int imx_rngc_read(struct hwrng *rng, void *data, size_t max, bool wait) break; /* how many random numbers are in FIFO? [0-16] */ - level = (status & RNGC_STATUS_FIFO_LEVEL_MASK) >> - RNGC_STATUS_FIFO_LEVEL_SHIFT; - + level = FIELD_GET(RNGC_STATUS_FIFO_LEVEL, status); if (level) { /* retrieve a random number from FIFO */ *(u32 *)data = readl(rngc->base + RNGC_FIFO); -- 2.30.2