diff options
Diffstat (limited to 'include/linux/genl_magic_func.h')
-rw-r--r-- | include/linux/genl_magic_func.h | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h index 5b9b8ae6748b..c0894dd8827b 100644 --- a/include/linux/genl_magic_func.h +++ b/include/linux/genl_magic_func.h | |||
@@ -273,49 +273,40 @@ static struct genl_family ZZZ_genl_family __read_mostly = { | |||
273 | * Magic: define multicast groups | 273 | * Magic: define multicast groups |
274 | * Magic: define multicast group registration helper | 274 | * Magic: define multicast group registration helper |
275 | */ | 275 | */ |
276 | #define ZZZ_genl_mcgrps CONCAT_(GENL_MAGIC_FAMILY, _genl_mcgrps) | ||
277 | static const struct genl_multicast_group ZZZ_genl_mcgrps[] = { | ||
278 | #undef GENL_mc_group | ||
279 | #define GENL_mc_group(group) { .name = #group, }, | ||
280 | #include GENL_MAGIC_INCLUDE_FILE | ||
281 | }; | ||
282 | |||
283 | enum CONCAT_(GENL_MAGIC_FAMILY, group_ids) { | ||
284 | #undef GENL_mc_group | ||
285 | #define GENL_mc_group(group) CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group), | ||
286 | #include GENL_MAGIC_INCLUDE_FILE | ||
287 | }; | ||
288 | |||
276 | #undef GENL_mc_group | 289 | #undef GENL_mc_group |
277 | #define GENL_mc_group(group) \ | 290 | #define GENL_mc_group(group) \ |
278 | static struct genl_multicast_group \ | ||
279 | CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group) __read_mostly = { \ | ||
280 | .name = #group, \ | ||
281 | }; \ | ||
282 | static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ | 291 | static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ |
283 | struct sk_buff *skb, gfp_t flags) \ | 292 | struct sk_buff *skb, gfp_t flags) \ |
284 | { \ | 293 | { \ |
285 | unsigned int group_id = \ | 294 | unsigned int group_id = \ |
286 | CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group).id; \ | 295 | CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group); \ |
287 | if (!group_id) \ | ||
288 | return -EINVAL; \ | ||
289 | return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \ | 296 | return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \ |
290 | group_id, flags); \ | 297 | group_id, flags); \ |
291 | } | 298 | } |
292 | 299 | ||
293 | #include GENL_MAGIC_INCLUDE_FILE | 300 | #include GENL_MAGIC_INCLUDE_FILE |
294 | 301 | ||
295 | int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void) | ||
296 | { | ||
297 | int err = genl_register_family_with_ops(&ZZZ_genl_family, ZZZ_genl_ops); | ||
298 | if (err) | ||
299 | return err; | ||
300 | #undef GENL_mc_group | ||
301 | #define GENL_mc_group(group) \ | ||
302 | err = genl_register_mc_group(&ZZZ_genl_family, \ | ||
303 | &CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group)); \ | ||
304 | if (err) \ | ||
305 | goto fail; \ | ||
306 | else \ | ||
307 | pr_info("%s: mcg %s: %u\n", #group, \ | ||
308 | __stringify(GENL_MAGIC_FAMILY), \ | ||
309 | CONCAT_(GENL_MAGIC_FAMILY, _mcg_ ## group).id); | ||
310 | |||
311 | #include GENL_MAGIC_INCLUDE_FILE | ||
312 | |||
313 | #undef GENL_mc_group | 302 | #undef GENL_mc_group |
314 | #define GENL_mc_group(group) | 303 | #define GENL_mc_group(group) |
315 | return 0; | 304 | |
316 | fail: | 305 | int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void) |
317 | genl_unregister_family(&ZZZ_genl_family); | 306 | { |
318 | return err; | 307 | return genl_register_family_with_ops_groups(&ZZZ_genl_family, \ |
308 | ZZZ_genl_ops, \ | ||
309 | ZZZ_genl_mcgrps); | ||
319 | } | 310 | } |
320 | 311 | ||
321 | void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void) | 312 | void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void) |