aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2013-09-25 05:24:17 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-10-11 01:50:18 -0400
commitf95dabef4c70e27e5114f4802fe6234ff82ce406 (patch)
treefcdceb2c6f6159c93b8c238e46c880b79bb47b22
parent41b93b238ab394c8cf0935ec3ba31c700a2b3b25 (diff)
hwrng: Return errors to upper levels in pseries-rng.c
We don't expect to get errors from the hypervisor when reading the rng, but if we do we should pass the error up to the hwrng driver. Otherwise the hwrng driver will continue calling us forever. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--drivers/char/hw_random/pseries-rng.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/char/hw_random/pseries-rng.c b/drivers/char/hw_random/pseries-rng.c
index 5f1197929f0c..b761459a3436 100644
--- a/drivers/char/hw_random/pseries-rng.c
+++ b/drivers/char/hw_random/pseries-rng.c
@@ -17,6 +17,9 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
22#include <linux/kernel.h>
20#include <linux/module.h> 23#include <linux/module.h>
21#include <linux/hw_random.h> 24#include <linux/hw_random.h>
22#include <asm/vio.h> 25#include <asm/vio.h>
@@ -25,10 +28,15 @@
25 28
26static int pseries_rng_data_read(struct hwrng *rng, u32 *data) 29static int pseries_rng_data_read(struct hwrng *rng, u32 *data)
27{ 30{
28 if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) { 31 int rc;
29 printk(KERN_ERR "pseries rng hcall error\n"); 32
30 return 0; 33 rc = plpar_hcall(H_RANDOM, (unsigned long *)data);
34 if (rc != H_SUCCESS) {
35 pr_err_ratelimited("H_RANDOM call failed %d\n", rc);
36 return -EIO;
31 } 37 }
38
39 /* The hypervisor interface returns 64 bits */
32 return 8; 40 return 8;
33} 41}
34 42