Home | History | Annotate | Line # | Download | only in lib
      1 /*	$NetBSD: drm_random.h,v 1.2 2021/12/18 23:45:31 riastradh Exp $	*/
      2 
      3 /* SPDX-License-Identifier: GPL-2.0 */
      4 #ifndef __DRM_RANDOM_H__
      5 #define __DRM_RANDOM_H__
      6 
      7 /* This is a temporary home for a couple of utility functions that should
      8  * be transposed to lib/ at the earliest convenience.
      9  */
     10 
     11 #include <linux/random.h>
     12 
     13 #define DRM_RND_STATE_INITIALIZER(seed__) ({				\
     14 	struct rnd_state state__;					\
     15 	prandom_seed_state(&state__, (seed__));				\
     16 	state__;							\
     17 })
     18 
     19 #define DRM_RND_STATE(name__, seed__) \
     20 	struct rnd_state name__ = DRM_RND_STATE_INITIALIZER(seed__)
     21 
     22 unsigned int *drm_random_order(unsigned int count,
     23 			       struct rnd_state *state);
     24 void drm_random_reorder(unsigned int *order,
     25 			unsigned int count,
     26 			struct rnd_state *state);
     27 
     28 #endif /* !__DRM_RANDOM_H__ */
     29