Hello all,
Seems like fusiondev major may conflict with drivers which use
register_chardev(0,...) (i.e. dynamically allocated major). So, maybe it
is a good idea to mke fusiondev majot dynamically allocated too ? Please
look at code in patch attached.
Maxim
Index: linux-2.6.10/drivers/char/fusion/fusiondev.c
===================================================================
--- linux-2.6.10.orig/drivers/char/fusion/fusiondev.c
+++ linux-2.6.10/drivers/char/fusion/fusiondev.c
@@ -45,8 +45,10 @@
#define DEBUG(x...) do {} while (0)
#endif
-#ifndef FUSION_MAJOR
-#define FUSION_MAJOR 252
+#ifndef FUSION_MAJOR
+static unsigned int fusion_major = 0;
+#else
+static unsigned int fusion_major = FUSION_MAJOR;
#endif
MODULE_LICENSE("GPL");
@@ -837,16 +839,23 @@ static int __init
register_devices(void)
{
int i;
+ int ret;
- if (register_chrdev (FUSION_MAJOR, "fusion", &fusion_fops)) {
- printk (KERN_ERR "fusion: unable to get major %d\n", FUSION_MAJOR);
- return -EIO;
+ ret = register_chrdev (fusion_major, "fusion", &fusion_fops);
+ if ((fusion_major == 0) && (ret > 0))
+ fusion_major = ret;
+ else if ((fusion_major == 0) && (ret < 0)){
+ printk (KERN_ERR "fusion: unable to register character device\n");
+ return -EIO;
+ } else if ((fusion_major != 0) && (ret != 0)){
+ printk (KERN_ERR "fusion: unable to get major %d\n", fusion_major);
+ return -EIO;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2)
fusion_class = class_simple_create (THIS_MODULE, "fusion");
if (IS_ERR(fusion_class)) {
- unregister_chrdev (FUSION_MAJOR, "fusion");
+ unregister_chrdev (fusion_major, "fusion");
return PTR_ERR(fusion_class);
}
#endif
@@ -856,11 +865,11 @@ register_devices(void)
for (i=0; i<NUM_MINORS; i++) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2)
class_simple_device_add (fusion_class,
- MKDEV(FUSION_MAJOR, i),
+ MKDEV(fusion_major, i),
NULL, "fusion%d", i);
#endif
- devfs_mk_cdev (MKDEV(FUSION_MAJOR, i),
+ devfs_mk_cdev (MKDEV(fusion_major, i),
S_IFCHR | S_IRUSR | S_IWUSR,
"fusion/%d", i);
}
@@ -874,8 +883,8 @@ register_devices(void)
int i;
char buf[16];
- if (devfs_register_chrdev (FUSION_MAJOR, "fusion", &fusion_fops)) {
- printk (KERN_ERR "fusion: unable to get major %d\n", FUSION_MAJOR);
+ if (devfs_register_chrdev (fusion_major, "fusion", &fusion_fops)) {
+ printk (KERN_ERR "fusion: unable to get major %d\n", fusion_major);
return -EIO;
}
@@ -883,7 +892,7 @@ register_devices(void)
snprintf (buf, 16, "fusion/%d", i);
devfs_handles[i] = devfs_register (NULL, buf, DEVFS_FL_DEFAULT,
- FUSION_MAJOR, i,
+ fusion_major, i,
S_IFCHR | S_IRUSR | S_IWUSR,
&fusion_fops, NULL);
}
@@ -914,11 +923,11 @@ deregister_devices(void)
{
int i;
- unregister_chrdev (FUSION_MAJOR, "fusion");
+ unregister_chrdev (fusion_major, "fusion");
for (i=0; i<NUM_MINORS; i++) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2)
- class_simple_device_remove (MKDEV(FUSION_MAJOR, i));
+ class_simple_device_remove (MKDEV(fusion_major, i));
#endif
devfs_remove ("fusion/%d", i);
@@ -936,7 +945,7 @@ deregister_devices(void)
{
int i;
- devfs_unregister_chrdev (FUSION_MAJOR, "fusion");
+ devfs_unregister_chrdev (fusion_major, "fusion");
for (i=0; i<NUM_MINORS; i++)
devfs_unregister (devfs_handles[i]);
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev