aboutsummaryrefslogtreecommitdiff
path: root/drivers/char/hw_random/optee-rng.c
AgeCommit message (Collapse)AuthorFilesLines
2020-08-21hwrng: optee - fix wait use caseJorge Ramirez-Ortiz1-2/+2
The current code waits for data to be available before attempting a second read. However the second read would not be executed as the while loop will exit. This fix does not wait if all data has been read (skips the call to msleep(0)) and reads a second time if partial data was retrieved on the first read. Worth noticing that since msleep(0) schedules a one jiffy timeout is better to skip such a call. Signed-off-by: Jorge Ramirez-Ortiz <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-08-21hwrng: optee - handle unlimited data ratesJorge Ramirez-Ortiz1-1/+1
Data rates of MAX_UINT32 will schedule an unnecessary one jiffy timeout on the call to msleep. Avoid this scenario by using 0 as the unlimited data rate. Signed-off-by: Jorge Ramirez-Ortiz <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-04-30hwrng: optee - Use UUID API for exporting the UUIDAndy Shevchenko1-1/+1
There is export_uuid() function which exports uuid_t to the u8 array. Use it instead of open coding variant. This allows to hide the uuid_t internals. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-02-20hwrng: make symbol 'optee_rng_id_table' staticWei Yongjun1-1/+1
Fixes the following sparse warning: drivers/char/hw_random/optee-rng.c:265:35: warning: symbol 'optee_rng_id_table' was not declared. Should it be static? Fixes: 5fe8b1cc6a03 ("hwrng: add OP-TEE based rng driver") Signed-off-by: Wei Yongjun <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
2019-02-20hwrng: Fix unsigned comparison with less than zeroYueHaibing1-2/+2
The return from the call to tee_client_invoke_func can be a negative error code however this is being assigned to an unsigned variable 'ret' hence the check is always false. Fix this by making 'ret' an int. Detected by Coccinelle ("Unsigned expression compared with zero: ret < 0") Fixes: 5fe8b1cc6a03 ("hwrng: add OP-TEE based rng driver") Signed-off-by: YueHaibing <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
2019-02-20hwrng: optee: Initialize some structs using memset instead of bracesNathan Chancellor1-5/+13
Clang warns: drivers/char/hw_random/optee-rng.c:80:31: warning: suggest braces around initialization of subobject [-Wmissing-braces] struct tee_param param[4] = {0}; ^ {} drivers/char/hw_random/optee-rng.c:177:31: warning: suggest braces around initialization of subobject [-Wmissing-braces] struct tee_param param[4] = {0}; ^ {} drivers/char/hw_random/optee-rng.c:212:48: warning: suggest braces around initialization of subobject [-Wmissing-braces] struct tee_ioctl_open_session_arg sess_arg = {0}; ^ {} 3 warnings generated. One way to fix these warnings is to add additional braces like Clang suggests; however, there has been a bit of push back from some maintainers, who just prefer memset as it is unambiguous, doesn't depend on a particular compiler version, and properly initializes all subobjects [1][2]. Do that here so there are no more warnings. [1]: https://lore.kernel.org/lkml/[email protected]/ [2]: https://lore.kernel.org/lkml/[email protected]/ Fixes: 5fe8b1cc6a03 ("hwrng: add OP-TEE based rng driver") Link: https://github.com/ClangBuiltLinux/linux/issues/369 Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
2019-02-01hwrng: add OP-TEE based rng driverSumit Garg1-0/+298
On ARM SoC's with TrustZone enabled, peripherals like entropy sources might not be accessible to normal world (linux in this case) and rather accessible to secure world (OP-TEE in this case) only. So this driver aims to provides a generic interface to OP-TEE based random number generator service. This driver registers on TEE bus to interact with OP-TEE based rng device/service. Signed-off-by: Sumit Garg <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Acked-by: Herbert Xu <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>