[MPlayer-dev-eng] [FWD] Re: mga_vid.c ported to 2.6.0-test1 (from: algernon at debian.org)

Mark Szabo mw3 at daisy.chains.ch
Sun Jul 20 17:15:42 CEST 2003


----- Forwarded message from Gergely Nagy <algernon at debian.org> -----

From: Gergely Nagy <algernon at debian.org>
Subject: Re: mga_vid.c ported to 2.6.0-test1
To: mplayer-dev-eng at mplayerhq.hu
Cc: Gergely Nagy <algernon at debian.org>
User-Agent: Wanderlust/2.10.1 (Watching The Wheels) Emacs/21.3 Mule/5.0 (SAKAKI)
Date: Sun, 20 Jul 2003 16:46:51 +0200
X-Fortune: Oh my god, dude!

> Anyway, a patch for drivers/mga_vid.c is included below

Apparently, I overlooked the MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT
stuff. Fixed patch below.

-- 
Gergely Nagy

--- drivers/mga_vid.c.orig	2003-07-20 16:32:50.000000000 +0200
+++ drivers/mga_vid.c	2003-07-20 16:43:06.000000000 +0200
@@ -148,7 +148,8 @@
 }
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,5)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,5)) && \
+    (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
 static long simple_strtol(const char *cp,char **endp,unsigned int base)
 {
         if(*cp=='-')
@@ -287,7 +288,7 @@
 
 static mga_vid_config_t mga_config; 
 
-#ifdef CONFIG_DEVFS_FS
+#if defined(CONFIG_DEVFS_FS) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 static devfs_handle_t dev_handle = NULL;
 #endif
 
@@ -1307,6 +1308,11 @@
 	return 0;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#define PCI_DEV_NAME(d) (d)->name
+#else
+#define PCI_DEV_NAME(d) (d)->dev.name
+#endif
 
 static int mga_vid_find_card(void)
 {
@@ -1338,7 +1344,7 @@
 			break;
 		default:
 			num_found--;
-			printk(KERN_INFO "mga_vid: ignoring matrox device (%d) at %s [%s]\n", dev->device, dev->slot_name, dev->name);
+			printk(KERN_INFO "mga_vid: ignoring matrox device (%d) at %s [%s]\n", dev->device, dev->slot_name, PCI_DEV_NAME(dev));
 			break;
 		}
 		if(num_found == mga_number+1)
@@ -1353,7 +1359,7 @@
 			printk(KERN_ERR "mga_vid: Only %d supported cards found\n", num_found);
 		return FALSE;   
 	}
-	printk(KERN_INFO "mga_vid: Found %s at %s [%s]\n", mga_dev_name, dev->slot_name, dev->name);
+	printk(KERN_INFO "mga_vid: Found %s at %s [%s]\n", mga_dev_name, dev->slot_name, PCI_DEV_NAME(dev));
 
 	pci_dev = dev;
 
@@ -1549,7 +1555,11 @@
 	mga_vid_write_regs(1);
 	mga_vid_in_use = 0;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 	MOD_DEC_USE_COUNT;
+#else
+	module_put (THIS_MODULE);
+#endif
 	return 0;
 }
 
@@ -1573,7 +1583,11 @@
 		return(-EBUSY);
 
 	mga_vid_in_use = 1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 	MOD_INC_USE_COUNT;
+#else
+	try_module_get (THIS_MODULE);
+#endif
 	return(0);
 }
 
@@ -1622,7 +1636,7 @@
 			return -EINVAL;
 		}
 	}
-#ifdef CONFIG_DEVFS_FS
+
 /*
 from 2.4.17/2.4.18 linux/devfs_fs_kernel.h:
 extern devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
@@ -1630,6 +1644,7 @@
 				      unsigned int major, unsigned int minor,
 				      umode_t mode, void *ops, void *info);
 */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION (2,6,0)) && defined (CONFIG_DEVFS_FS)
 	if ((dev_handle = devfs_register(
 					NULL,
 					"mga_vid", DEVFS_FL_NONE,
@@ -1640,18 +1655,34 @@
 		printk(KERN_ERR "mga_vid: unable to get major: %d (devfs) => fallback to non-devfs mode\n", major);
 //		return -EIO;
 	}
-#endif		
+#endif
+
 	if(register_chrdev(major, "mga_vid", &mga_vid_fops))
 	{
 		printk(KERN_ERR "mga_vid: unable to get major: %d\n", major);
 		return -EIO;
 	}
 
+#if defined(CONFIG_DEVFS_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION (2,6,0))
+	if (devfs_mk_cdev (MKDEV (major, 0), 
+			   S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+			   "mga_vid"))
+	{
+		printk(KERN_ERR "mga_vid: unable to register major: %d (devfs)\n", major);
+//		return -EIO;
+	}
+	
+#endif
+
 	if (!mga_vid_find_card())
 	{
 		printk(KERN_ERR "mga_vid: no supported devices found\n");
 #ifdef CONFIG_DEVFS_FS
+#if (LINUX_VERSION_CODE < KERNEL_VERSION (2,6,0))
 		if(dev_handle) devfs_unregister(dev_handle);
+#else
+		devfs_remove ("mga_vid");
+#endif
 #endif
 		unregister_chrdev(major, "mga_vid");
 		return -EINVAL;
@@ -1683,7 +1714,11 @@
 	//FIXME turn off BES
 	printk(KERN_INFO "mga_vid: Cleaning up module\n");
 #ifdef CONFIG_DEVFS_FS
+#if (LINUX_VERSION_CODE) < KERNEL_VERSION (2,6,0)
 	if(dev_handle) devfs_unregister(dev_handle);
+#else
+	devfs_remove ("mga_vid");
+#endif
 #endif
 	unregister_chrdev(major, "mga_vid");
 }

----- End forwarded message -----

-- 
Mark Szabo
mw3 at bsd.hu



More information about the MPlayer-dev-eng mailing list