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