]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM: OMAP2+: throw the die id into the entropy pool
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 5 Sep 2013 07:29:18 +0000 (09:29 +0200)
committerTony Lindgren <tony@atomide.com>
Thu, 3 Oct 2013 18:08:56 +0000 (11:08 -0700)
At least eight bytes of this number are totally unique for the device
it seems, so this is a perfect candidate for feeding the entropy
pool. One byte more or less of constants does not matter so feed in
the entire OID struct.

This fixes the issue of similar devices initializing to the
same state initially.

Further registers could be added too, such as OMAP4
CONTROL_STD_FUSE_OPP* and CONTROL_DPLL_NWELL_TRIM* registers,
but those vary based on the SoC generation.

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Paul Walmsley <paul@pwsan.com>
Reviewed-by: Kevin Hilman <khilman@linaro.org>
Reviewed-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[tony@atomide.com: updated comments per mailing list discussion]
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/id.c

index 0289adcb6efb8dbc1f718a4e38a867afba414cfc..ef32d11c4bca6f5e08ead35d70f2177a85c68b8d 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/random.h>
 #include <linux/slab.h>
 
 #ifdef CONFIG_SOC_BUS
@@ -130,6 +131,17 @@ void omap_get_die_id(struct omap_die_id *odi)
        odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
 }
 
+static int __init omap_feed_randpool(void)
+{
+       struct omap_die_id odi;
+
+       /* Throw the die ID into the entropy pool at boot */
+       omap_get_die_id(&odi);
+       add_device_randomness(&odi, sizeof(odi));
+       return 0;
+}
+omap_device_initcall(omap_feed_randpool);
+
 void __init omap2xxx_check_revision(void)
 {
        int i, j;