cam_common_util.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_COMMON_UTIL_H_
  6. #define _CAM_COMMON_UTIL_H_
  7. #include <linux/types.h>
  8. #include <linux/kernel.h>
  9. #define CAM_BITS_MASK_SHIFT(x, mask, shift) (((x) & (mask)) >> shift)
  10. #define PTR_TO_U64(ptr) ((uint64_t)(uintptr_t)ptr)
  11. #define U64_TO_PTR(ptr) ((void *)(uintptr_t)ptr)
  12. /**
  13. * cam_common_util_get_string_index()
  14. *
  15. * @brief Match the string from list of strings to return
  16. * matching index
  17. *
  18. * @strings: Pointer to list of strings
  19. * @num_strings: Number of strings in 'strings'
  20. * @matching_string: String to match
  21. * @index: Pointer to index to return matching index
  22. *
  23. * @return: 0 for success
  24. * -EINVAL for Fail
  25. */
  26. int cam_common_util_get_string_index(const char **strings,
  27. uint32_t num_strings, const char *matching_string, uint32_t *index);
  28. /**
  29. * cam_common_util_remove_duplicate_arr()
  30. *
  31. * @brief Move all the unique integers to the start of
  32. * the array and return the number of unique integers
  33. *
  34. * @array: Pointer to the first integer of array
  35. * @num: Number of elements in array
  36. *
  37. * @return: Number of unique integers in array
  38. */
  39. uint32_t cam_common_util_remove_duplicate_arr(int32_t *array,
  40. uint32_t num);
  41. #endif /* _CAM_COMMON_UTIL_H_ */