Commit 32547a6a authored by Vladis Dronov's avatar Vladis Dronov Committed by Herbert Xu

hwrng: cn10k - Make check_rng_health() return an error code

Currently check_rng_health() returns zero unconditionally.
Make it to output an error code and return it.

Fixes: 38e9791a ("hwrng: cn10k - Add random number generator support")
Signed-off-by: default avatarVladis Dronov <vdronov@redhat.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 753d6770
...@@ -31,26 +31,23 @@ struct cn10k_rng { ...@@ -31,26 +31,23 @@ struct cn10k_rng {
#define PLAT_OCTEONTX_RESET_RNG_EBG_HEALTH_STATE 0xc2000b0f #define PLAT_OCTEONTX_RESET_RNG_EBG_HEALTH_STATE 0xc2000b0f
static int reset_rng_health_state(struct cn10k_rng *rng) static unsigned long reset_rng_health_state(struct cn10k_rng *rng)
{ {
struct arm_smccc_res res; struct arm_smccc_res res;
/* Send SMC service call to reset EBG health state */ /* Send SMC service call to reset EBG health state */
arm_smccc_smc(PLAT_OCTEONTX_RESET_RNG_EBG_HEALTH_STATE, 0, 0, 0, 0, 0, 0, 0, &res); arm_smccc_smc(PLAT_OCTEONTX_RESET_RNG_EBG_HEALTH_STATE, 0, 0, 0, 0, 0, 0, 0, &res);
if (res.a0 != 0UL) return res.a0;
return -EIO;
return 0;
} }
static int check_rng_health(struct cn10k_rng *rng) static int check_rng_health(struct cn10k_rng *rng)
{ {
u64 status; u64 status;
int err; unsigned long err;
/* Skip checking health */ /* Skip checking health */
if (!rng->reg_base) if (!rng->reg_base)
return 0; return -ENODEV;
status = readq(rng->reg_base + RNM_PF_EBG_HEALTH); status = readq(rng->reg_base + RNM_PF_EBG_HEALTH);
if (status & BIT_ULL(20)) { if (status & BIT_ULL(20)) {
...@@ -58,7 +55,9 @@ static int check_rng_health(struct cn10k_rng *rng) ...@@ -58,7 +55,9 @@ static int check_rng_health(struct cn10k_rng *rng)
if (err) { if (err) {
dev_err(&rng->pdev->dev, "HWRNG: Health test failed (status=%llx)\n", dev_err(&rng->pdev->dev, "HWRNG: Health test failed (status=%llx)\n",
status); status);
dev_err(&rng->pdev->dev, "HWRNG: error during reset\n"); dev_err(&rng->pdev->dev, "HWRNG: error during reset (error=%lx)\n",
err);
return -EIO;
} }
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment