{"id":4161,"date":"2022-12-20T17:39:35","date_gmt":"2022-12-20T20:39:35","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/init_module-man9\/"},"modified":"2022-12-20T17:39:35","modified_gmt":"2022-12-20T20:39:35","slug":"init_module-man9","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/init_module-man9\/","title":{"rendered":"init_module (man9)"},"content":{"rendered":"<h1 align=\"center\">init_module<\/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\">init_module, cleanup_module \u2212 module load and unload functions<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <linux\/module.h> #include <linux\/modversions.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int init_module(void); <br \/> void cleanup_module(void);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These functions are not part of the kernel but entry points into loadable modules. These are the only symbols that must be externally defined in order to load a module into a running kernel.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When a module is loaded into a running kernel, the <b>init_module<\/b>(9) function within that object file is called to set up the module. The implementation of that function initializes local features and uses functions such as <b>register_chrdev<\/b>(9) to attach itself to the kernel. It then returns zero(0) if it succeeds. If there is a problem or the module decides that it cannot be loaded, it returns instead an error code (i.e. <i>-ENODEV<\/i>) and the kernel releases the module again.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Once loaded, the <b>cleanup_module<\/b>(9) function of a module is used by the kernel to remove the module again. The module detaches itself from the kernel and returns.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>init_module<\/b>(9) function returns 0 on success, or an error code <0 if the module cannot be initialized.<\/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\"><b>MOD_INC_USE_COUNT<\/b>(9), <b>insmod<\/b>(1)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Also list some source files for the kernel that implement the functions of the page.<\/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<p style=\"margin-left:11%; margin-top: 1em\">It is entirely up to the driver to be sure it is detached from the kernel when unloaded. If a module makes an error in this regard, bad things may happen.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  init_module, cleanup_module \u2212 module load and unload functions <\/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,1241,1223,1225],"class_list":["post-4161","post","type-post","status-publish","format-standard","hentry","category-9-rutinas-del-nucleo","tag-1226","tag-init_module","tag-kernel","tag-man9"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4161","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=4161"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4161\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}