On Thu, 17 Aug 2017 15:56:11 +0200 Michał Mirosław <mirq-linux@xxxxxxxxxxxx> wrote: > Mix device-specific data into randomness pool. > > Signed-off-by: Michał Mirosław <mirq-linux@xxxxxxxxxxxx> Hmm. I wondered about the firmware version as a source of randomness, but will leave it in here. Applied to the togreg branch of iio.git and pushed out as testing. Thanks, Jonathan > --- > drivers/iio/magnetometer/ak8974.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c > index 76091da20a0c..ab204f8560e3 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> > @@ -466,10 +467,12 @@ static int ak8974_detect(struct ak8974 *ak8974) > ret = regmap_read(ak8974->map, AMI305_VER, &fw); > if (ret) > return ret; > + add_device_randomness(&fw, sizeof(fw)); The firmware version seems rather to guessable to really count as randomness. presumably it would constant for a particular batch of chips. > fw &= 0x7f; /* only bits 0 thru 6 valid */ > ret = ak8974_get_u16_val(ak8974, AMI305_SN, &sn); > if (ret) > return ret; > + add_device_randomness(&sn, sizeof(sn)); This is better. The serial number should be hard to guess on a particular part. Jonathan > dev_info(&ak8974->i2c->dev, > "detected %s, FW ver %02x, S/N: %04x\n", > name, fw, sn); -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html