Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754946Ab3IYJYi (ORCPT ); Wed, 25 Sep 2013 05:24:38 -0400 Received: from ozlabs.org ([203.10.76.45]:43845 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754302Ab3IYJY0 (ORCPT ); Wed, 25 Sep 2013 05:24:26 -0400 From: Michael Ellerman To: Cc: , mpm@selenic.com, herbert@gondor.hengli.com.au Subject: [PATCH 2/2] hwrng: Return errors to upper levels in pseries-rng.c Date: Wed, 25 Sep 2013 19:24:17 +1000 Message-Id: <1380101057-29903-2-git-send-email-michael@ellerman.id.au> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1380101057-29903-1-git-send-email-michael@ellerman.id.au> References: <1380101057-29903-1-git-send-email-michael@ellerman.id.au> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1536 Lines: 50 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 --- drivers/char/hw_random/pseries-rng.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/pseries-rng.c b/drivers/char/hw_random/pseries-rng.c index 9dbeed3..ab7ffde 100644 --- a/drivers/char/hw_random/pseries-rng.c +++ b/drivers/char/hw_random/pseries-rng.c @@ -17,6 +17,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include #include #include #include @@ -24,10 +27,15 @@ static int pseries_rng_data_read(struct hwrng *rng, u32 *data) { - if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) { - printk(KERN_ERR "pseries rng hcall error\n"); - return 0; + int rc; + + rc = plpar_hcall(H_RANDOM, (unsigned long *)data); + if (rc != H_SUCCESS) { + pr_err_ratelimited("H_RANDOM call failed %d\n", rc); + return -EIO; } + + /* The hypervisor interface returns 64 bits */ return 8; } -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/