Commit c2ef76af authored by Rusty Russell's avatar Rusty Russell Committed by David S. Miller

[PATCH] module_name macro

Fixes crypto so it compiles with !CONFIG_MODULES, and cleans up two
other cases which did #ifdef CONFIG_MODULES.
parent 6ad349cd
...@@ -263,8 +263,7 @@ static int c_show(struct seq_file *m, void *p) ...@@ -263,8 +263,7 @@ static int c_show(struct seq_file *m, void *p)
struct crypto_alg *alg = (struct crypto_alg *)p; struct crypto_alg *alg = (struct crypto_alg *)p;
seq_printf(m, "name : %s\n", alg->cra_name); seq_printf(m, "name : %s\n", alg->cra_name);
seq_printf(m, "module : %s\n", alg->cra_module ? seq_printf(m, "module : %s\n", module_name(alg->cra_module));
alg->cra_module->name : "[static]");
seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
......
...@@ -242,6 +242,13 @@ static inline void module_put(struct module *module) ...@@ -242,6 +242,13 @@ static inline void module_put(struct module *module)
#endif /* CONFIG_MODULE_UNLOAD */ #endif /* CONFIG_MODULE_UNLOAD */
/* This is a #define so the string doesn't get put in every .o file */
#define module_name(mod) \
({ \
struct module *__mod = (mod); \
__mod ? __mod->name : "kernel"; \
})
#define __unsafe(mod) \ #define __unsafe(mod) \
do { \ do { \
if (mod && !(mod)->unsafe) { \ if (mod && !(mod)->unsafe) { \
...@@ -265,6 +272,8 @@ do { \ ...@@ -265,6 +272,8 @@ do { \
#define try_module_get(module) 1 #define try_module_get(module) 1
#define module_put(module) do { } while(0) #define module_put(module) do { } while(0)
#define module_name(mod) "kernel"
#define __unsafe(mod) #define __unsafe(mod)
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
......
...@@ -210,13 +210,8 @@ get_exec_domain_list(char *page) ...@@ -210,13 +210,8 @@ get_exec_domain_list(char *page)
read_lock(&exec_domains_lock); read_lock(&exec_domains_lock);
for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next) for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next)
len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n", len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n",
ep->pers_low, ep->pers_high, ep->name, ep->pers_low, ep->pers_high, ep->name,
#ifdef CONFIG_MODULES module_name(ep->module));
ep->module ? ep->module->name : "kernel"
#else
"kernel"
#endif
);
read_unlock(&exec_domains_lock); read_unlock(&exec_domains_lock);
return (len); return (len);
} }
......
...@@ -361,8 +361,6 @@ helper_cmp(const struct ip_nat_helper *helper, ...@@ -361,8 +361,6 @@ helper_cmp(const struct ip_nat_helper *helper,
return ip_ct_tuple_mask_cmp(tuple, &helper->tuple, &helper->mask); return ip_ct_tuple_mask_cmp(tuple, &helper->tuple, &helper->mask);
} }
#define MODULE_MAX_NAMELEN 32
int ip_nat_helper_register(struct ip_nat_helper *me) int ip_nat_helper_register(struct ip_nat_helper *me)
{ {
int ret = 0; int ret = 0;
...@@ -374,14 +372,13 @@ int ip_nat_helper_register(struct ip_nat_helper *me) ...@@ -374,14 +372,13 @@ int ip_nat_helper_register(struct ip_nat_helper *me)
&& ct_helper->me) { && ct_helper->me) {
__MOD_INC_USE_COUNT(ct_helper->me); __MOD_INC_USE_COUNT(ct_helper->me);
} else { } else {
#ifdef CONFIG_MODULES
/* We are a NAT helper for protocol X. If we need /* We are a NAT helper for protocol X. If we need
* respective conntrack helper for protoccol X, compute * respective conntrack helper for protoccol X, compute
* conntrack helper name and try to load module */ * conntrack helper name and try to load module */
char name[MODULE_MAX_NAMELEN]; char name[MODULE_NAME_LEN];
const char *tmp = me->me->name; const char *tmp = module_name(me->me);
if (strlen(tmp) + 6 > MODULE_MAX_NAMELEN) { if (strlen(tmp) + 6 > MODULE_NAME_LEN) {
printk("%s: unable to " printk("%s: unable to "
"compute conntrack helper name " "compute conntrack helper name "
"from %s\n", __FUNCTION__, tmp); "from %s\n", __FUNCTION__, tmp);
...@@ -403,7 +400,6 @@ int ip_nat_helper_register(struct ip_nat_helper *me) ...@@ -403,7 +400,6 @@ int ip_nat_helper_register(struct ip_nat_helper *me)
"because kernel was compiled without kernel " "because kernel was compiled without kernel "
"module loader support\n", name); "module loader support\n", name);
return -EBUSY; return -EBUSY;
#endif
#endif #endif
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment