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