If the self-test fails, it probably won't actually suddenly
start working.  Currently, this causes an endless spew of
error messages on the console and in the logs, so this patch
adds a limiter to the test.
Reported-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
 {
        struct n2rng *np = container_of(work, struct n2rng, work.work);
        int err = 0;
+       static int retries = 4;
 
        if (!(np->flags & N2RNG_FLAG_CONTROL)) {
                err = n2rng_guest_check(np);
                dev_info(&np->op->dev, "RNG ready\n");
        }
 
-       if (err && !(np->flags & N2RNG_FLAG_SHUTDOWN))
+       if (--retries == 0)
+               dev_err(&np->op->dev, "Self-test retries failed, RNG not ready\n");
+       else if (err && !(np->flags & N2RNG_FLAG_SHUTDOWN))
                schedule_delayed_work(&np->work, HZ * 2);
 }