From 679531e1669085115bac5f6fc982d54a4a9608e8 Mon Sep 17 00:00:00 2001
From: Rik Faith <faith@alephnull.com>
Date: Wed, 15 Nov 2000 15:47:51 +0000
Subject: Sync with Linux 2.4.0-test11-pre5 Provide backward compatibility
 tested     against 2.2.18pre21 As usual, since all 2.4.0-test* kernels set
 LINUX_VERSION_CODE to the same     value, if you are running a 2.4.0-test
 kernel, you MUST be running     2.4.0-test11-pre4 or later (although anything
 after 2.4.0-test11-pre1     should work fine -- I tested with pre4/pre5). I
 expect 2.2.x support to     continue to work for all recent kernels, but I
 tested with 2.2.18pre21     -- we use the old intermodule symbol
 communication for 2.2.x kernels,     so they should all continue to work.

---
 linux-core/drmP.h     | 27 +++++----------------------
 linux-core/i810_drv.c |  7 +++----
 linux-core/mga_drv.c  |  7 +++----
 linux-core/r128_drv.c |  7 +++----
 linux-core/sis_drv.c  | 23 +++++++++++------------
 linux-core/tdfx_drv.c |  6 +++---
 6 files changed, 28 insertions(+), 49 deletions(-)

(limited to 'linux-core')

diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 46e08e05..affeae70 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -59,15 +59,6 @@
 #include <asm/io.h>
 #include <asm/mman.h>
 #include <asm/uaccess.h>
-
-#ifndef copy_to_user_ret
-#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
-#endif
-
-#ifndef copy_from_user_ret
-#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
-#endif
-
 #ifdef CONFIG_MTRR
 #include <asm/mtrr.h>
 #endif
@@ -519,19 +510,6 @@ typedef struct drm_agp_head {
 	unsigned long      base;
    	int 		   agp_mtrr;
 } drm_agp_head_t;
