From: Rusty Russell Date: Mon, 8 Dec 2014 08:50:37 +0000 (+0800) Subject: hwrng: use reference counts on each struct hwrng. X-Git-Tag: fixes-v4.0-rc1~106^2~60 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a2c0ba5ad00c018c0bef39a2224aca950aa33f2;p=pandora-kernel.git hwrng: use reference counts on each struct hwrng. current_rng holds one reference, and we bump it every time we want to do a read from it. This means we only hold the rng_mutex to grab or drop a reference, so accessing /sys/devices/virtual/misc/hw_random/rng_current doesn't block on read of /dev/hwrng. Using a kref is overkill (we're always under the rng_mutex), but a standard pattern. This also solves the problem that the hwrng_fillfn thread was accessing current_rng without a lock, which could change (eg. to NULL) underneath it. Signed-off-by: Rusty Russell Signed-off-by: Amos Kong Signed-off-by: Herbert Xu --- Reading git-diff-tree failed