hc
2024-08-12 233ab1bd4c5697f5cdec94e60206e8c6ac609b4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * (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 */
}