xref: /openbmc/linux/drivers/gpu/drm/lib/drm_random.h (revision 612a462a)
1 #ifndef __DRM_RANDOM_H__
2 #define __DRM_RANDOM_H__
3 
4 /* This is a temporary home for a couple of utility functions that should
5  * be transposed to lib/ at the earliest convenience.
6  */
7 
8 #include <linux/random.h>
9 
10 #define DRM_RND_STATE_INITIALIZER(seed__) ({				\
11 	struct rnd_state state__;					\
12 	prandom_seed_state(&state__, (seed__));				\
13 	state__;							\
14 })
15 
16 #define DRM_RND_STATE(name__, seed__) \
17 	struct rnd_state name__ = DRM_RND_STATE_INITIALIZER(seed__)
18 
19 unsigned int *drm_random_order(unsigned int count,
20 			       struct rnd_state *state);
21 void drm_random_reorder(unsigned int *order,
22 			unsigned int count,
23 			struct rnd_state *state);
24 
25 #endif /* !__DRM_RANDOM_H__ */
26