X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=Documentation%2FDocBook%2Fkernel-hacking.tmpl;h=0424c92f5db184e697ecfd8f943a2e3c2068f189;hb=5237fac468d9ad78bc9c09d26426b3425b876540;hp=9cf7cd0cdb57e62ea93af11df60fc931dedecd6f;hpb=86090fcac5e27b630656fe3d963a6b80e26dac44;p=linux-2.6.git diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl index 9cf7cd0cd..0424c92f5 100644 --- a/Documentation/DocBook/kernel-hacking.tmpl +++ b/Documentation/DocBook/kernel-hacking.tmpl @@ -779,62 +779,7 @@ printk(KERN_INFO "my ip: %d.%d.%d.%d\n", NIPQUAD(ipaddress)); - - <function>MOD_INC_USE_COUNT</function>/<function>MOD_DEC_USE_COUNT</function> - <filename class="headerfile">include/linux/module.h</filename> - - - These manipulate the module usage count, to protect against - removal (a module also can't be removed if another module uses - one of its exported symbols: see below). Every reference to - the module from user context should be reflected by this - counter (e.g. for every data structure or socket) before the - function sleeps. To quote Tim Waugh: - - - -/* THIS IS BAD */ -foo_open (...) -{ - stuff.. - if (fail) - return -EBUSY; - sleep.. (might get unloaded here) - stuff.. - MOD_INC_USE_COUNT; - return 0; -} - -/* THIS IS GOOD / -foo_open (...) -{ - MOD_INC_USE_COUNT; - stuff.. - if (fail) { - MOD_DEC_USE_COUNT; - return -EBUSY; - } - sleep.. (safe now) - stuff.. - return 0; -} - - - - You can often avoid having to deal with these problems by using the - owner field of the - file_operations structure. Set this field - as the macro THIS_MODULE. - - - - For more complicated module unload locking requirements, you can set the - can_unload function pointer to your own routine, - which should return 0 if the module is - unloadable, or -EBUSY otherwise. - - - +