aboutsummaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-wm831x.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-08-13 11:28:17 -0400
committerSteven Rostedt <rostedt@goodmis.org>2012-08-13 11:28:17 -0400
commit139803a137dea5e02334692c20f07f19c42afc2e (patch)
tree8c6a149f003aa3c366e44e9bfffb8b3cd6a01fc5 /drivers/rtc/rtc-wm831x.c
parent69ebd1210e5fc6535320c9da4c6196b95fa0668c (diff)
parent8524c7870680e93cb3d8f1d3f90f927c3c0686b6 (diff)
Merge tag 'v3.2.27' into v3.2-rt
This is the 3.2.27 stable release Conflicts: kernel/irq/handle.c
Diffstat (limited to 'drivers/rtc/rtc-wm831x.c')
-rw-r--r--drivers/rtc/rtc-wm831x.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c
index bdc909bd56da..f3c211099a14 100644
--- a/drivers/rtc/rtc-wm831x.c
+++ b/drivers/rtc/rtc-wm831x.c
@@ -24,7 +24,7 @@
#include <linux/mfd/wm831x/core.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
-
+#include <linux/random.h>
/*
* R16416 (0x4020) - RTC Write Counter
@@ -96,6 +96,26 @@ struct wm831x_rtc {
unsigned int alarm_enabled:1;
};
+static void wm831x_rtc_add_randomness(struct wm831x *wm831x)
+{
+ int ret;
+ u16 reg;
+
+ /*
+ * The write counter contains a pseudo-random number which is
+ * regenerated every time we set the RTC so it should be a
+ * useful per-system source of entropy.
+ */
+ ret = wm831x_reg_read(wm831x, WM831X_RTC_WRITE_COUNTER);
+ if (ret >= 0) {
+ reg = ret;
+ add_device_randomness(&reg, sizeof(reg));
+ } else {
+ dev_warn(wm831x->dev, "Failed to read RTC write counter: %d\n",
+ ret);
+ }
+}
+
/*
* Read current time and date in RTC
*/
@@ -449,6 +469,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
alm_irq, ret);
}
+ wm831x_rtc_add_randomness(wm831x);
+
return 0;
err: