Skip to content

Commit

Permalink
hwrng: cn10k - Make check_rng_health() return an error code
Browse files Browse the repository at this point in the history
[ Upstream commit 32547a6 ]

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

Fixes: 38e9791 ("hwrng: cn10k - Add random number generator support")
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
nefigtut authored and gregkh committed Jun 9, 2022
1 parent cbf08dd commit 35d1f0e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions drivers/char/hw_random/cn10k-rng.c
Expand Up @@ -31,34 +31,33 @@ struct cn10k_rng {

#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;

/* 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);
if (res.a0 != 0UL)
return -EIO;

return 0;
return res.a0;
}

static int check_rng_health(struct cn10k_rng *rng)
{
u64 status;
int err;
unsigned long err;

/* Skip checking health */
if (!rng->reg_base)
return 0;
return -ENODEV;

status = readq(rng->reg_base + RNM_PF_EBG_HEALTH);
if (status & BIT_ULL(20)) {
err = reset_rng_health_state(rng);
if (err) {
dev_err(&rng->pdev->dev, "HWRNG: Health test failed (status=%llx)\n",
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;
Expand Down

0 comments on commit 35d1f0e

Please sign in to comment.