mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@kernel.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: miaoqing@codeaurora.org, rsalvaterra@gmail.com,
	"Toke Høiland-Jørgensen" <toke@toke.dk>,
	"Sepehrdad, Pouyan" <pouyans@qti.qualcomm.com>,
	ath9k-devel <ath9k-devel@qca.qualcomm.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"Dominik Brodowski" <linux@dominikbrodowski.net>,
	"Linux Crypto Mailing List" <linux-crypto@vger.kernel.org>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	LKML <linux-kernel@vger.kernel.org>,
	Netdev <netdev@vger.kernel.org>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: Re: [PATCH v2] ath9k: use hw_random API instead of directly dumping into random.c
Date: Wed, 16 Feb 2022 07:38:17 +0200	[thread overview]
Message-ID: <87mtir9xrq.fsf@tynnyri.adurom.net> (raw)
In-Reply-To: <20220216000230.22625-1-Jason@zx2c4.com> (Jason A. Donenfeld's message of "Wed, 16 Feb 2022 01:02:30 +0100")

"Jason A. Donenfeld" <Jason@zx2c4.com> writes:

> Hardware random number generators are supposed to use the hw_random
> framework. This commit turns ath9k's kthread-based design into a proper
> hw_random driver.
>
> This compiles, but I have no hardware or other ability to determine
> whether it works. I'll leave further development up to the ath9k
> and hw_random maintainers.
>
> Cc: Toke Høiland-Jørgensen <toke@redhat.com>
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

[...]

> +retry:
> +	if (max & ~3UL)
> +		bytes_read = ath9k_rng_data_read(sc, buf, max >> 2);
> +	if ((max & 3UL) && ath9k_rng_data_read(sc, &word, 1)) {
> +		memcpy(buf + bytes_read, &word, max & 3);
> +		bytes_read += max & 3;
> +		memzero_explicit(&word, sizeof(word));
> +	}
> +	if (max && unlikely(!bytes_read) && wait) {
> +		msleep(ath9k_rng_delay_get(++fail_stats));
> +		goto retry;
>  	}

Wouldn't a while loop be cleaner? With a some kind limit for the number
of loops, to avoid a neverending loop.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

  parent reply	other threads:[~2022-02-16  5:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAHmME9rkTP7bJBDvnejQ6BGPu13qpHKbtnjt3h33NEaTnYLirg@mail.gmail.com>
2022-02-15 15:38 ` ath9k should perhaps use hw_random api? Jason A. Donenfeld
2022-02-15 16:28   ` [PATCH] ath9k: use hw_random API instead of directly dumping into random.c Jason A. Donenfeld
2022-02-15 22:55     ` Rui Salvaterra
2022-02-15 23:22     ` Toke Høiland-Jørgensen
2022-02-15 23:52       ` Jason A. Donenfeld
2022-02-16  0:02         ` [PATCH v2] " Jason A. Donenfeld
2022-02-16  3:13           ` Florian Fainelli
2022-02-16 10:43             ` Jason A. Donenfeld
2022-02-16 11:33               ` [PATCH v3] " Jason A. Donenfeld
2022-02-16 13:27                 ` Rui Salvaterra
2022-02-17 13:51                 ` Toke Høiland-Jørgensen
2022-02-21 10:22                 ` Kalle Valo
2022-02-22 10:01                   ` Ard Biesheuvel
2022-02-22 10:13                     ` Jason A. Donenfeld
2022-02-16  5:38           ` Kalle Valo [this message]
2022-02-16  7:15           ` [PATCH v2] " Dominik Brodowski
2022-02-16  7:11         ` [PATCH] " Dominik Brodowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtir9xrq.fsf@tynnyri.adurom.net \
    --to=kvalo@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=ath9k-devel@qca.qualcomm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=miaoqing@codeaurora.org \
    --cc=netdev@vger.kernel.org \
    --cc=pouyans@qti.qualcomm.com \
    --cc=rsalvaterra@gmail.com \
    --cc=toke@redhat.com \
    --cc=toke@toke.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®