You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
624 B

/*
* (C) Copyright 2021 Rockchip Electronics Co., Ltd
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <rng.h>
unsigned int rand_r(unsigned int *seedp)
{
struct udevice *dev;
unsigned int rand;
int ret;
ret = uclass_get_device(UCLASS_RNG, 0, &dev);
if (ret) {
printf("No RNG device, ret=%d\n", ret);
return ret;
}
ret = dm_rng_read(dev, &rand, sizeof(unsigned int));
if (ret) {
printf("Reading RNG failed, ret=%d\n", ret);
return ret;
}
return rand;
}
unsigned int rand(void)
{
return rand_r(0);
}
void srand(unsigned int seed)
{
/* nothing to do */
}