Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7826832rwp; Wed, 19 Jul 2023 00:25:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGqDm4O10HhNl7GFehhMr4TKsZk7QNYcMVm8lHqBeMuPTlawfYJsnlDduAQZaSx4G0ubQG2 X-Received: by 2002:a17:906:20e:b0:994:13c3:2f89 with SMTP id 14-20020a170906020e00b0099413c32f89mr1344936ejd.27.1689751510057; Wed, 19 Jul 2023 00:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689751510; cv=none; d=google.com; s=arc-20160816; b=pmAmSlqhIz7Sv//446c76fvTaPpbLnbeMi6mh7WKgI+WOd4QVVLiLdpQVH74F9G2aA 82zfoPp5QTZ7RcjukIB537n/sRHHkzjfJVVcH85itRIlDmft6AwDY02DKXWURhzJqDf0 F4d3Jog1A5b9HNpTK8iBuTu3priumW4oK6tZOjKKDu2Je6P9W49fOkIn8adfSTqRZ5/Y OEN9ID2lhUAKmCMCAIwr6ai23BvqbfdjRDMxoD90F3U/Fpp8nIHpmXqOLPaqsz1SfWkQ Uz7gnUDKIPt/I4+4Dnp9YVjD5469CIjLoGOJH/AS8kohNAT+5yapLtRpb0NVJoXHWNFn mpew== 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=xJH7nT39FRBv2flVrYQ0M4kbDo8QIGeX3RiBvsbExqQ=; fh=dVfXhkbP60ZT4KVr26y6imwTSq8xUCJNaPCgpFL70HA=; b=q0kAisgotOm5BAF8w34/fjD6qqiE3oitWz3+PXbeL2NVMSU74B3qpwjO7t8vTsWx2h s77kuAAV5aMWfmHsYr+avSt/m80QQPlXnXmK2M13r53eRbgiZZ9WG6jl5ar3dUVO7XHt 0D/IE5OL3SSrofVNc3WtixrnVHiJJ5e+11HYpjqUF/WsEdySQRgopi+8g/B1cO96et+K qlkOl2cz4uQDYpMwlgr6p0hYLiDgaRngoZR3icFJ83yok9IL0gHJPiGGLm7AUV9WNDbC dYphHhlxxPTSH+OlGkGnz0MdvzQjYA8l7Dmg2yMCkxmWfpDHV+YK68S3pLHVUQjP4dRJ nHvg== 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 i23-20020a170906851700b00988d908d1casi2437593ejx.482.2023.07.19.00.24.45; Wed, 19 Jul 2023 00:25:10 -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 S229874AbjGSHUM (ORCPT + 99 others); Wed, 19 Jul 2023 03:20:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjGSHUK (ORCPT ); Wed, 19 Jul 2023 03:20:10 -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 1B5DBE43; Wed, 19 Jul 2023 00:20:10 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,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 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"); -- 2.30.2