Skip to content

Commit 6cfeb41

Browse files
Dejin Zhengmiquelraynal
authored andcommitted
mtd: Add helper macro for register_mtd_blktrans boilerplate
This patch introduces the module_mtd_blktrans macro which is a convenience macro for mtd blktrans modules similar to module_platform_driver. It is intended to be used by drivers which init/exit section does nothing but register/unregister the mtd blktrans driver. By using this macro it is possible to eliminate a few lines of boilerplate code per mtd blktrans driver. Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-2-zhengdejin5@gmail.com
1 parent 6833139 commit 6cfeb41

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎include/linux/mtd/blktrans.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,16 @@ extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
7777
extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
7878
extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev);
7979

80+
/**
81+
* module_mtd_blktrans() - Helper macro for registering a mtd blktrans driver
82+
* @__mtd_blktrans: mtd_blktrans_ops struct
83+
*
84+
* Helper macro for mtd blktrans drivers which do not do anything special in
85+
* module init/exit. This eliminates a lot of boilerplate. Each module may only
86+
* use this macro once, and calling it replaces module_init() and module_exit()
87+
*/
88+
#define module_mtd_blktrans(__mtd_blktrans) \
89+
module_driver(__mtd_blktrans, register_mtd_blktrans, \
90+
deregister_mtd_blktrans)
8091

8192
#endif /* __MTD_TRANS_H__ */

0 commit comments

Comments
 (0)