[MPlayer-matrox] [PATCH] add udev support to mga_vid svn

Tamas, Gergely dice at mfa.kfki.hu
Sat Jul 29 22:53:05 CEST 2006


Hi,

This patch adds udev support to mga_vid svn [revision 243].

Put something like the following into '/etc/udev/rules.d/mga_vid.rules'
file :

KERNEL=="mga_vid", NAME="%k", MODE="0660", GROUP="video"

Works fine here with 2.6.18-rc2 .

Please test it...

Thanks,
Gergely

Index: mga_vid.c
===================================================================
--- mga_vid.c	(revision 243)
+++ mga_vid.c	(working copy)
@@ -57,6 +57,8 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 
+#include <linux/device.h>
+
 #include <linux/pci.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -254,6 +256,9 @@
 #define ICLEAR	    0x1e18
 #define STATUS      0x1e14
 
+struct class *mga_vid_class;
+int mga_vid_major;
+
 /* Global handles for cdev */
 static struct cdev *mga_vid_cdev;
 static dev_t mga_cdev_handle;
@@ -1134,8 +1139,14 @@
 		else
 		{
 			mga_cdev_handle = MKDEV(major,0);
-			if(!register_chrdev_region(mga_cdev_handle, mga_cards_num, "mga_vid"))
-				printk(KERN_INFO "mga_vid: using major: %d (assigned or default!)\n", major);
+			if(!register_chrdev_region(mga_cdev_handle, mga_cards_num, "mga_vid")) {
+				mga_vid_major = major;
+
+				mga_vid_class = class_create(THIS_MODULE, "mga_vid");
+				class_device_create(mga_vid_class, NULL, MKDEV (mga_vid_major, 0), NULL, "mga_vid");
+
+ 				printk(KERN_INFO "mga_vid: using major: %d (assigned or default!)\n", major);
+			}
 		}
 		/* Allocate a cdev for this character device, and fill in some parameters it needs */
 		mga_vid_cdev = cdev_alloc();
@@ -1184,6 +1195,9 @@
 		}
 	}
 
+	class_device_destroy(mga_vid_class, MKDEV(mga_vid_major, 0));
+	class_destroy(mga_vid_class);
+
 	//FIXME turn off BES
 	cdev_del(mga_vid_cdev);
 	unregister_chrdev_region(mga_cdev_handle, mga_cards_num);



More information about the MPlayer-matrox mailing list