summaryrefslogtreecommitdiffstats
path: root/drivers/iio/magnetometer
diff options
context:
space:
mode:
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>2017-08-17 15:56:11 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2017-08-20 16:17:27 +0200
commit408cc6eb1e3adc43a434d5d584708c2a1d2c6c32 (patch)
tree35482b785e4330670f6c9e34ce3f92a63bc8c98e /drivers/iio/magnetometer
parentiio: magnetometer: ak8974: support AMI306 variant (diff)
downloadlinux-408cc6eb1e3adc43a434d5d584708c2a1d2c6c32.tar.xz
linux-408cc6eb1e3adc43a434d5d584708c2a1d2c6c32.zip
iio: magnetometer: ak8974: add_device_randomness (serial number)
Mix device-specific data into randomness pool. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/magnetometer')
-rw-r--r--drivers/iio/magnetometer/ak8974.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
index 76091da20a0c..b1c209faf1b1 100644
--- a/drivers/iio/magnetometer/ak8974.c
+++ b/drivers/iio/magnetometer/ak8974.c
@@ -20,6 +20,7 @@
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/bitops.h>
+#include <linux/random.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
@@ -470,6 +471,7 @@ static int ak8974_detect(struct ak8974 *ak8974)
ret = ak8974_get_u16_val(ak8974, AMI305_SN, &sn);
if (ret)
return ret;
+ add_device_randomness(&sn, sizeof(sn));
dev_info(&ak8974->i2c->dev,
"detected %s, FW ver %02x, S/N: %04x\n",
name, fw, sn);