qdf_util.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /*
  2. * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * DOC: qdf_util.h
  28. * This file defines utility functions.
  29. */
  30. #ifndef _QDF_UTIL_H
  31. #define _QDF_UTIL_H
  32. #include <i_qdf_util.h>
  33. #ifdef QCA_CONFIG_SMP
  34. #define QDF_MAX_AVAILABLE_CPU 8
  35. #else
  36. #define QDF_MAX_AVAILABLE_CPU 1
  37. #endif
  38. typedef __qdf_wait_queue_head_t qdf_wait_queue_head_t;
  39. typedef void (*qdf_fw_down_callback)(void);
  40. /**
  41. * qdf_unlikely - Compiler-dependent macro denoting code likely to execute
  42. * @_expr: expression to be checked
  43. */
  44. #define qdf_unlikely(_expr) __qdf_unlikely(_expr)
  45. /**
  46. * qdf_likely - Compiler-dependent macro denoting code unlikely to execute
  47. * @_expr: expression to be checked
  48. */
  49. #define qdf_likely(_expr) __qdf_likely(_expr)
  50. /**
  51. * qdf_mb - read + write memory barrier.
  52. */
  53. #define qdf_mb() __qdf_mb()
  54. /**
  55. * qdf_ioread32 - read a register
  56. * @offset: register address
  57. */
  58. #define qdf_ioread32(offset) __qdf_ioread32(offset)
  59. /**
  60. * qdf_iowrite32 - write a register
  61. * @offset: register address
  62. * @value: value to write (32bit value)
  63. */
  64. #define qdf_iowrite32(offset, value) __qdf_iowrite32(offset, value)
  65. /**
  66. * qdf_assert - assert "expr" evaluates to false.
  67. */
  68. #ifdef QDF_DEBUG
  69. #define qdf_assert(expr) __qdf_assert(expr)
  70. #else
  71. #define qdf_assert(expr)
  72. #endif /* QDF_DEBUG */
  73. /**
  74. * qdf_assert_always - alway assert "expr" evaluates to false.
  75. */
  76. #define qdf_assert_always(expr) __qdf_assert(expr)
  77. /**
  78. * qdf_target_assert_always - alway target assert "expr" evaluates to false.
  79. */
  80. #define qdf_target_assert_always(expr) __qdf_target_assert(expr)
  81. /**
  82. * QDF_MAX - get maximum of two values
  83. * @_x: 1st arguement
  84. * @_y: 2nd arguement
  85. */
  86. #define QDF_MAX(_x, _y) (((_x) > (_y)) ? (_x) : (_y))
  87. /**
  88. * QDF_MIN - get minimum of two values
  89. * @_x: 1st arguement
  90. * @_y: 2nd arguement
  91. */
  92. #define QDF_MIN(_x, _y) (((_x) < (_y)) ? (_x) : (_y))
  93. /**
  94. * qdf_status_to_os_return - returns the status to OS.
  95. * @status: enum QDF_STATUS
  96. *
  97. * returns: int status success/failure
  98. */
  99. static inline int qdf_status_to_os_return(QDF_STATUS status)
  100. {
  101. return __qdf_status_to_os_return(status);
  102. }
  103. /**
  104. * qdf_set_bit() - set bit in address
  105. * @nr: bit number to be set
  106. * @addr: address buffer pointer
  107. *
  108. * Return: none
  109. */
  110. #define qdf_set_bit(nr, addr) __qdf_set_bit(nr, addr)
  111. /**
  112. * qdf_clear_bit() - clear bit in address
  113. * @nr: bit number to be clear
  114. * @addr: address buffer pointer
  115. *
  116. * Return: none
  117. */
  118. #define qdf_clear_bit(nr, addr) __qdf_clear_bit(nr, addr)
  119. /**
  120. * qdf_test_bit() - test bit position in address
  121. * @nr: bit number to be tested
  122. * @addr: address buffer pointer
  123. *
  124. * Return: none
  125. */
  126. #define qdf_test_bit(nr, addr) __qdf_test_bit(nr, addr)
  127. /**
  128. * qdf_test_and_clear_bit() - test and clear bit position in address
  129. * @nr: bit number to be tested
  130. * @addr: address buffer pointer
  131. *
  132. * Return: none
  133. */
  134. #define qdf_test_and_clear_bit(nr, addr) __qdf_test_and_clear_bit(nr, addr)
  135. /**
  136. * qdf_find_first_bit() - find first bit position in address
  137. * @addr: address buffer pointer
  138. * @nbits: number of bits
  139. *
  140. * Return: position first set bit in addr
  141. */
  142. #define qdf_find_first_bit(addr, nbits) __qdf_find_first_bit(addr, nbits)
  143. #define qdf_wait_queue_interruptible(wait_queue, condition) \
  144. __qdf_wait_queue_interruptible(wait_queue, condition)
  145. /**
  146. * qdf_wait_queue_timeout() - wait for specified time on given condition
  147. * @wait_queue: wait queue to wait on
  148. * @condition: condition to wait on
  149. * @timeout: timeout value in jiffies
  150. *
  151. * Return: 0 if condition becomes false after timeout
  152. * 1 or remaining jiffies, if condition becomes true during timeout
  153. */
  154. #define qdf_wait_queue_timeout(wait_queue, condition, timeout) \
  155. __qdf_wait_queue_timeout(wait_queue, \
  156. condition, timeout)
  157. #define qdf_init_waitqueue_head(_q) __qdf_init_waitqueue_head(_q)
  158. #define qdf_wake_up_interruptible(_q) __qdf_wake_up_interruptible(_q)
  159. /**
  160. * qdf_wake_up() - wakes up sleeping waitqueue
  161. * @wait_queue: wait queue, which needs wake up
  162. *
  163. * Return: none
  164. */
  165. #define qdf_wake_up(_q) __qdf_wake_up(_q)
  166. #define qdf_wake_up_completion(_q) __qdf_wake_up_completion(_q)
  167. /**
  168. * qdf_container_of - cast a member of a structure out to the containing
  169. * structure
  170. * @ptr: the pointer to the member.
  171. * @type: the type of the container struct this is embedded in.
  172. * @member: the name of the member within the struct.
  173. */
  174. #define qdf_container_of(ptr, type, member) \
  175. __qdf_container_of(ptr, type, member)
  176. /**
  177. * qdf_is_pwr2 - test input value is power of 2 integer
  178. * @value: input integer
  179. */
  180. #define QDF_IS_PWR2(value) (((value) ^ ((value)-1)) == ((value) << 1) - 1)
  181. /**
  182. * qdf_roundup() - roundup the input value
  183. * @x: value to roundup
  184. * @y: input value rounded to multiple of this
  185. *
  186. * Return: rounded value
  187. */
  188. #define qdf_roundup(x, y) __qdf_roundup(x, y)
  189. /**
  190. * qdf_is_macaddr_equal() - compare two QDF MacAddress
  191. * @mac_addr1: Pointer to one qdf MacAddress to compare
  192. * @mac_addr2: Pointer to the other qdf MacAddress to compare
  193. *
  194. * This function returns a bool that tells if a two QDF MacAddress'
  195. * are equivalent.
  196. *
  197. * Return: true if the MacAddress's are equal
  198. * not true if the MacAddress's are not equal
  199. */
  200. static inline bool qdf_is_macaddr_equal(struct qdf_mac_addr *mac_addr1,
  201. struct qdf_mac_addr *mac_addr2)
  202. {
  203. return __qdf_is_macaddr_equal(mac_addr1, mac_addr2);
  204. }
  205. /**
  206. * qdf_is_macaddr_zero() - check for a MacAddress of all zeros.
  207. * @mac_addr: pointer to the struct qdf_mac_addr to check.
  208. *
  209. * This function returns a bool that tells if a MacAddress is made up of
  210. * all zeros.
  211. *
  212. * Return: true if the MacAddress is all Zeros
  213. * false if the MacAddress is not all Zeros.
  214. */
  215. static inline bool qdf_is_macaddr_zero(struct qdf_mac_addr *mac_addr)
  216. {
  217. struct qdf_mac_addr zero_mac_addr = QDF_MAC_ADDR_ZERO_INIT;
  218. return qdf_is_macaddr_equal(mac_addr, &zero_mac_addr);
  219. }
  220. /**
  221. * qdf_zero_macaddr() - zero out a MacAddress
  222. * @mac_addr: pointer to the struct qdf_mac_addr to zero.
  223. *
  224. * This function zeros out a QDF MacAddress type.
  225. *
  226. * Return: none
  227. */
  228. static inline void qdf_zero_macaddr(struct qdf_mac_addr *mac_addr)
  229. {
  230. __qdf_zero_macaddr(mac_addr);
  231. }
  232. /**
  233. * qdf_is_macaddr_group() - check for a MacAddress is a 'group' address
  234. * @mac_addr1: pointer to the qdf MacAddress to check
  235. *
  236. * This function returns a bool that tells if a the input QDF MacAddress
  237. * is a "group" address. Group addresses have the 'group address bit' turned
  238. * on in the MacAddress. Group addresses are made up of Broadcast and
  239. * Multicast addresses.
  240. *
  241. * Return: true if the input MacAddress is a Group address
  242. * false if the input MacAddress is not a Group address
  243. */
  244. static inline bool qdf_is_macaddr_group(struct qdf_mac_addr *mac_addr)
  245. {
  246. return mac_addr->bytes[0] & 0x01;
  247. }
  248. /**
  249. * qdf_is_macaddr_broadcast() - check for a MacAddress is a broadcast address
  250. * @mac_addr: Pointer to the qdf MacAddress to check
  251. *
  252. * This function returns a bool that tells if a the input QDF MacAddress
  253. * is a "broadcast" address.
  254. *
  255. * Return: true if the input MacAddress is a broadcast address
  256. * flase if the input MacAddress is not a broadcast address
  257. */
  258. static inline bool qdf_is_macaddr_broadcast(struct qdf_mac_addr *mac_addr)
  259. {
  260. struct qdf_mac_addr broadcast_mac_addr = QDF_MAC_ADDR_BCAST_INIT;
  261. return qdf_is_macaddr_equal(mac_addr, &broadcast_mac_addr);
  262. }
  263. /**
  264. * qdf_copy_macaddr() - copy a QDF MacAddress
  265. * @dst_addr: pointer to the qdf MacAddress to copy TO (the destination)
  266. * @src_addr: pointer to the qdf MacAddress to copy FROM (the source)
  267. *
  268. * This function copies a QDF MacAddress into another QDF MacAddress.
  269. *
  270. * Return: none
  271. */
  272. static inline void qdf_copy_macaddr(struct qdf_mac_addr *dst_addr,
  273. struct qdf_mac_addr *src_addr)
  274. {
  275. *dst_addr = *src_addr;
  276. }
  277. /**
  278. * qdf_set_macaddr_broadcast() - set a QDF MacAddress to the 'broadcast'
  279. * @mac_addr: pointer to the qdf MacAddress to set to broadcast
  280. *
  281. * This function sets a QDF MacAddress to the 'broadcast' MacAddress. Broadcast
  282. * MacAddress contains all 0xFF bytes.
  283. *
  284. * Return: none
  285. */
  286. static inline void qdf_set_macaddr_broadcast(struct qdf_mac_addr *mac_addr)
  287. {
  288. __qdf_set_macaddr_broadcast(mac_addr);
  289. }
  290. /**
  291. * qdf_set_u16() - Assign 16-bit unsigned value to a byte array base on CPU's
  292. * endianness.
  293. * @ptr: Starting address of a byte array
  294. * @value: The value to assign to the byte array
  295. *
  296. * Caller must validate the byte array has enough space to hold the vlaue
  297. *
  298. * Return: The address to the byte after the assignment. This may or may not
  299. * be valid. Caller to verify.
  300. */
  301. static inline uint8_t *qdf_set_u16(uint8_t *ptr, uint16_t value)
  302. {
  303. #if defined(ANI_BIG_BYTE_ENDIAN)
  304. *(ptr) = (uint8_t) (value >> 8);
  305. *(ptr + 1) = (uint8_t) (value);
  306. #else
  307. *(ptr + 1) = (uint8_t) (value >> 8);
  308. *(ptr) = (uint8_t) (value);
  309. #endif
  310. return ptr + 2;
  311. }
  312. /**
  313. * qdf_get_u16() - Retrieve a 16-bit unsigned value from a byte array base on
  314. * CPU's endianness.
  315. * @ptr: Starting address of a byte array
  316. * @value: Pointer to a caller allocated buffer for 16 bit value. Value is to
  317. * assign to this location.
  318. *
  319. * Caller must validate the byte array has enough space to hold the vlaue
  320. *
  321. * Return: The address to the byte after the assignment. This may or may not
  322. * be valid. Caller to verify.
  323. */
  324. static inline uint8_t *qdf_get_u16(uint8_t *ptr, uint16_t *value)
  325. {
  326. #if defined(ANI_BIG_BYTE_ENDIAN)
  327. *value = (((uint16_t) (*ptr << 8)) | ((uint16_t) (*(ptr + 1))));
  328. #else
  329. *value = (((uint16_t) (*(ptr + 1) << 8)) | ((uint16_t) (*ptr)));
  330. #endif
  331. return ptr + 2;
  332. }
  333. /**
  334. * qdf_get_u32() - retrieve a 32-bit unsigned value from a byte array base on
  335. * CPU's endianness.
  336. * @ptr: Starting address of a byte array
  337. * @value: Pointer to a caller allocated buffer for 32 bit value. Value is to
  338. * assign to this location.
  339. *
  340. * Caller must validate the byte array has enough space to hold the vlaue
  341. *
  342. * Return: The address to the byte after the assignment. This may or may not
  343. * be valid. Caller to verify.
  344. */
  345. static inline uint8_t *qdf_get_u32(uint8_t *ptr, uint32_t *value)
  346. {
  347. #if defined(ANI_BIG_BYTE_ENDIAN)
  348. *value = ((uint32_t) (*(ptr) << 24) |
  349. (uint32_t) (*(ptr + 1) << 16) |
  350. (uint32_t) (*(ptr + 2) << 8) | (uint32_t) (*(ptr + 3)));
  351. #else
  352. *value = ((uint32_t) (*(ptr + 3) << 24) |
  353. (uint32_t) (*(ptr + 2) << 16) |
  354. (uint32_t) (*(ptr + 1) << 8) | (uint32_t) (*(ptr)));
  355. #endif
  356. return ptr + 4;
  357. }
  358. /**
  359. * qdf_ntohs - Convert a 16-bit value from network byte order to host byte order
  360. */
  361. #define qdf_ntohs(x) __qdf_ntohs(x)
  362. /**
  363. * qdf_ntohl - Convert a 32-bit value from network byte order to host byte order
  364. */
  365. #define qdf_ntohl(x) __qdf_ntohl(x)
  366. /**
  367. * qdf_htons - Convert a 16-bit value from host byte order to network byte order
  368. */
  369. #define qdf_htons(x) __qdf_htons(x)
  370. /**
  371. * qdf_htonl - Convert a 32-bit value from host byte order to network byte order
  372. */
  373. #define qdf_htonl(x) __qdf_htonl(x)
  374. /**
  375. * qdf_cpu_to_le16 - Convert a 16-bit value from CPU byte order to
  376. * little-endian byte order
  377. *
  378. * @x: value to be converted
  379. */
  380. #define qdf_cpu_to_le16(x) __qdf_cpu_to_le16(x)
  381. /**
  382. * qdf_cpu_to_le32 - Convert a 32-bit value from CPU byte order to
  383. * little-endian byte order
  384. *
  385. * @x: value to be converted
  386. */
  387. #define qdf_cpu_to_le32(x) __qdf_cpu_to_le32(x)
  388. /**
  389. * qdf_cpu_to_le64 - Convert a 64-bit value from CPU byte order to
  390. * little-endian byte order
  391. *
  392. * @x: value to be converted
  393. */
  394. #define qdf_cpu_to_le64(x) __qdf_cpu_to_le64(x)
  395. /**
  396. * qdf_le16_to_cpu - Convert a 16-bit value from little-endian byte order
  397. * to CPU byte order
  398. *
  399. * @x: value to be converted
  400. */
  401. #define qdf_le16_to_cpu(x) __qdf_le16_to_cpu(x)
  402. /**
  403. * qdf_le32_to_cpu - Convert a 32-bit value from little-endian byte
  404. * order to CPU byte order
  405. *
  406. * @x: value to be converted
  407. */
  408. #define qdf_le32_to_cpu(x) __qdf_le32_to_cpu(x)
  409. /**
  410. * qdf_le64_to_cpu - Convert a 64-bit value from little-endian byte
  411. * order to CPU byte order
  412. *
  413. * @x: value to be converted
  414. */
  415. #define qdf_le64_to_cpu(x) __qdf_le64_to_cpu(x)
  416. /**
  417. * qdf_cpu_to_be16 - Convert a 16-bit value from CPU byte order to
  418. * big-endian byte order
  419. *
  420. * @x: value to be converted
  421. */
  422. #define qdf_cpu_to_be16(x) __qdf_cpu_to_be16(x)
  423. /**
  424. * qdf_cpu_to_be32 - Convert a 32-bit value from CPU byte order to
  425. * big-endian byte order
  426. *
  427. * @x: value to be converted
  428. */
  429. #define qdf_cpu_to_be32(x) __qdf_cpu_to_be32(x)
  430. /**
  431. * qdf_cpu_to_be64 - Convert a 64-bit value from CPU byte order to
  432. * big-endian byte order
  433. *
  434. * @x: value to be converted
  435. */
  436. #define qdf_cpu_to_be64(x) __qdf_cpu_to_be64(x)
  437. /**
  438. * qdf_be16_to_cpu - Convert a 16-bit value from big-endian byte order
  439. * to CPU byte order
  440. *
  441. * @x: value to be converted
  442. */
  443. #define qdf_be16_to_cpu(x) __qdf_be16_to_cpu(x)
  444. /**
  445. * qdf_be32_to_cpu - Convert a 32-bit value from big-endian byte order
  446. * to CPU byte order
  447. *
  448. * @x: value to be converted
  449. */
  450. #define qdf_be32_to_cpu(x) __qdf_be32_to_cpu(x)
  451. /**
  452. * qdf_be64_to_cpu - Convert a 64-bit value from big-endian byte order
  453. * to CPU byte order
  454. *
  455. * @x: value to be converted
  456. */
  457. #define qdf_be64_to_cpu(x) __qdf_be64_to_cpu(x)
  458. /**
  459. * qdf_function - replace with the name of the current function
  460. */
  461. #define qdf_function __qdf_function
  462. /**
  463. * qdf_min - minimum of two numbers
  464. */
  465. #define qdf_min(a, b) __qdf_min(a, b)
  466. /**
  467. * qdf_get_pwr2() - get next power of 2 integer from input value
  468. * @value: input value to find next power of 2 integer
  469. *
  470. * Get next power of 2 integer from input value
  471. *
  472. * Return: Power of 2 integer
  473. */
  474. static inline int qdf_get_pwr2(int value)
  475. {
  476. int log2;
  477. if (QDF_IS_PWR2(value))
  478. return value;
  479. log2 = 0;
  480. while (value) {
  481. value >>= 1;
  482. log2++;
  483. }
  484. return 1 << log2;
  485. }
  486. static inline
  487. int qdf_get_cpu(void)
  488. {
  489. return __qdf_get_cpu();
  490. }
  491. /**
  492. * qdf_device_init_wakeup() - allow a device to wake up the aps system
  493. * @qdf_dev: the qdf device context
  494. * @enable: enable/disable the device as a wakup source
  495. *
  496. * Return: 0 or errno
  497. */
  498. static inline int qdf_device_init_wakeup(qdf_device_t qdf_dev, bool enable)
  499. {
  500. return __qdf_device_init_wakeup(qdf_dev, enable);
  501. }
  502. static inline
  503. uint64_t qdf_get_totalramsize(void)
  504. {
  505. return __qdf_get_totalramsize();
  506. }
  507. /**
  508. * qdf_get_lower_32_bits() - get lower 32 bits from an address.
  509. * @addr: address
  510. *
  511. * This api returns the lower 32 bits of an address.
  512. *
  513. * Return: lower 32 bits.
  514. */
  515. static inline
  516. uint32_t qdf_get_lower_32_bits(qdf_dma_addr_t addr)
  517. {
  518. return __qdf_get_lower_32_bits(addr);
  519. }
  520. /**
  521. * qdf_get_upper_32_bits() - get upper 32 bits from an address.
  522. * @addr: address
  523. *
  524. * This api returns the upper 32 bits of an address.
  525. *
  526. * Return: upper 32 bits.
  527. */
  528. static inline
  529. uint32_t qdf_get_upper_32_bits(qdf_dma_addr_t addr)
  530. {
  531. return __qdf_get_upper_32_bits(addr);
  532. }
  533. /**
  534. * qdf_rounddown_pow_of_two() - Round down to nearest power of two
  535. * @n: number to be tested
  536. *
  537. * Test if the input number is power of two, and return the nearest power of two
  538. *
  539. * Return: number rounded down to the nearest power of two
  540. */
  541. static inline
  542. unsigned long qdf_rounddown_pow_of_two(unsigned long n)
  543. {
  544. return __qdf_rounddown_pow_of_two(n);
  545. }
  546. /**
  547. * qdf_set_dma_coherent_mask() - set max number of bits allowed in dma addr
  548. * @dev: device pointer
  549. * @addr_bits: max number of bits allowed in dma address
  550. *
  551. * This API sets the maximum allowed number of bits in the dma address.
  552. *
  553. * Return: 0 - success, non zero - failure
  554. */
  555. static inline
  556. int qdf_set_dma_coherent_mask(struct device *dev, uint8_t addr_bits)
  557. {
  558. return __qdf_set_dma_coherent_mask(dev, addr_bits);
  559. }
  560. /**
  561. * qdf_do_div() - wrapper function for kernel macro(do_div).
  562. * @dividend: Dividend value
  563. * @divisor : Divisor value
  564. *
  565. * Return: Quotient
  566. */
  567. static inline
  568. uint64_t qdf_do_div(uint64_t dividend, uint32_t divisor)
  569. {
  570. return __qdf_do_div(dividend, divisor);
  571. }
  572. /**
  573. * qdf_do_div_rem() - wrapper function for kernel macro(do_div)
  574. * to get remainder.
  575. * @dividend: Dividend value
  576. * @divisor : Divisor value
  577. *
  578. * Return: remainder
  579. */
  580. static inline
  581. uint64_t qdf_do_div_rem(uint64_t dividend, uint32_t divisor)
  582. {
  583. return __qdf_do_div_rem(dividend, divisor);
  584. }
  585. /**
  586. * qdf_get_random_bytes() - returns nbytes bytes of random
  587. * data
  588. *
  589. * Return: random bytes of data
  590. */
  591. static inline
  592. void qdf_get_random_bytes(void *buf, int nbytes)
  593. {
  594. return __qdf_get_random_bytes(buf, nbytes);
  595. }
  596. /**
  597. * qdf_register_fw_down_callback() - API to register fw down callback
  598. *
  599. * Return: none
  600. */
  601. void qdf_register_fw_down_callback(qdf_fw_down_callback *fw_down_callback);
  602. #endif /*_QDF_UTIL_H*/