From b9eab01125bf3cb6f5fbab1811402d16c9fcf4ec Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Wed, 11 Nov 2015 19:13:29 -0800 Subject: mtd: partitions: add module_mtd_part_parser() helper This can help eliminate some boilerplate by generating the module_init() and module_exit() functions, and by automatically assigning the module owner. Signed-off-by: Brian Norris --- drivers/mtd/mtdpart.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/mtdpart.c') diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 46dfbf5629c3..1fa3ca95d9c1 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -703,13 +703,17 @@ static struct mtd_part_parser *get_partition_parser(const char *name) #define put_partition_parser(p) do { module_put((p)->owner); } while (0) -void register_mtd_parser(struct mtd_part_parser *p) +int __register_mtd_parser(struct mtd_part_parser *p, struct module *owner) { + p->owner = owner; + spin_lock(&part_parser_lock); list_add(&p->list, &part_parsers); spin_unlock(&part_parser_lock); + + return 0; } -EXPORT_SYMBOL_GPL(register_mtd_parser); +EXPORT_SYMBOL_GPL(__register_mtd_parser); void deregister_mtd_parser(struct mtd_part_parser *p) { -- cgit v1.2.3-70-g09d2