Skip to content

Commit b83c2d9

Browse files
Andre-ARMherbertx
authored andcommitted
firmware: smccc: Register smccc_trng platform device
At the moment we probe for the Random Number Generator SMCCC service, and use that in the core code (arch_get_random). However the hardware entropy can also be useful to access from userland, and be it to assess its quality. Register a platform device when the SMCCC TRNG service is detected, to allow a hw_random driver to hook onto this. The function registering the device is deliberately made in a way which allows expansion, so other services that could be exposed via a platform device (or some other interface), can be added here easily. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Mark Brown <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 5441a07 commit b83c2d9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/firmware/smccc/smccc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/init.h>
1010
#include <linux/arm-smccc.h>
1111
#include <linux/kernel.h>
12+
#include <linux/platform_device.h>
1213
#include <asm/archrandom.h>
1314

1415
static u32 smccc_version = ARM_SMCCC_VERSION_1_0;
@@ -42,3 +43,19 @@ u32 arm_smccc_get_version(void)
4243
return smccc_version;
4344
}
4445
EXPORT_SYMBOL_GPL(arm_smccc_get_version);
46+
47+
static int __init smccc_devices_init(void)
48+
{
49+
struct platform_device *pdev;
50+
51+
if (smccc_trng_available) {
52+
pdev = platform_device_register_simple("smccc_trng", -1,
53+
NULL, 0);
54+
if (IS_ERR(pdev))
55+
pr_err("smccc_trng: could not register device: %ld\n",
56+
PTR_ERR(pdev));
57+
}
58+
59+
return 0;
60+
}
61+
device_initcall(smccc_devices_init);

0 commit comments

Comments
 (0)