Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 320722
b: refs/heads/master
c: 9dccf55
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown authored and Theodore Ts'o committed Jul 19, 2012
1 parent 04e8f52 commit 13ca131
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 330e0a01d54c2b8606c56816f99af6ebc58ec92c
refs/heads/master: 9dccf55f4cb011a7552a8a2749a580662f5ed8ed
24 changes: 23 additions & 1 deletion trunk/drivers/rtc/rtc-wm831x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -431,6 +451,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
alm_irq, ret);
}

wm831x_rtc_add_randomness(wm831x);

return 0;

err:
Expand Down

0 comments on commit 13ca131

Please sign in to comment.