X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=include%2Flinux%2Frandom.h;h=fb7ab9de5f360878805779e489d1d35a2f205fa0;hp=25d02fe5c9b5a6561e19bd3410a4132ea98dffd8;hb=cad719d86e9dbd06634eaba6401e022c8101d6b2;hpb=dc85ce155b7cad4c39c1fc95b4f6281920cef3c8 diff --git a/include/linux/random.h b/include/linux/random.h index 25d02fe5c9b5..fb7ab9de5f36 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -40,6 +40,10 @@ struct rand_pool_info { __u32 buf[0]; }; +struct rnd_state { + __u32 s1, s2, s3; +}; + /* Exported functions */ #ifdef __KERNEL__ @@ -74,6 +78,30 @@ unsigned long randomize_range(unsigned long start, unsigned long end, unsigned l u32 random32(void); void srandom32(u32 seed); +u32 prandom32(struct rnd_state *); + +/* + * Handle minimum values for seeds + */ +static inline u32 __seed(u32 x, u32 m) +{ + return (x < m) ? x + m : x; +} + +/** + * prandom32_seed - set seed for prandom32(). + * @state: pointer to state structure to receive the seed. + * @seed: arbitrary 64-bit value to use as a seed. + */ +static inline void prandom32_seed(struct rnd_state *state, u64 seed) +{ + u32 i = (seed >> 32) ^ (seed << 10) ^ seed; + + state->s1 = __seed(i, 1); + state->s2 = __seed(i, 7); + state->s3 = __seed(i, 15); +} + #endif /* __KERNEL___ */ #endif /* _LINUX_RANDOM_H */