141 lines
3.5 KiB
Diff
141 lines
3.5 KiB
Diff
From: Ben Hutchings <ben@decadent.org.uk>
|
|
Subject: [PATCH] drm: Revert "lib: Introduce generic list_sort function"
|
|
|
|
This reverts commit 2c761270d5520dd84ab0b4e47c24d99ff8503c38
|
|
"lib: Introduce generic list_sort function" in drivers/gpu/drm, which
|
|
was included in drm-2.6.32.9-2.6.33.patch. We don't want to include
|
|
that change from 2.6.33. However, we do declare list_sort() as static.
|
|
|
|
--- a/drivers/gpu/drm/drm_modes.c
|
|
+++ b/drivers/gpu/drm/drm_modes.c
|
|
@@ -1,4 +1,9 @@
|
|
/*
|
|
+ * The list_sort function is (presumably) licensed under the GPL (see the
|
|
+ * top level "COPYING" file for details).
|
|
+ *
|
|
+ * The remainder of this file is:
|
|
+ *
|
|
* Copyright © 1997-2003 by The XFree86 Project, Inc.
|
|
* Copyright © 2007 Dave Airlie
|
|
* Copyright © 2007-2008 Intel Corporation
|
|
@@ -31,7 +36,6 @@
|
|
*/
|
|
|
|
#include <linux/list.h>
|
|
-#include <linux/list_sort.h>
|
|
#include "drmP.h"
|
|
#include "drm.h"
|
|
#include "drm_crtc.h"
|
|
@@ -851,7 +855,6 @@ EXPORT_SYMBOL(drm_mode_prune_invalid);
|
|
|
|
/**
|
|
* drm_mode_compare - compare modes for favorability
|
|
- * @priv: unused
|
|
* @lh_a: list_head for first mode
|
|
* @lh_b: list_head for second mode
|
|
*
|
|
@@ -865,7 +868,7 @@ 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(struct list_head *lh_a, 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);
|
|
@@ -882,6 +885,85 @@ static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head
|
|
return diff;
|
|
}
|
|
|
|
+/* FIXME: what we don't have a list sort function? */
|
|
+/* list sort from Mark J Roberts (mjr@znex.org) */
|
|
+static void list_sort(struct list_head *head,
|
|
+ int (*cmp)(struct list_head *a, struct list_head *b))
|
|
+{
|
|
+ struct list_head *p, *q, *e, *list, *tail, *oldhead;
|
|
+ int insize, nmerges, psize, qsize, i;
|
|
+
|
|
+ list = head->next;
|
|
+ list_del(head);
|
|
+ insize = 1;
|
|
+ for (;;) {
|
|
+ p = oldhead = list;
|
|
+ list = tail = NULL;
|
|
+ nmerges = 0;
|
|
+
|
|
+ while (p) {
|
|
+ nmerges++;
|
|
+ q = p;
|
|
+ psize = 0;
|
|
+ for (i = 0; i < insize; i++) {
|
|
+ psize++;
|
|
+ q = q->next == oldhead ? NULL : q->next;
|
|
+ if (!q)
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ qsize = insize;
|
|
+ while (psize > 0 || (qsize > 0 && q)) {
|
|
+ if (!psize) {
|
|
+ e = q;
|
|
+ q = q->next;
|
|
+ qsize--;
|
|
+ if (q == oldhead)
|
|
+ q = NULL;
|
|
+ } else if (!qsize || !q) {
|
|
+ e = p;
|
|
+ p = p->next;
|
|
+ psize--;
|
|
+ if (p == oldhead)
|
|
+ p = NULL;
|
|
+ } else if (cmp(p, q) <= 0) {
|
|
+ e = p;
|
|
+ p = p->next;
|
|
+ psize--;
|
|
+ if (p == oldhead)
|
|
+ p = NULL;
|
|
+ } else {
|
|
+ e = q;
|
|
+ q = q->next;
|
|
+ qsize--;
|
|
+ if (q == oldhead)
|
|
+ q = NULL;
|
|
+ }
|
|
+ if (tail)
|
|
+ tail->next = e;
|
|
+ else
|
|
+ list = e;
|
|
+ e->prev = tail;
|
|
+ tail = e;
|
|
+ }
|
|
+ p = q;
|
|
+ }
|
|
+
|
|
+ tail->next = list;
|
|
+ list->prev = tail;
|
|
+
|
|
+ if (nmerges <= 1)
|
|
+ break;
|
|
+
|
|
+ insize *= 2;
|
|
+ }
|
|
+
|
|
+ head->next = list;
|
|
+ head->prev = list->prev;
|
|
+ list->prev->next = head;
|
|
+ list->prev = head;
|
|
+}
|
|
+
|
|
/**
|
|
* drm_mode_sort - sort mode list
|
|
* @mode_list: list to sort
|
|
@@ -893,7 +975,7 @@ static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head
|
|
*/
|
|
void drm_mode_sort(struct list_head *mode_list)
|
|
{
|
|
- list_sort(NULL, mode_list, drm_mode_compare);
|
|
+ list_sort(mode_list, drm_mode_compare);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_sort);
|
|
|