Skip to content
This repository
Browse code

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

commit 27130f0 upstream.

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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information...
commit 3da77549a1d212c47e134c05333e1e5ed72981c5 1 parent 648deda
Mark Brown broonie authored Ben Hutchings committed

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. +8 0 drivers/mfd/wm831x-otp.c
8 drivers/mfd/wm831x-otp.c
@@ -18,6 +18,7 @@
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>
@@ -66,6 +67,7 @@ static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL);
66 67
67 68 int wm831x_otp_init(struct wm831x *wm831x)
68 69 {
  70 + char uuid[WM831X_UNIQUE_ID_LEN];
69 71 int ret;
70 72
71 73 ret = device_create_file(wm831x->dev, &dev_attr_unique_id);
@@ -73,6 +75,12 @@ int wm831x_otp_init(struct wm831x *wm831x)
73 75 dev_err(wm831x->dev, "Unique ID attribute not created: %d\n",
74 76 ret);
75 77
  78 + ret = wm831x_unique_id_read(wm831x, uuid);
  79 + if (ret == 0)
  80 + add_device_randomness(uuid, sizeof(uuid));
  81 + else
  82 + dev_err(wm831x->dev, "Failed to read UUID: %d\n", ret);
  83 +
76 84 return ret;
77 85 }
78 86

0 comments on commit 3da7754

Please sign in to comment.
Something went wrong with that request. Please try again.