summaryrefslogtreecommitdiff
path: root/linux/mga_drv.c
diff options
context:
space:
mode:
authorRik Faith <faith@alephnull.com>2000-08-04 10:04:55 +0000
committerRik Faith <faith@alephnull.com>2000-08-04 10:04:55 +0000
commitf3ae6786f89a4f63dbba93c5519d3792a1744dd7 (patch)
tree0d9ef964855fc32189fd5553373bb9dcf904ed12 /linux/mga_drv.c
parentbcad11818296fa58a356175bc7e13060579012d0 (diff)
Sync with Linux 2.4.0-test6-pre2
Diffstat (limited to 'linux/mga_drv.c')
-rw-r--r--linux/mga_drv.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/linux/mga_drv.c b/linux/mga_drv.c
index 30c8880f..7aae6f3e 100644
--- a/linux/mga_drv.c
+++ b/linux/mga_drv.c
@@ -31,13 +31,8 @@
*/
#include <linux/config.h>
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "drmP.h"
#include "mga_drv.h"
-EXPORT_SYMBOL(mga_init);
-EXPORT_SYMBOL(mga_cleanup);
#define MGA_NAME "mga"
#define MGA_DESC "Matrox g200/g400"
@@ -131,9 +126,6 @@ MODULE_AUTHOR("VA Linux Systems, Inc.");
MODULE_DESCRIPTION("Matrox g200/g400");
MODULE_PARM(mga, "s");
-module_init(mga_init);
-module_exit(mga_cleanup);
-
#ifndef MODULE
/* mga_options is called by the kernel to parse command-line options passed
* via the boot-loader (e.g., LILO). It calls the insmod option routine,
@@ -345,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). */
-int mga_init(void)
+static int mga_init(void)
{
int retcode;
drm_device_t *dev = &mga_device;
@@ -410,7 +402,7 @@ int mga_init(void)
/* mga_cleanup is called via cleanup_module at module unload time. */
-void mga_cleanup(void)
+static void mga_cleanup(void)
{
drm_device_t *dev = &mga_device;
@@ -442,6 +434,10 @@ void mga_cleanup(void)
}
}
+module_init(mga_init);
+module_exit(mga_cleanup);
+
+
int mga_version(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@@ -483,7 +479,9 @@ int mga_open(struct inode *inode, struct file *filp)
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
- MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_open);
spin_lock(&dev->count_lock);
if (!dev->open_count++) {
@@ -498,9 +496,11 @@ int mga_open(struct inode *inode, struct file *filp)
int mga_release(struct inode *inode, struct file *filp)
{
drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ drm_device_t *dev;
int retcode = 0;
+ lock_kernel();
+ dev = priv->dev;
DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n",
current->pid, dev->device, dev->open_count);
@@ -562,7 +562,9 @@ int mga_release(struct inode *inode, struct file *filp)
up(&dev->struct_sem);
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
- MOD_DEC_USE_COUNT;
+#if LINUX_VERSION_CODE < 0x020333
+ MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
+#endif
atomic_inc(&dev->total_close);
spin_lock(&dev->count_lock);
if (!--dev->open_count) {
@@ -571,12 +573,15 @@ int mga_release(struct inode *inode, struct file *filp)
atomic_read(&dev->ioctl_count),
dev->blocked);
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return -EBUSY;
}
spin_unlock(&dev->count_lock);
+ unlock_kernel();
return mga_takedown(dev);
}
- spin_unlock(&dev->count_lock);
+ spin_unlock(&dev->count_lock);
+ unlock_kernel();
return retcode;
}