{"id":4173,"date":"2022-12-20T17:39:36","date_gmt":"2022-12-20T20:39:36","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mod_inc_use_count-man9\/"},"modified":"2022-12-20T17:39:36","modified_gmt":"2022-12-20T20:39:36","slug":"mod_inc_use_count-man9","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mod_inc_use_count-man9\/","title":{"rendered":"MOD_INC_USE_COUNT (man9)"},"content":{"rendered":"<h1 align=\"center\">MOD_INC_USE_COUNT<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#AVAILABILITY\">AVAILABILITY<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#BUGS\">BUGS<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">MOD_INC_USE_COUNT, MOD_DEC_USE_COUNT \u2212 Support reference counting of modules<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <linux\/module.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#define MOD_INC_USE_COUNT <br \/> #define MOD_DEC_USE_COUNT<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These macros support reference counting of modules during their lifetime. Each time <b>MOD_INC_USE_COUNT<\/b>(9) is invoked, the kernel increases the number of counted references to the module. The <b>MOD_DEC_USE_COUNT<\/b>(9) decreases the reference count.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The reference count is used by the kernel to know when a module is no longer in use by the device or application software. A <b>MOD_INC_USE_COUNT<\/b>(9) is generally placed in the open entry for a driver, and a <b>MOD_DEC_USE_COUNT<\/b>(9) in the release for the driver, to count the number of times the device has been opened, and thus prevent the module being unloaded when in use. The device driver may increment the use count other times, such as when memory is mapped or the module must remain loaded for external events.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the device driver is not compiled as a module (<i>MODULE<\/i> is not defined) then the macro reduces to no behavior.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These macros take no parameters and return no result.<\/p>\n<h2>AVAILABILITY <a name=\"AVAILABILITY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Linux 1.0+<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>\/usr\/include\/linux\/module.h<\/i><\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Stephen Williams <steve@icarus.com><\/p>\n<h2>BUGS <a name=\"BUGS\"><\/a> <\/h2>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  MOD_INC_USE_COUNT, MOD_DEC_USE_COUNT \u2212 Support reference counting of modules <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1222],"tags":[1226,1223,1225,1253],"class_list":["post-4173","post","type-post","status-publish","format-standard","hentry","category-9-rutinas-del-nucleo","tag-1226","tag-kernel","tag-man9","tag-mod_inc_use_count"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4173"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4173\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}