Skip to contentSkip to conversation

Fix capi reload by unregistering the correct major

PATCH In review Stefan Schweizer 2 participants 4 messages Apr 29, 2006 – May 12, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix capi reload by unregistering the correct major

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I am having the bug
FATAL: Error inserting capi ([..]/capi.ko): Device or resource busy when I try to reload capi after loading it.
in dmesg: capi20: unable to get major 68

I attached a patch to fix the issue which is caused by setting the major to zero when registering the chrdev succeeded. Please apply
- - Stefan

errors in the dmesg:

CAPI Subsystem Rev 1.1.2.8
capifs: Rev 1.1.2.3
capi20: Rev 1.1.2.7: started up with major 0 (middleware+capifs) <-- here you see that it was set to 0.
(after unload and retry)
capi: Rev 1.1.2.7: unloaded
CAPI Subsystem Rev 1.1.2.8
capi20: unable to get major 68
<-- the chrdev has not been unlinked
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEU6GBNJowsmZ/PzARArMZAJ9tfOoFGJ5wNd86DA15JiaZJFLsAQCfaYr7 9XF6cTgYU7Y9hzvGLgXkJqU=
=qvpL
-----END PGP SIGNATURE-----

isdn/capi/capi.c renamed from isdn/capi/capi.c.orig +0 -1
@@ -1499,7 +1499,6 @@
 		printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
 		return major_ret;
 	}
-	capi_major = major_ret;
 	capi_class = class_create(THIS_MODULE, "capi");
 	if (IS_ERR(capi_class)) {
 		unregister_chrdev(capi_major, "capi20");
#1 lore raw
Quoted 5 lines · Stefan Schweizer

I am having the bug
FATAL: Error inserting capi ([..]/capi.ko): Device or resource busy when I try to reload capi after loading it.
in dmesg: capi20: unable to get major 68

This is odd.

Quoted 22 lines

I attached a patch to fix the issue which is caused by setting the major to zero when registering the chrdev succeeded. Please apply
- - Stefan

errors in the dmesg:

CAPI Subsystem Rev 1.1.2.8
capifs: Rev 1.1.2.3
capi20: Rev 1.1.2.7: started up with major 0 (middleware+capifs) <-- here you see that it was set to 0.
(after unload and retry)
capi: Rev 1.1.2.7: unloaded
CAPI Subsystem Rev 1.1.2.8
capi20: unable to get major 68
<-- the chrdev has not been unlinked

isdn/capi/capi.c line 1504

Quoted 7 lines
isdn/capi/capi.c renamed from isdn/capi/capi.c.orig +0 -1
@@ -1499,7 +1499,6 @@
 		printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
 		return major_ret;
 	}
-	capi_major = major_ret;
 	capi_class = class_create(THIS_MODULE, "capi");
 	if (IS_ERR(capi_class)) {
 		unregister_chrdev(capi_major, "capi20");

What does "unload and retry" mean?

An `rmmod capi;modprobe capi' will reset the major to 68, so you must mean something else. What?

#2 lore raw
Quoted 17 lines · Andrew Morton

isdn/capi/capi.c 2006-04-29 18:27:22.000000000 +0200 line 1504

Quoted 13 lines · Stefan Schweizer
isdn/capi/capi.c 2006-04-29 18:27:22.000000000 +0200 renamed from isdn/capi/capi.c.orig 2006-04-29 18:40:25.000000000 +0200 +0 -1
@@ -1499,7 +1499,6 @@
 printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
 return major_ret;
 }
-    capi_major = major_ret;
 capi_class = class_create(THIS_MODULE, "capi");
 if (IS_ERR(capi_class)) {
 unregister_chrdev(capi_major, "capi20");

What does "unload and retry" mean?

Quoted 2 lines

An `rmmod capi;modprobe capi' will reset the major to 68, so you must mean something else. What?

I mean exactly rmmod capi; modprobe capi. The problem is, that on unload time, the capi_major has been set to major_ret, which is 0 if a major number is given. Of course it does not unregister 68 then. Consequently when trying to load it a second time after unloading it fails, because it has not freed the major 68.

Regards,
Stefan

#3 lore raw

Hi,

after seeing your problems with my patch on -mm-commits, I actually think this one might be better. It allows dynamic majors and does not break anything :)
Please change my patch
- Stefan

isdn/capi/capi.c 2006-05-12 22:16:22.000000000 +0200 renamed from isdn/capi/capi.c 2006-05-13 00:12:46.000000000 +0200 +0 -0
@@ -1499,7 +1499,9 @@
                printk(KERN_ERR "capi20: unable to get major %d\n",
capi_major);
                return major_ret;
        }

- capi_major = major_ret;
+ if (major_ret != 0) {
+ capi_major = major_ret;
+ }

        capi_class = class_create(THIS_MODULE, "capi");
        if (IS_ERR(capi_class)) {
                unregister_chrdev(capi_major, "capi20");