drm_random.h 719 B

123456789101112131415161718192021222324252627
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __DRM_RANDOM_H__
  3. #define __DRM_RANDOM_H__
  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. #include <linux/random.h>
  8. #define DRM_RND_STATE_INITIALIZER(seed__) ({ \
  9. struct rnd_state state__; \
  10. prandom_seed_state(&state__, (seed__)); \
  11. state__; \
  12. })
  13. #define DRM_RND_STATE(name__, seed__) \
  14. struct rnd_state name__ = DRM_RND_STATE_INITIALIZER(seed__)
  15. unsigned int *drm_random_order(unsigned int count,
  16. struct rnd_state *state);
  17. void drm_random_reorder(unsigned int *order,
  18. unsigned int count,
  19. struct rnd_state *state);
  20. #endif /* !__DRM_RANDOM_H__ */