diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h --- a/sys/compat/linuxkpi/common/include/linux/list.h +++ b/sys/compat/linuxkpi/common/include/linux/list.h @@ -504,7 +504,12 @@ (pos) && ({ n = (pos)->member.next; 1; }); \ pos = hlist_entry_safe(n, typeof(*(pos)), member)) +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 +extern void list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv, + const struct list_head *a, const struct list_head *b)); +#else extern void list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv, struct list_head *a, struct list_head *b)); +#endif #endif /* _LINUXKPI_LINUX_LIST_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -32,6 +32,12 @@ #include "opt_stack.h" +/* + * We need this before we include to select the correct + * prototype for list_sort(). + */ +#define LINUXKPI_VERSION 51300 + #include #include #include @@ -2570,25 +2576,25 @@ } struct list_sort_thunk { - int (*cmp)(void *, struct list_head *, struct list_head *); + int (*cmp)(void *, const struct list_head *, const struct list_head *); void *priv; }; static inline int linux_le_cmp(const void *d1, const void *d2, void *priv) { - struct list_head *le1, *le2; + const struct list_head *le1, *le2; struct list_sort_thunk *thunk; thunk = priv; - le1 = *(__DECONST(struct list_head **, d1)); - le2 = *(__DECONST(struct list_head **, d2)); + le1 = *(const struct list_head * const *)d1; + le2 = *(const struct list_head * const *)d2; return ((thunk->cmp)(thunk->priv, le1, le2)); } void list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv, - struct list_head *a, struct list_head *b)) + const struct list_head *a, const struct list_head *b)) { struct list_sort_thunk thunk; struct list_head **ar, *le;