diff options
author | Yangtao Li <frank.li@vivo.com> | 2023-04-09 19:43:37 +0300 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2023-04-11 19:09:08 +0300 |
commit | 3664ff82dae1ef9f14f7763d3dd30565e7ef9e14 (patch) | |
tree | b18b6bec1dd93c543024e7943349fb3e239767d7 /include/linux/device-mapper.h | |
parent | 306fbc2e041c227be7c934efe8a49ddb87bd31f1 (diff) | |
download | linux-3664ff82dae1ef9f14f7763d3dd30565e7ef9e14.tar.xz |
dm: add helper macro for simple DM target module init and exit
Eliminate duplicate boilerplate code for simple modules that contain
a single DM target driver without any additional setup code.
Add a new module_dm() macro, which replaces the module_init() and
module_exit() with template functions that call dm_register_target()
and dm_unregister_target() respectively.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Diffstat (limited to 'include/linux/device-mapper.h')
-rw-r--r-- | include/linux/device-mapper.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 8aa6b3ea91fa..f2d9afb8a7e9 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -631,6 +631,26 @@ void dm_destroy_crypto_profile(struct blk_crypto_profile *profile); DMEMIT("target_name=%s,target_version=%u.%u.%u", \ (y)->name, (y)->version[0], (y)->version[1], (y)->version[2]) +/** + * module_dm() - Helper macro for DM targets that don't do anything + * special in their module_init and module_exit. + * Each module may only use this macro once, and calling it replaces + * module_init() and module_exit(). + * + * @name: DM target's name + */ +#define module_dm(name) \ +static int __init dm_##name##_init(void) \ +{ \ + return dm_register_target(&(name##_target)); \ +} \ +module_init(dm_##name##_init) \ +static void __exit dm_##name##_exit(void) \ +{ \ + dm_unregister_target(&(name##_target)); \ +} \ +module_exit(dm_##name##_exit) + /* * Definitions of return values from target end_io function. */ |