#include #include #include #include #include "rnd.h" #include "die.h" #include "ioexact.h" #include "ioops.h" static int fdw = -1; static void randombytes_weak(unsigned char *x, size_t xlen) { int ret; if (fdw == -1) { for (;;) { fdw = open(LOW_ENTROPY_SOURCE, O_RDONLY); if (fdw != -1) break; sleep(1); } } while (xlen > 0) { if (xlen < 1048576) ret = xlen; else ret = 1048576; ret = read(fdw, x, ret); if (ret < 1) { sleep(1); continue; } x += ret; xlen -= ret; } } static void randombytes_strong(unsigned char *x, size_t xlen) { int fds, ret; fds = open_or_die(HIG_ENTROPY_SOURCE, O_RDONLY); ret = read_exact(fds, x, xlen, 0); if (ret != (int) xlen) panic("Error reading from entropy source!\n"); close(fds); } int secrand(void) { int ret; randombytes_weak((void *) &ret, sizeof(ret)); return ret; } void gen_key_bytes(unsigned char *area, size_t len) { randombytes_strong(area, len); } 8807'/> net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2016-03-02 16:24:47 +0530
committerMark Brown <broonie@kernel.org>2016-03-02 23:13:05 +0900
commit354794dacc213da7596cefea4dbcd8c094368807 (patch)
tree51a080d54afeba7ba26d46fd9b00e4e14beae6a5 /Documentation
parent670666b9e0aff40c65d8061a2f53e79eee238685 (diff)
regulator: helper: Add helper to configure active-discharge using regmap
Add helper function to set the state of active-discharge of regulator using regmap. The HW regulator driver can directly use this by providing the necessary information in the regulator descriptor. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'Documentation')