xref: /freebsd/sys/compat/linuxkpi/common/include/linux/device/driver.h (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2021 Bjoern A. Zeeb
5  * Copyright (c) 2024 The FreeBSD Foundation
6  *
7  * Portions of this software were developed by Björn Zeeb
8  * under sponsorship from the FreeBSD Foundation.
9  */
10 
11 #ifndef	LINUXKPI_LINUX_DEVICE_DRIVER_H
12 #define	LINUXKPI_LINUX_DEVICE_DRIVER_H
13 
14 #include <sys/cdefs.h>
15 #include <linux/module.h>
16 
17 #define	module_driver(_drv, _regf, _unregf)					\
18 static inline int								\
19 __CONCAT(__CONCAT(_, _drv), _init)(void)					\
20 {										\
21 	return (_regf(&(_drv)));		 				\
22 }										\
23 										\
24 static inline void								\
25 __CONCAT(__CONCAT(_, _drv), _exit)(void)					\
26 {										\
27 	_unregf(&(_drv));							\
28 }										\
29 										\
30 module_init(__CONCAT(__CONCAT(_, _drv), _init));				\
31 module_exit(__CONCAT(__CONCAT(_, _drv), _exit))
32 
33 #endif	/* LINUXKPI_LINUX_DEVICE_DRIVER_H */
34