Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d67723c6 authored by Olav Haugan's avatar Olav Haugan
Browse files

drivers: soc: qcom: Use number of bytes returned from PRNG for entropy



Use the number of bytes returned from the PRNG to specify the amount of
entropy that we are contributing to the random pool instead of assuming
we receive the amount requested.

Change-Id: I5d49206146fd5f18f69516e4ba31dd3a38a81d62
Signed-off-by: default avatarOlav Haugan <ohaugan@codeaurora.org>
parent e2a38e4c
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -56,9 +56,18 @@ void __init init_random_pool(void)
					&desc);

	if (!ret) {
		u64 bytes_received = desc.ret[0];

		if (bytes_received != SZ_512)
			pr_warn("Did not receive the expected number of bytes from PRNG: %llu\n",
				bytes_received);

		dmac_inv_range(random_buffer, random_buffer +
						RANDOM_BUFFER_SIZE);
		add_hwgenerator_randomness(random_buffer, SZ_512, SZ_512 << 3);
		bytes_received = (bytes_received <= RANDOM_BUFFER_SIZE) ?
					bytes_received : RANDOM_BUFFER_SIZE;
		add_hwgenerator_randomness(random_buffer, bytes_received,
					   bytes_received << 3);
	}
}