Skip to content

Commit

Permalink
hwrng: cctrng - don't open code init and exit functions
Browse files Browse the repository at this point in the history
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 <martin@kaiser.cx>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
martin-kaiser authored and herbertx committed Jul 28, 2023
1 parent 9f3fa6b commit 80e40fe
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions drivers/char/hw_random/cctrng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 80e40fe

Please sign in to comment.