Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: wm831x: Feed the device UUID into device_add_randomness()

wm831x devices contain a unique ID value. Feed this into the newly added
device_add_randomness() to add some per device seed data to the pool.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org

authored by

Mark Brown and committed by
Theodore Ts'o
27130f0c 9dccf55f

+8
+8
drivers/mfd/wm831x-otp.c
··· 18 18 #include <linux/bcd.h> 19 19 #include <linux/delay.h> 20 20 #include <linux/mfd/core.h> 21 + #include <linux/random.h> 21 22 22 23 #include <linux/mfd/wm831x/core.h> 23 24 #include <linux/mfd/wm831x/otp.h> ··· 67 66 68 67 int wm831x_otp_init(struct wm831x *wm831x) 69 68 { 69 + char uuid[WM831X_UNIQUE_ID_LEN]; 70 70 int ret; 71 71 72 72 ret = device_create_file(wm831x->dev, &dev_attr_unique_id); 73 73 if (ret != 0) 74 74 dev_err(wm831x->dev, "Unique ID attribute not created: %d\n", 75 75 ret); 76 + 77 + ret = wm831x_unique_id_read(wm831x, uuid); 78 + if (ret == 0) 79 + add_device_randomness(uuid, sizeof(uuid)); 80 + else 81 + dev_err(wm831x->dev, "Failed to read UUID: %d\n", ret); 76 82 77 83 return ret; 78 84 }