Commit e2c75fca authored by Joe Perches's avatar Joe Perches Committed by Paul E. McKenney

module: Fix pr_fmt() bug for header use of printk

This commit removes the pr_fmt() macro, replacing it with mod_err() and
mod_debug() macros to avoid errors when using printk() from header files.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 520eccdf
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
* Licensed under the GPL-2 or later * Licensed under the GPL-2 or later
*/ */
#define pr_fmt(fmt) "module %s: " fmt, mod->name
#include <linux/moduleloader.h> #include <linux/moduleloader.h>
#include <linux/elf.h> #include <linux/elf.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -16,6 +14,11 @@ ...@@ -16,6 +14,11 @@
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#define mod_err(mod, fmt, ...) \
pr_err("module %s: " fmt, (mod)->name, ##__VA_ARGS__)
#define mod_debug(mod, fmt, ...) \
pr_debug("module %s: " fmt, (mod)->name, ##__VA_ARGS__)
/* Transfer the section to the L1 memory */ /* Transfer the section to the L1 memory */
int int
module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
...@@ -44,7 +47,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -44,7 +47,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l1_inst_sram_alloc(s->sh_size); dest = l1_inst_sram_alloc(s->sh_size);
mod->arch.text_l1 = dest; mod->arch.text_l1 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L1 inst memory allocation failed\n"); mod_err(mod, "L1 inst memory allocation failed\n");
return -1; return -1;
} }
dma_memcpy(dest, (void *)s->sh_addr, s->sh_size); dma_memcpy(dest, (void *)s->sh_addr, s->sh_size);
...@@ -56,7 +59,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -56,7 +59,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l1_data_sram_alloc(s->sh_size); dest = l1_data_sram_alloc(s->sh_size);
mod->arch.data_a_l1 = dest; mod->arch.data_a_l1 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L1 data memory allocation failed\n"); mod_err(mod, "L1 data memory allocation failed\n");
return -1; return -1;
} }
memcpy(dest, (void *)s->sh_addr, s->sh_size); memcpy(dest, (void *)s->sh_addr, s->sh_size);
...@@ -68,7 +71,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -68,7 +71,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l1_data_sram_zalloc(s->sh_size); dest = l1_data_sram_zalloc(s->sh_size);
mod->arch.bss_a_l1 = dest; mod->arch.bss_a_l1 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L1 data memory allocation failed\n"); mod_err(mod, "L1 data memory allocation failed\n");
return -1; return -1;
} }
...@@ -77,7 +80,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -77,7 +80,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l1_data_B_sram_alloc(s->sh_size); dest = l1_data_B_sram_alloc(s->sh_size);
mod->arch.data_b_l1 = dest; mod->arch.data_b_l1 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L1 data memory allocation failed\n"); mod_err(mod, "L1 data memory allocation failed\n");
return -1; return -1;
} }
memcpy(dest, (void *)s->sh_addr, s->sh_size); memcpy(dest, (void *)s->sh_addr, s->sh_size);
...@@ -87,7 +90,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -87,7 +90,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l1_data_B_sram_alloc(s->sh_size); dest = l1_data_B_sram_alloc(s->sh_size);
mod->arch.bss_b_l1 = dest; mod->arch.bss_b_l1 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L1 data memory allocation failed\n"); mod_err(mod, "L1 data memory allocation failed\n");
return -1; return -1;
} }
memset(dest, 0, s->sh_size); memset(dest, 0, s->sh_size);
...@@ -99,7 +102,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -99,7 +102,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l2_sram_alloc(s->sh_size); dest = l2_sram_alloc(s->sh_size);
mod->arch.text_l2 = dest; mod->arch.text_l2 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L2 SRAM allocation failed\n"); mod_err(mod, "L2 SRAM allocation failed\n");
return -1; return -1;
} }
memcpy(dest, (void *)s->sh_addr, s->sh_size); memcpy(dest, (void *)s->sh_addr, s->sh_size);
...@@ -111,7 +114,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -111,7 +114,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l2_sram_alloc(s->sh_size); dest = l2_sram_alloc(s->sh_size);
mod->arch.data_l2 = dest; mod->arch.data_l2 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L2 SRAM allocation failed\n"); mod_err(mod, "L2 SRAM allocation failed\n");
return -1; return -1;
} }
memcpy(dest, (void *)s->sh_addr, s->sh_size); memcpy(dest, (void *)s->sh_addr, s->sh_size);
...@@ -123,7 +126,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ...@@ -123,7 +126,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
dest = l2_sram_zalloc(s->sh_size); dest = l2_sram_zalloc(s->sh_size);
mod->arch.bss_l2 = dest; mod->arch.bss_l2 = dest;
if (dest == NULL) { if (dest == NULL) {
pr_err("L2 SRAM allocation failed\n"); mod_err(mod, "L2 SRAM allocation failed\n");
return -1; return -1;
} }
...@@ -157,7 +160,7 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, ...@@ -157,7 +160,7 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
Elf32_Sym *sym; Elf32_Sym *sym;
unsigned long location, value, size; unsigned long location, value, size;
pr_debug("applying relocate section %u to %u\n", mod_debug(mod, "applying relocate section %u to %u\n",
relsec, sechdrs[relsec].sh_info); relsec, sechdrs[relsec].sh_info);
for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
...@@ -174,13 +177,13 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, ...@@ -174,13 +177,13 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
if (location >= COREB_L1_DATA_A_START) { if (location >= COREB_L1_DATA_A_START) {
pr_err("cannot relocate in L1: %u (SMP kernel)\n", mod_err(mod, "cannot relocate in L1: %u (SMP kernel)\n",
ELF32_R_TYPE(rel[i].r_info)); ELF32_R_TYPE(rel[i].r_info));
return -ENOEXEC; return -ENOEXEC;
} }
#endif #endif
pr_debug("location is %lx, value is %lx type is %d\n", mod_debug(mod, "location is %lx, value is %lx type is %d\n",
location, value, ELF32_R_TYPE(rel[i].r_info)); location, value, ELF32_R_TYPE(rel[i].r_info));
switch (ELF32_R_TYPE(rel[i].r_info)) { switch (ELF32_R_TYPE(rel[i].r_info)) {
...@@ -200,12 +203,12 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, ...@@ -200,12 +203,12 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
case R_BFIN_PCREL12_JUMP: case R_BFIN_PCREL12_JUMP:
case R_BFIN_PCREL12_JUMP_S: case R_BFIN_PCREL12_JUMP_S:
case R_BFIN_PCREL10: case R_BFIN_PCREL10:
pr_err("unsupported relocation: %u (no -mlong-calls?)\n", mod_err(mod, "unsupported relocation: %u (no -mlong-calls?)\n",
ELF32_R_TYPE(rel[i].r_info)); ELF32_R_TYPE(rel[i].r_info));
return -ENOEXEC; return -ENOEXEC;
default: default:
pr_err("unknown relocation: %u\n", mod_err(mod, "unknown relocation: %u\n",
ELF32_R_TYPE(rel[i].r_info)); ELF32_R_TYPE(rel[i].r_info));
return -ENOEXEC; return -ENOEXEC;
} }
...@@ -222,7 +225,7 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, ...@@ -222,7 +225,7 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
isram_memcpy((void *)location, &value, size); isram_memcpy((void *)location, &value, size);
break; break;
default: default:
pr_err("invalid relocation for %#lx\n", location); mod_err(mod, "invalid relocation for %#lx\n", location);
return -ENOEXEC; return -ENOEXEC;
} }
} }
......
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