drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / include / linux / bsearch.h
blobe66b711d091e92640e7b96eb62a1c8e58a131d4a
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_BSEARCH_H
3 #define _LINUX_BSEARCH_H
5 #include <linux/types.h>
7 static __always_inline
8 void *__inline_bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp)
10 const char *pivot;
11 int result;
13 while (num > 0) {
14 pivot = base + (num >> 1) * size;
15 result = cmp(key, pivot);
17 if (result == 0)
18 return (void *)pivot;
20 if (result > 0) {
21 base = pivot + size;
22 num--;
24 num >>= 1;
27 return NULL;
30 extern void *bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp);
32 #endif /* _LINUX_BSEARCH_H */