aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/kernel/module.c')
-rw-r--r--arch/blackfin/kernel/module.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/arch/blackfin/kernel/module.c b/arch/blackfin/kernel/module.c
index 0188c933b155..15af5768c403 100644
--- a/arch/blackfin/kernel/module.c
+++ b/arch/blackfin/kernel/module.c
@@ -4,8 +4,6 @@
4 * Licensed under the GPL-2 or later 4 * Licensed under the GPL-2 or later
5 */ 5 */
6 6
7#define pr_fmt(fmt) "module %s: " fmt, mod->name
8
9#include <linux/moduleloader.h> 7#include <linux/moduleloader.h>
10#include <linux/elf.h> 8#include <linux/elf.h>
11#include <linux/vmalloc.h> 9#include <linux/vmalloc.h>
@@ -16,6 +14,11 @@
16#include <asm/cacheflush.h> 14#include <asm/cacheflush.h>
17#include <linux/uaccess.h> 15#include <linux/uaccess.h>
18 16
17#define mod_err(mod, fmt, ...) \
18 pr_err("module %s: " fmt, (mod)->name, ##__VA_ARGS__)
19#define mod_debug(mod, fmt, ...) \
20 pr_debug("module %s: " fmt, (mod)->name, ##__VA_ARGS__)
21
19/* Transfer the section to the L1 memory */ 22/* Transfer the section to the L1 memory */
20int 23int
21module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, 24module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
@@ -44,7 +47,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
44 dest = l1_inst_sram_alloc(s->sh_size); 47 dest = l1_inst_sram_alloc(s->sh_size);
45 mod->arch.text_l1 = dest; 48 mod->arch.text_l1 = dest;
46 if (dest == NULL) { 49 if (dest == NULL) {
47 pr_err("L1 inst memory allocation failed\n"); 50 mod_err(mod, "L1 inst memory allocation failed\n");
48 return -1; 51 return -1;
49 } 52 }
50 dma_memcpy(dest, (void *)s->sh_addr, s->sh_size); 53 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 dest = l1_data_sram_alloc(s->sh_size); 59 dest = l1_data_sram_alloc(s->sh_size);
57 mod->arch.data_a_l1 = dest; 60 mod->arch.data_a_l1 = dest;
58 if (dest == NULL) { 61 if (dest == NULL) {
59 pr_err("L1 data memory allocation failed\n"); 62 mod_err(mod, "L1 data memory allocation failed\n");
60 return -1; 63 return -1;
61 } 64 }
62 memcpy(dest, (void *)s->sh_addr, s->sh_size); 65 memcpy(dest, (void *)s->sh_addr, s->sh_size);
@@ -68,7 +71,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
68 dest = l1_data_sram_zalloc(s->sh_size); 71 dest = l1_data_sram_zalloc(s->sh_size);
69 mod->arch.bss_a_l1 = dest; 72 mod->arch.bss_a_l1 = dest;
70 if (dest == NULL) { 73 if (dest == NULL) {
71 pr_err("L1 data memory allocation failed\n"); 74 mod_err(mod, "L1 data memory allocation failed\n");
72 return -1; 75 return -1;
73 } 76 }
74 77
@@ -77,7 +80,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
77 dest = l1_data_B_sram_alloc(s->sh_size); 80 dest = l1_data_B_sram_alloc(s->sh_size);
78 mod->arch.data_b_l1 = dest; 81 mod->arch.data_b_l1 = dest;
79 if (dest == NULL) { 82 if (dest == NULL) {
80 pr_err("L1 data memory allocation failed\n"); 83 mod_err(mod, "L1 data memory allocation failed\n");
81 return -1; 84 return -1;
82 } 85 }
83 memcpy(dest, (void *)s->sh_addr, s->sh_size); 86 memcpy(dest, (void *)s->sh_addr, s->sh_size);
@@ -87,7 +90,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
87 dest = l1_data_B_sram_alloc(s->sh_size); 90 dest = l1_data_B_sram_alloc(s->sh_size);
88 mod->arch.bss_b_l1 = dest; 91 mod->arch.bss_b_l1 = dest;
89 if (dest == NULL) { 92 if (dest == NULL) {
90 pr_err("L1 data memory allocation failed\n"); 93 mod_err(mod, "L1 data memory allocation failed\n");
91 return -1; 94 return -1;
92 } 95 }
93 memset(dest, 0, s->sh_size); 96 memset(dest, 0, s->sh_size);
@@ -99,7 +102,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
99 dest = l2_sram_alloc(s->sh_size); 102 dest = l2_sram_alloc(s->sh_size);
100 mod->arch.text_l2 = dest; 103 mod->arch.text_l2 = dest;
101 if (dest == NULL) { 104 if (dest == NULL) {
102 pr_err("L2 SRAM allocation failed\n"); 105 mod_err(mod, "L2 SRAM allocation failed\n");
103 return -1; 106 return -1;
104 } 107 }
105 memcpy(dest, (void *)s->sh_addr, s->sh_size); 108 memcpy(dest, (void *)s->sh_addr, s->sh_size);
@@ -111,7 +114,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
111 dest = l2_sram_alloc(s->sh_size); 114 dest = l2_sram_alloc(s->sh_size);
112 mod->arch.data_l2 = dest; 115 mod->arch.data_l2 = dest;
113 if (dest == NULL) { 116 if (dest == NULL) {
114 pr_err("L2 SRAM allocation failed\n"); 117 mod_err(mod, "L2 SRAM allocation failed\n");
115 return -1; 118 return -1;
116 } 119 }
117 memcpy(dest, (void *)s->sh_addr, s->sh_size); 120 memcpy(dest, (void *)s->sh_addr, s->sh_size);
@@ -123,7 +126,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
123 dest = l2_sram_zalloc(s->sh_size); 126 dest = l2_sram_zalloc(s->sh_size);
124 mod->arch.bss_l2 = dest; 127 mod->arch.bss_l2 = dest;
125 if (dest == NULL) { 128 if (dest == NULL) {
126 pr_err("L2 SRAM allocation failed\n"); 129 mod_err(mod, "L2 SRAM allocation failed\n");
127 return -1; 130 return -1;
128 } 131 }
129 132
@@ -157,8 +160,8 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
157 Elf32_Sym *sym; 160 Elf32_Sym *sym;
158 unsigned long location, value, size; 161 unsigned long location, value, size;
159 162
160 pr_debug("applying relocate section %u to %u\n", 163 mod_debug(mod, "applying relocate section %u to %u\n",
161 relsec, sechdrs[relsec].sh_info); 164 relsec, sechdrs[relsec].sh_info);
162 165
163 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 166 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
164 /* This is where to make the change */ 167 /* This is where to make the change */
@@ -174,14 +177,14 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
174 177
175#ifdef CONFIG_SMP 178#ifdef CONFIG_SMP
176 if (location >= COREB_L1_DATA_A_START) { 179 if (location >= COREB_L1_DATA_A_START) {
177 pr_err("cannot relocate in L1: %u (SMP kernel)\n", 180 mod_err(mod, "cannot relocate in L1: %u (SMP kernel)\n",
178 ELF32_R_TYPE(rel[i].r_info)); 181 ELF32_R_TYPE(rel[i].r_info));
179 return -ENOEXEC; 182 return -ENOEXEC;
180 } 183 }
181#endif 184#endif
182 185
183 pr_debug("location is %lx, value is %lx type is %d\n", 186 mod_debug(mod, "location is %lx, value is %lx type is %d\n",
184 location, value, ELF32_R_TYPE(rel[i].r_info)); 187 location, value, ELF32_R_TYPE(rel[i].r_info));
185 188
186 switch (ELF32_R_TYPE(rel[i].r_info)) { 189 switch (ELF32_R_TYPE(rel[i].r_info)) {
187 190
@@ -200,12 +203,12 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
200 case R_BFIN_PCREL12_JUMP: 203 case R_BFIN_PCREL12_JUMP:
201 case R_BFIN_PCREL12_JUMP_S: 204 case R_BFIN_PCREL12_JUMP_S:
202 case R_BFIN_PCREL10: 205 case R_BFIN_PCREL10:
203 pr_err("unsupported relocation: %u (no -mlong-calls?)\n", 206 mod_err(mod, "unsupported relocation: %u (no -mlong-calls?)\n",
204 ELF32_R_TYPE(rel[i].r_info)); 207 ELF32_R_TYPE(rel[i].r_info));
205 return -ENOEXEC; 208 return -ENOEXEC;
206 209
207 default: 210 default:
208 pr_err("unknown relocation: %u\n", 211 mod_err(mod, "unknown relocation: %u\n",
209 ELF32_R_TYPE(rel[i].r_info)); 212 ELF32_R_TYPE(rel[i].r_info));
210 return -ENOEXEC; 213 return -ENOEXEC;
211 } 214 }
@@ -222,7 +225,7 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
222 isram_memcpy((void *)location, &value, size); 225 isram_memcpy((void *)location, &value, size);
223 break; 226 break;
224 default: 227 default:
225 pr_err("invalid relocation for %#lx\n", location); 228 mod_err(mod, "invalid relocation for %#lx\n", location);
226 return -ENOEXEC; 229 return -ENOEXEC;
227 } 230 }
228 } 231 }