From: Lee Jones Subject: Re: [PATCH 4/6] hwrng: st: Add support for ST's HW Random Number Generator Date: Mon, 14 Sep 2015 09:04:51 +0100 Message-ID: <20150914080451.GD27591@x1> References: <1442002110-28733-1-git-send-email-lee.jones@linaro.org> <1442002110-28733-5-git-send-email-lee.jones@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Cc: devicetree@vger.kernel.org, herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org, Pankaj Dev , linux-crypto@vger.kernel.org, mpm@selenic.com, linux-arm-kernel@lists.infradead.org, kernel@stlinux.com To: Kieran Bingham Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org List-Id: linux-crypto.vger.kernel.org T24gU2F0LCAxMiBTZXAgMjAxNSwgS2llcmFuIEJpbmdoYW0gd3JvdGU6Cj4gT24gMTEgU2VwdGVt YmVyIDIwMTUgYXQgMjE6MDgsIExlZSBKb25lcyA8bGVlLmpvbmVzQGxpbmFyby5vcmc+IHdyb3Rl Ogo+ID4gU2lnbmVkLW9mZi1ieTogUGFua2FqIERldiA8cGFua2FqLmRldkBzdC5jb20+Cj4gPiBT aWduZWQtb2ZmLWJ5OiBMZWUgSm9uZXMgPGxlZS5qb25lc0BsaW5hcm8ub3JnPgo+ID4gLS0tCj4g PiAgZHJpdmVycy9jaGFyL2h3X3JhbmRvbS9LY29uZmlnICB8ICAxMCArKysKPiA+ICBkcml2ZXJz L2NoYXIvaHdfcmFuZG9tL01ha2VmaWxlIHwgICAxICsKPiA+ICBkcml2ZXJzL2NoYXIvaHdfcmFu ZG9tL3N0LXJuZy5jIHwgMTQyICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysKPiA+ICAzIGZpbGVzIGNoYW5nZWQsIDE1MyBpbnNlcnRpb25zKCspCj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