`try_module_get()`/`module_put()` `include/linux/module.h`
Prev | Chapter 6. Common Routines | Next

## `try_module_get()`/`module_put()` `include/linux/module.h`

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). Before calling into module code, you should call `try_module_get()` on that module: if it fails, then the module is being removed and you should act as if it wasn't there. Otherwise, you can safely enter the module, and call `module_put()` when you're finished.

Most registerable structures have an `owner` field, such as in the file_operations structure. Set this field to the macro THIS_MODULE.

Prev | Up | Next
`module_exit()` `include/linux/init.h` | Home | Chapter 7. Wait Queues `include/linux/wait.h`