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: 122430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2258907vqt; Wed, 19 Jul 2023 00:24:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGH60rfFrnW84G95qnnTVSHrbHJ0zTipTHcpLRStsO9Iqa2tspCg0aPJOnkDvO88gRGc8wC X-Received: by 2002:a17:906:9f25:b0:98e:2413:952f with SMTP id fy37-20020a1709069f2500b0098e2413952fmr1399030ejc.18.1689751479353; Wed, 19 Jul 2023 00:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689751479; cv=none; d=google.com; s=arc-20160816; b=gqpxfVNEEP6kCO5sFhyUFq/2KJxShYC2/seL/+Wn6MBaQKu0/ikvv+Kc9F5oT6erkH yr3666JS/9LikWrh+1+0ojNc0WG6toMw2ArXFQQW2zdeFSvCF3asedq53U6B5xpX4PIo K+SFFuwsLwW7bI+6sPd/tJnzjWGdyIdkqWtXnARpDpSoXAZgbpJN9FSSWPX5Tbxhthtj GNfDQDYydD3q46BFYlTlDtmQFGK9XXReluWvJVnE8KSw74Bgh6GEaQU0uf0zPEPlLKFv 3jPNcsY/FKvwt7GAljk6GMFyWLrfCSqatUyZCvoBc+0X0Vpphcp2E1z8J851d36j8+9h VmBw== 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=CYknIv88f3SweWG205rHDozbmFHC7cnj2EK43skAFv/kuME9Yn/+OL5FCOosL2Ewgh nU3N6/VBl6SzrAlmKYClfzwiz+WaZ8A8daUTklpM1cHNFMg3Pq5kFf6Vq/NVsxIMpClY E7hsOb3nzXyzYPAXPG51gMmYpoVYMOxCmus66gRF73Bm+BNeGd3U2GDIKzOFMBqA8928 4aeeVwNG0fAra17GdfZJhTn+xNDp9G7K2POJb/s1DwFnQVaRRcdEGc6xHdcxvhGg+pgD PWpHC+L82sTnUuHkGRpw1k0broziGDtgHdEfScO+Judh1iw6YVXQ7q3qailT7m0laHa4 NAHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a170906068200b009935121ecd7si2242264ejb.639.2023.07.19.00.24.15; Wed, 19 Jul 2023 00:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbjGSHUQ (ORCPT + 99 others); Wed, 19 Jul 2023 03:20:16 -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 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771832847490921386 X-GMAIL-MSGID: 1771832847490921386 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");