-
-typedef struct {
-	void       (*free_memory)(agp_memory *);
-	agp_memory *(*allocate_memory)(size_t, u32);
-	int        (*bind_memory)(agp_memory *, off_t);
-	int        (*unbind_memory)(agp_memory *);
-	void       (*enable)(u32);
-	int        (*acquire)(void);
-	void       (*release)(void);
-	void       (*copy_info)(agp_kern_info *);
-} drm_agp_func_t;
-
-extern drm_agp_func_t drm_agp;
 #endif
 
 typedef struct drm_sigdata {
@@ -833,6 +811,7 @@ extern drm_agp_head_t *drm_agp_init(void);
 extern void           drm_agp_uninit(void);
 extern int            drm_agp_acquire(struct inode *inode, struct file *filp,
 				      unsigned int cmd, unsigned long arg);
+extern void           _drm_agp_release(void);
 extern int            drm_agp_release(struct inode *inode, struct file *filp,
 				      unsigned int cmd, unsigned long arg);
 extern int            drm_agp_enable(struct inode *inode, struct file *filp,
@@ -847,6 +826,10 @@ extern int            drm_agp_unbind(struct inode *inode, struct file *filp,
 				     unsigned int cmd, unsigned long arg);
 extern int            drm_agp_bind(struct inode *inode, struct file *filp,
 				   unsigned int cmd, unsigned long arg);
+extern agp_memory     *drm_agp_allocate_memory(size_t pages, u32 type);
+extern int            drm_agp_free_memory(agp_memory *handle);
+extern int            drm_agp_bind_memory(agp_memory *handle, off_t start);
+extern int            drm_agp_unbind_memory(agp_memory *handle);
 #endif
 #endif
 #endif
diff --git a/linux-core/i810_drv.c b/linux-core/i810_drv.c
index ed880c41..7152eac3 100644
--- a/linux-core/i810_drv.c
+++ b/linux-core/i810_drv.c
@@ -255,8 +255,7 @@ static int i810_takedown(drm_device_t *dev)
 		}
 		dev->agp->memory = NULL;
 
-		if (dev->agp->acquired && drm_agp.release)
-			(*drm_agp.release)();
+		if (dev->agp->acquired) _drm_agp_release();
 
 		dev->agp->acquired = 0;
 		dev->agp->enabled  = 0;
@@ -338,7 +337,7 @@ static int i810_takedown(drm_device_t *dev)
 /* i810_init is called via init_module at module load time, or via
  * linux/init/main.c (this is not currently supported). */
 
-static int i810_init(void)
+static int __init i810_init(void)
 {
 	int		      retcode;
 	drm_device_t	      *dev = &i810_device;
@@ -397,7 +396,7 @@ static int i810_init(void)
 
 /* i810_cleanup is called via cleanup_module at module unload time. */
 
-static void i810_cleanup(void)
+static void __exit i810_cleanup(void)
 {
 	drm_device_t	      *dev = &i810_device;
 
diff --git a/linux-core/mga_drv.c b/linux-core/mga_drv.c
index 4aaac625..883eb75c 100644
--- a/linux-core/mga_drv.c
+++ b/linux-core/mga_drv.c
@@ -255,8 +255,7 @@ static int mga_takedown(drm_device_t *dev)
 		}
 		dev->agp->memory = NULL;
 
-		if (dev->agp->acquired && drm_agp.release)
-			(*drm_agp.release)();
+		if (dev->agp->acquired)	_drm_agp_release();
 
 		dev->agp->acquired = 0;
 		dev->agp->enabled  = 0;
@@ -338,7 +337,7 @@ static int mga_takedown(drm_device_t *dev)
 /* mga_init is called via init_module at module load time, or via
  * linux/init/main.c (this is not currently supported). */
 
-static int mga_init(void)
+static int __init mga_init(void)
 {
 	int		      retcode;
 	drm_device_t	      *dev = &mga_device;
@@ -398,7 +397,7 @@ static int mga_init(void)
 
 /* mga_cleanup is called via cleanup_module at module unload time. */
 
-static void mga_cleanup(void)
+static void __exit mga_cleanup(void)
 {
 	drm_device_t	      *dev = &mga_device;
 
diff --git a/linux-core/r128_drv.c b/linux-core/r128_drv.c
index 7ae49801..969ada93 100644
--- a/linux-core/r128_drv.c
+++ b/linux-core/r128_drv.c
@@ -252,8 +252,7 @@ static int r128_takedown(drm_device_t *dev)
 		}
 		dev->agp->memory = NULL;
 
-		if (dev->agp->acquired && drm_agp.release)
-			(*drm_agp.release)();
+		if (dev->agp->acquired)	_drm_agp_release();
 
 		dev->agp->acquired = 0;
 		dev->agp->enabled  = 0;
@@ -323,7 +322,7 @@ static int r128_takedown(drm_device_t *dev)
 /* r128_init is called via init_module at module load time, or via
  * linux/init/main.c (this is not currently supported). */
 
-static int r128_init(void)
+static int __init r128_init(void)
 {
 	int		      retcode;
 	drm_device_t	      *dev = &r128_device;
@@ -387,7 +386,7 @@ static int r128_init(void)
 
 /* r128_cleanup is called via cleanup_module at module unload time. */
 
-static void r128_cleanup(void)
+static void __exit r128_cleanup(void)
 {
 	drm_device_t	      *dev = &r128_device;
 
diff --git a/linux-core/sis_drv.c b/linux-core/sis_drv.c
index 2f98e322..92ec32dd 100644
--- a/linux-core/sis_drv.c
+++ b/linux-core/sis_drv.c
@@ -250,7 +250,7 @@ static int sis_takedown(drm_device_t *dev)
 			drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
 			temp = temp_next;
 		}
-		if (dev->agp->acquired) (*drm_agp.release)();
+		if (dev->agp->acquired) _drm_agp_release();
 	}
 #endif
 				/* Clear vma list (only built for debugging) */
@@ -394,17 +394,16 @@ int sis_version(struct inode *inode, struct file *filp, unsigned int cmd,
 	drm_version_t version;
 	int	      len;
 
-	copy_from_user_ret(&version,
-			   (drm_version_t *)arg,
-			   sizeof(version),
-			   -EFAULT);
+	if (copy_from_user(&version, (drm_version_t *)arg, sizeof(version)))
+		return -EFAULT;
 
 #define DRM_COPY(name,value)				     \
 	len = strlen(value);				     \
 	if (len > name##_len) len = name##_len;		     \
 	name##_len = strlen(value);			     \
 	if (len && name) {				     \
-		copy_to_user_ret(name, value, len, -EFAULT); \
+		if (copy_to_user(name, value, len))          \
+			return -EFAULT;                      \
 	}
 
 	version.version_major	   = SIS_MAJOR;
@@ -415,10 +414,8 @@ int sis_version(struct inode *inode, struct file *filp, unsigned int cmd,
 	DRM_COPY(version.date, SIS_DATE);
 	DRM_COPY(version.desc, SIS_DESC);
 
-	copy_to_user_ret((drm_version_t *)arg,
-			 &version,
-			 sizeof(version),
-			 -EFAULT);
+	if (copy_to_user((drm_version_t *)arg, &version, sizeof(version)))
+		return -EFAULT;
 	return 0;
 }
 
@@ -533,7 +530,8 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd,
         dev->lck_start = start = get_cycles();
 #endif
 
-        copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+        if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+		return -EFAULT;
 
         if (lock.context == DRM_KERNEL_CONTEXT) {
                 DRM_ERROR("Process %d using kernel context %d\n",
@@ -667,7 +665,8 @@ int sis_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
 	drm_device_t	  *dev	  = priv->dev;
 	drm_lock_t	  lock;
 
-	copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+	if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+		return -EFAULT;
 	
 	if (lock.context == DRM_KERNEL_CONTEXT) {
 		DRM_ERROR("Process %d using kernel context %d\n",
diff --git a/linux-core/tdfx_drv.c b/linux-core/tdfx_drv.c
index 5f2c804a..7d79a013 100644
--- a/linux-core/tdfx_drv.c
+++ b/linux-core/tdfx_drv.c
@@ -235,7 +235,7 @@ static int tdfx_takedown(drm_device_t *dev)
 			drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
 			temp = temp_next;
 		}
-		if (dev->agp->acquired) (*drm_agp.release)();
+		if (dev->agp->acquired) _drm_agp_release();
 	}
 #endif
 				/* Clear vma list (only built for debugging) */
@@ -298,7 +298,7 @@ static int tdfx_takedown(drm_device_t *dev)
 /* tdfx_init is called via init_module at module load time, or via
  * linux/init/main.c (this is not currently supported). */
 
-static int tdfx_init(void)
+static int __init tdfx_init(void)
 {
 	int		      retcode;
 	drm_device_t	      *dev = &tdfx_device;
@@ -346,7 +346,7 @@ static int tdfx_init(void)
 
 /* tdfx_cleanup is called via cleanup_module at module unload time. */
 
-static void tdfx_cleanup(void)
+static void __exit tdfx_cleanup(void)
 {
 	drm_device_t	      *dev = &tdfx_device;
 
-- 
cgit v1.2.3