From: jsg Date: Fri, 1 Oct 2021 04:36:38 +0000 (+0000) Subject: treewide: Change list_sort to use const pointers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6dafb210c291ca8de59b735f5c1fc3744cd59dd3;p=openbsd treewide: Change list_sort to use const pointers From Sami Tolvanen 55e6f8b3c0f5cc600df12ddd0371d2703b910fd7 in linux 5.10.y/5.10.70 4f0f586bf0c898233d8f316f471a21db2abd522d in mainline linux --- diff --git a/sys/dev/pci/drm/drm_modes.c b/sys/dev/pci/drm/drm_modes.c index f8753b4e726..563cc5a48cc 100644 --- a/sys/dev/pci/drm/drm_modes.c +++ b/sys/dev/pci/drm/drm_modes.c @@ -1290,7 +1290,8 @@ EXPORT_SYMBOL(drm_mode_prune_invalid); * Negative if @lh_a is better than @lh_b, zero if they're equivalent, or * positive if @lh_b is better than @lh_a. */ -static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head *lh_b) +static int drm_mode_compare(void *priv, const struct list_head *lh_a, + const struct list_head *lh_b) { struct drm_display_mode *a = list_entry(lh_a, struct drm_display_mode, head); struct drm_display_mode *b = list_entry(lh_b, struct drm_display_mode, head); diff --git a/sys/dev/pci/drm/i915/gt/intel_engine_user.c b/sys/dev/pci/drm/i915/gt/intel_engine_user.c index fd9bda463b0..2cddff8ffa0 100644 --- a/sys/dev/pci/drm/i915/gt/intel_engine_user.c +++ b/sys/dev/pci/drm/i915/gt/intel_engine_user.c @@ -49,7 +49,8 @@ static const u8 uabi_classes[] = { [VIDEO_ENHANCEMENT_CLASS] = I915_ENGINE_CLASS_VIDEO_ENHANCE, }; -static int engine_cmp(void *priv, struct list_head *A, struct list_head *B) +static int engine_cmp(void *priv, const struct list_head *A, + const struct list_head *B) { const struct intel_engine_cs *a = container_of((struct rb_node *)A, typeof(*a), uabi_node); diff --git a/sys/dev/pci/drm/i915/gvt/debugfs.c b/sys/dev/pci/drm/i915/gvt/debugfs.c index 62e6a14ad58..9f1c209d925 100644 --- a/sys/dev/pci/drm/i915/gvt/debugfs.c +++ b/sys/dev/pci/drm/i915/gvt/debugfs.c @@ -41,7 +41,7 @@ struct diff_mmio { /* Compare two diff_mmio items. */ static int mmio_offset_compare(void *priv, - struct list_head *a, struct list_head *b) + const struct list_head *a, const struct list_head *b) { struct diff_mmio *ma; struct diff_mmio *mb; diff --git a/sys/dev/pci/drm/i915/selftests/i915_gem_gtt.c b/sys/dev/pci/drm/i915/selftests/i915_gem_gtt.c index 2134e5e9fb0..681a7dc9176 100644 --- a/sys/dev/pci/drm/i915/selftests/i915_gem_gtt.c +++ b/sys/dev/pci/drm/i915/selftests/i915_gem_gtt.c @@ -1075,7 +1075,8 @@ static int igt_ppgtt_shrink_boom(void *arg) return exercise_ppgtt(arg, shrink_boom); } -static int sort_holes(void *priv, struct list_head *A, struct list_head *B) +static int sort_holes(void *priv, const struct list_head *A, + const struct list_head *B) { struct drm_mm_node *a = list_entry(A, typeof(*a), hole_stack); struct drm_mm_node *b = list_entry(B, typeof(*b), hole_stack); diff --git a/sys/dev/pci/drm/include/linux/list.h b/sys/dev/pci/drm/include/linux/list.h index 671c3548d8c..746f911fcf0 100644 --- a/sys/dev/pci/drm/include/linux/list.h +++ b/sys/dev/pci/drm/include/linux/list.h @@ -1,4 +1,4 @@ -/* $OpenBSD: list.h,v 1.3 2021/07/07 02:38:36 jsg Exp $ */ +/* $OpenBSD: list.h,v 1.4 2021/10/01 04:36:38 jsg Exp $ */ /* drm_linux_list.h -- linux list functions for the BSDs. * Created: Mon Apr 7 14:30:16 1999 by anholt@FreeBSD.org */ @@ -291,7 +291,7 @@ list_splice_tail_init(struct list_head *list, struct list_head *head) } void list_sort(void *, struct list_head *, - int (*)(void *, struct list_head *, struct list_head *)); + int (*)(void *, const struct list_head *, const struct list_head *)); #define hlist_entry(ptr, type, member) \ ((ptr) ? container_of(ptr, type, member) : NULL) diff --git a/sys/dev/pci/drm/linux_list_sort.c b/sys/dev/pci/drm/linux_list_sort.c index b259d87fab5..c93d73fee4b 100644 --- a/sys/dev/pci/drm/linux_list_sort.c +++ b/sys/dev/pci/drm/linux_list_sort.c @@ -38,17 +38,17 @@ static struct list_head * list_sort_merge(struct list_head *, struct list_head *, - int (*)(void *, struct list_head *, - struct list_head *), void *); + int (*)(void *, const struct list_head *, + const struct list_head *), void *); static void list_sort_merge_into(struct list_head *, struct list_head *, struct list_head *, - int (*)(void *, struct list_head *, - struct list_head *), void *); + int (*)(void *, const struct list_head *, + const struct list_head *), void *); void list_sort(void *arg, struct list_head *list, - int (*compare)(void *, struct list_head *, struct list_head *)) + int (*compare)(void *, const struct list_head *, const struct list_head *)) { /* * Array of sorted sublists, counting in binary: accum[i] @@ -118,8 +118,8 @@ list_sort(void *arg, struct list_head *list, */ static struct list_head * list_sort_merge(struct list_head *a, struct list_head *b, - int (*compare)(void *, struct list_head *, - struct list_head *), void *arg) + int (*compare)(void *, const struct list_head *, + const struct list_head *), void *arg) { struct list_head head, *tail = &head; @@ -149,8 +149,8 @@ list_sort_merge(struct list_head *a, struct list_head *b, static void list_sort_merge_into(struct list_head *list, struct list_head *a, struct list_head *b, - int (*compare)(void *, struct list_head *, - struct list_head *), void *arg) + int (*compare)(void *, const struct list_head *, + const struct list_head *), void *arg) { struct list_head *prev = list; diff --git a/sys/dev/pci/drm/radeon/radeon_cs.c b/sys/dev/pci/drm/radeon/radeon_cs.c index fe9f6f6bcd9..1e29b0cf7b5 100644 --- a/sys/dev/pci/drm/radeon/radeon_cs.c +++ b/sys/dev/pci/drm/radeon/radeon_cs.c @@ -397,8 +397,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) return 0; } -static int cmp_size_smaller_first(void *priv, struct list_head *a, - struct list_head *b) +static int cmp_size_smaller_first(void *priv, const struct list_head *a, + const struct list_head *b) { struct radeon_bo_list *la = list_entry(a, struct radeon_bo_list, tv.head); struct radeon_bo_list *lb = list_entry(b, struct radeon_bo_list, tv.head);