genetlink: replace custom CONCATENATE() implementation

Replace custom implementation of the macros from args.h.

Link: https://lkml.kernel.org/r/20230718211147.18647-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Daniel Latypov <dlatypov@google.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Gow <davidgow@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Andy Shevchenko
2023-07-19 00:11:47 +03:00
committed by Andrew Morton
parent 90e3e18548
commit 2e106e5643
2 changed files with 17 additions and 18 deletions

View File

@@ -2,6 +2,7 @@
#ifndef GENL_MAGIC_FUNC_H #ifndef GENL_MAGIC_FUNC_H
#define GENL_MAGIC_FUNC_H #define GENL_MAGIC_FUNC_H
#include <linux/args.h>
#include <linux/build_bug.h> #include <linux/build_bug.h>
#include <linux/genl_magic_struct.h> #include <linux/genl_magic_struct.h>
@@ -23,7 +24,7 @@
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \ #define GENL_struct(tag_name, tag_number, s_name, s_fields) \
[tag_name] = { .type = NLA_NESTED }, [tag_name] = { .type = NLA_NESTED },
static struct nla_policy CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy)[] = { static struct nla_policy CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy)[] = {
#include GENL_MAGIC_INCLUDE_FILE #include GENL_MAGIC_INCLUDE_FILE
}; };
@@ -209,7 +210,7 @@ static int s_name ## _from_attrs_for_change(struct s_name *s, \
* Magic: define op number to op name mapping {{{1 * Magic: define op number to op name mapping {{{1
* {{{2 * {{{2
*/ */
static const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd) static const char *CONCATENATE(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
{ {
switch (cmd) { switch (cmd) {
#undef GENL_op #undef GENL_op
@@ -235,7 +236,7 @@ static const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
.cmd = op_name, \ .cmd = op_name, \
}, },
#define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops) #define ZZZ_genl_ops CONCATENATE(GENL_MAGIC_FAMILY, _genl_ops)
static struct genl_ops ZZZ_genl_ops[] __read_mostly = { static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
#include GENL_MAGIC_INCLUDE_FILE #include GENL_MAGIC_INCLUDE_FILE
}; };
@@ -248,32 +249,32 @@ static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
* and provide register/unregister functions. * and provide register/unregister functions.
* {{{2 * {{{2
*/ */
#define ZZZ_genl_family CONCAT_(GENL_MAGIC_FAMILY, _genl_family) #define ZZZ_genl_family CONCATENATE(GENL_MAGIC_FAMILY, _genl_family)
static struct genl_family ZZZ_genl_family; static struct genl_family ZZZ_genl_family;
/* /*
* Magic: define multicast groups * Magic: define multicast groups
* Magic: define multicast group registration helper * Magic: define multicast group registration helper
*/ */
#define ZZZ_genl_mcgrps CONCAT_(GENL_MAGIC_FAMILY, _genl_mcgrps) #define ZZZ_genl_mcgrps CONCATENATE(GENL_MAGIC_FAMILY, _genl_mcgrps)
static const struct genl_multicast_group ZZZ_genl_mcgrps[] = { static const struct genl_multicast_group ZZZ_genl_mcgrps[] = {
#undef GENL_mc_group #undef GENL_mc_group
#define GENL_mc_group(group) { .name = #group, }, #define GENL_mc_group(group) { .name = #group, },
#include GENL_MAGIC_INCLUDE_FILE #include GENL_MAGIC_INCLUDE_FILE
}; };
enum CONCAT_(GENL_MAGIC_FAMILY, group_ids) { enum CONCATENATE(GENL_MAGIC_FAMILY, group_ids) {
#undef GENL_mc_group #undef GENL_mc_group
#define GENL_mc_group(group) CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group), #define GENL_mc_group(group) CONCATENATE(GENL_MAGIC_FAMILY, _group_ ## group),
#include GENL_MAGIC_INCLUDE_FILE #include GENL_MAGIC_INCLUDE_FILE
}; };
#undef GENL_mc_group #undef GENL_mc_group
#define GENL_mc_group(group) \ #define GENL_mc_group(group) \
static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ static int CONCATENATE(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \
struct sk_buff *skb, gfp_t flags) \ struct sk_buff *skb, gfp_t flags) \
{ \ { \
unsigned int group_id = \ unsigned int group_id = \
CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group); \ CONCATENATE(GENL_MAGIC_FAMILY, _group_ ## group); \
return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \ return genlmsg_multicast(&ZZZ_genl_family, skb, 0, \
group_id, flags); \ group_id, flags); \
} }
@@ -289,8 +290,8 @@ static struct genl_family ZZZ_genl_family __ro_after_init = {
#ifdef GENL_MAGIC_FAMILY_HDRSZ #ifdef GENL_MAGIC_FAMILY_HDRSZ
.hdrsize = NLA_ALIGN(GENL_MAGIC_FAMILY_HDRSZ), .hdrsize = NLA_ALIGN(GENL_MAGIC_FAMILY_HDRSZ),
#endif #endif
.maxattr = ARRAY_SIZE(CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy))-1, .maxattr = ARRAY_SIZE(CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy))-1,
.policy = CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy), .policy = CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy),
.ops = ZZZ_genl_ops, .ops = ZZZ_genl_ops,
.n_ops = ARRAY_SIZE(ZZZ_genl_ops), .n_ops = ARRAY_SIZE(ZZZ_genl_ops),
.mcgrps = ZZZ_genl_mcgrps, .mcgrps = ZZZ_genl_mcgrps,
@@ -299,12 +300,12 @@ static struct genl_family ZZZ_genl_family __ro_after_init = {
.module = THIS_MODULE, .module = THIS_MODULE,
}; };
int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void) int CONCATENATE(GENL_MAGIC_FAMILY, _genl_register)(void)
{ {
return genl_register_family(&ZZZ_genl_family); return genl_register_family(&ZZZ_genl_family);
} }
void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void) void CONCATENATE(GENL_MAGIC_FAMILY, _genl_unregister)(void)
{ {
genl_unregister_family(&ZZZ_genl_family); genl_unregister_family(&ZZZ_genl_family);
} }

View File

@@ -14,14 +14,12 @@
# error "you need to define GENL_MAGIC_INCLUDE_FILE before inclusion" # error "you need to define GENL_MAGIC_INCLUDE_FILE before inclusion"
#endif #endif
#include <linux/args.h>
#include <linux/genetlink.h> #include <linux/genetlink.h>
#include <linux/types.h> #include <linux/types.h>
#define CONCAT__(a,b) a ## b extern int CONCATENATE(GENL_MAGIC_FAMILY, _genl_register)(void);
#define CONCAT_(a,b) CONCAT__(a,b) extern void CONCATENATE(GENL_MAGIC_FAMILY, _genl_unregister)(void);
extern int CONCAT_(GENL_MAGIC_FAMILY, _genl_register)(void);
extern void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void);
/* /*
* Extension of genl attribute validation policies {{{2 * Extension of genl attribute validation policies {{{2