Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27130f0c authored by Mark Brown's avatar Mark Brown Committed by Theodore Ts'o
Browse files

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
parent 9dccf55f
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/bcd.h>
#include <linux/bcd.h>
#include <linux/delay.h>
#include <linux/delay.h>
#include <linux/mfd/core.h>
#include <linux/mfd/core.h>
#include <linux/random.h>


#include <linux/mfd/wm831x/core.h>
#include <linux/mfd/wm831x/core.h>
#include <linux/mfd/wm831x/otp.h>
#include <linux/mfd/wm831x/otp.h>
@@ -66,6 +67,7 @@ static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL);


int wm831x_otp_init(struct wm831x *wm831x)
int wm831x_otp_init(struct wm831x *wm831x)
{
{
	char uuid[WM831X_UNIQUE_ID_LEN];
	int ret;
	int ret;


	ret = device_create_file(wm831x->dev, &dev_attr_unique_id);
	ret = device_create_file(wm831x->dev, &dev_attr_unique_id);
@@ -73,6 +75,12 @@ int wm831x_otp_init(struct wm831x *wm831x)
		dev_err(wm831x->dev, "Unique ID attribute not created: %d\n",
		dev_err(wm831x->dev, "Unique ID attribute not created: %d\n",
			ret);
			ret);


	ret = wm831x_unique_id_read(wm831x, uuid);
	if (ret == 0)
		add_device_randomness(uuid, sizeof(uuid));
	else
		dev_err(wm831x->dev, "Failed to read UUID: %d\n", ret);

	return ret;
	return ret;
}
}