From f3ae6786f89a4f63dbba93c5519d3792a1744dd7 Mon Sep 17 00:00:00 2001 From: Rik Faith Date: Fri, 4 Aug 2000 10:04:55 +0000 Subject: Sync with Linux 2.4.0-test6-pre2 --- linux/mga_drv.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'linux/mga_drv.c') 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 -#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; } -- cgit v1.2.3