From patchwork Wed Jul 19 07:18:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 13318440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B1B6C001DC for ; Wed, 19 Jul 2023 07:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hHeabBm3J5BxGCwd4y0wXAJ8Vl2xFrHZkDw/d+6ENn0=; b=Y4lc19jXSWqBbX zMyJ76Fbgj6GJ8Nf00+SB0nwhZaCVeNck5fwJ59EjhHlHDXg0HmwcKmY7Ejyp2CV9Sl52G0rwqCZg IuaPZKcU466bEG22x7xUomTUMuRiBtM+kuiEsbA7QdxCF4zcS+mUGSHaNbzZkOeYoDQQUqrhH8gZ2 2OUsJ8H9wCxzATQexPMeBGhgl14oiA0UaiMnWhWqe9M0VSW2AvTCyFQsEvQZb/tFAKW16FCWJk3Qs kvuYQz555yPwGh4IMOvefMoc4JEvMsKz9R+Ex2mO2Em4zQ4GeBLa6O/NGCpJhoWINksbk5Tgaa/XK f0ABQBhah3R87Y9Y1v3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM1U5-0064YA-0F; Wed, 19 Jul 2023 07:20:29 +0000 Received: from viti.kaiser.cx ([2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM1Tq-0064Sw-34 for linux-arm-kernel@lists.infradead.org; Wed, 19 Jul 2023 07:20:17 +0000 Received: from ipservice-092-217-093-053.092.217.pools.vodafone-ip.de ([92.217.93.53] 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 1qM1Tk-0008I7-MQ; Wed, 19 Jul 2023 09:20:08 +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/4] hwrng: cctrng - don't open code init and exit functions Date: Wed, 19 Jul 2023 09:18:03 +0200 Message-Id: <20230719071806.335718-2-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230719071806.335718-1-martin@kaiser.cx> References: <20230719071806.335718-1-martin@kaiser.cx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230719_002015_151418_767B0F44 X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Do not open code the init and exit functions of the cctrng driver. If we move the BUILD_BUG_ON checks into the probe function, we can use module_platform_driver and make the code shorter. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/cctrng.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c index 302ffa354c2f..241da7e44675 100644 --- a/drivers/char/hw_random/cctrng.c +++ b/drivers/char/hw_random/cctrng.c @@ -492,6 +492,10 @@ static int cctrng_probe(struct platform_device *pdev) u32 val; int irq; + /* Compile time assertion checks */ + BUILD_BUG_ON(CCTRNG_DATA_BUF_WORDS < 6); + BUILD_BUG_ON((CCTRNG_DATA_BUF_WORDS & (CCTRNG_DATA_BUF_WORDS-1)) != 0); + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -698,21 +702,7 @@ static struct platform_driver cctrng_driver = { .remove = cctrng_remove, }; -static int __init cctrng_mod_init(void) -{ - /* Compile time assertion checks */ - BUILD_BUG_ON(CCTRNG_DATA_BUF_WORDS < 6); - BUILD_BUG_ON((CCTRNG_DATA_BUF_WORDS & (CCTRNG_DATA_BUF_WORDS-1)) != 0); - - return platform_driver_register(&cctrng_driver); -} -module_init(cctrng_mod_init); - -static void __exit cctrng_mod_exit(void) -{ - platform_driver_unregister(&cctrng_driver); -} -module_exit(cctrng_mod_exit); +module_platform_driver(cctrng_driver); /* Module description */ MODULE_DESCRIPTION("ARM CryptoCell TRNG Driver");