44 * Licensed under the GPL-2 or later
55 */
66
7- #define pr_fmt (fmt ) "module %s: " fmt, mod->name
8-
97#include <linux/moduleloader.h>
108#include <linux/elf.h>
119#include <linux/vmalloc.h>
1614#include <asm/cacheflush.h>
1715#include <linux/uaccess.h>
1816
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+
1922/* Transfer the section to the L1 memory */
2023int
2124module_frob_arch_sections (Elf_Ehdr * hdr , Elf_Shdr * sechdrs ,
@@ -44,7 +47,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
4447 dest = l1_inst_sram_alloc (s -> sh_size );
4548 mod -> arch .text_l1 = dest ;
4649 if (dest == NULL ) {
47- pr_err ( "L1 inst memory allocation failed\n" );
50+ mod_err ( mod , "L1 inst memory allocation failed\n" );
4851 return -1 ;
4952 }
5053 dma_memcpy (dest , (void * )s -> sh_addr , s -> sh_size );
@@ -56,7 +59,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
5659 dest = l1_data_sram_alloc (s -> sh_size );
5760 mod -> arch .data_a_l1 = dest ;
5861 if (dest == NULL ) {
59- pr_err ( "L1 data memory allocation failed\n" );
62+ mod_err ( mod , "L1 data memory allocation failed\n" );
6063 return -1 ;
6164 }
6265 memcpy (dest , (void * )s -> sh_addr , s -> sh_size );
@@ -68,7 +71,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
6871 dest = l1_data_sram_zalloc (s -> sh_size );
6972 mod -> arch .bss_a_l1 = dest ;
7073 if (dest == NULL ) {
71- pr_err ( "L1 data memory allocation failed\n" );
74+ mod_err ( mod , "L1 data memory allocation failed\n" );
7275 return -1 ;
7376 }
7477
@@ -77,7 +80,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7780 dest = l1_data_B_sram_alloc (s -> sh_size );
7881 mod -> arch .data_b_l1 = dest ;
7982 if (dest == NULL ) {
80- pr_err ( "L1 data memory allocation failed\n" );
83+ mod_err ( mod , "L1 data memory allocation failed\n" );
8184 return -1 ;
8285 }
8386 memcpy (dest , (void * )s -> sh_addr , s -> sh_size );
@@ -87,7 +90,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8790 dest = l1_data_B_sram_alloc (s -> sh_size );
8891 mod -> arch .bss_b_l1 = dest ;
8992 if (dest == NULL ) {
90- pr_err ( "L1 data memory allocation failed\n" );
93+ mod_err ( mod , "L1 data memory allocation failed\n" );
9194 return -1 ;
9295 }
9396 memset (dest , 0 , s -> sh_size );
@@ -99,7 +102,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
99102 dest = l2_sram_alloc (s -> sh_size );
100103 mod -> arch .text_l2 = dest ;
101104 if (dest == NULL ) {
102- pr_err ( "L2 SRAM allocation failed\n" );
105+ mod_err ( mod , "L2 SRAM allocation failed\n" );
103106 return -1 ;
104107 }
105108 memcpy (dest , (void * )s -> sh_addr , s -> sh_size );
@@ -111,7 +114,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
111114 dest = l2_sram_alloc (s -> sh_size );
112115 mod -> arch .data_l2 = dest ;
113116 if (dest == NULL ) {
114- pr_err ( "L2 SRAM allocation failed\n" );
117+ mod_err ( mod , "L2 SRAM allocation failed\n" );
115118 return -1 ;
116119 }
117120 memcpy (dest , (void * )s -> sh_addr , s -> sh_size );
@@ -123,7 +126,7 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
123126 dest = l2_sram_zalloc (s -> sh_size );
124127 mod -> arch .bss_l2 = dest ;
125128 if (dest == NULL ) {
126- pr_err ( "L2 SRAM allocation failed\n" );
129+ mod_err ( mod , "L2 SRAM allocation failed\n" );
127130 return -1 ;
128131 }
129132
@@ -157,8 +160,8 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
157160 Elf32_Sym * sym ;
158161 unsigned long location , value , size ;
159162
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 );
162165
163166 for (i = 0 ; i < sechdrs [relsec ].sh_size / sizeof (* rel ); i ++ ) {
164167 /* This is where to make the change */
@@ -174,14 +177,14 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
174177
175178#ifdef CONFIG_SMP
176179 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" ,
178181 ELF32_R_TYPE (rel [i ].r_info ));
179182 return - ENOEXEC ;
180183 }
181184#endif
182185
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 ));
185188
186189 switch (ELF32_R_TYPE (rel [i ].r_info )) {
187190
@@ -200,12 +203,12 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
200203 case R_BFIN_PCREL12_JUMP :
201204 case R_BFIN_PCREL12_JUMP_S :
202205 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" ,
204207 ELF32_R_TYPE (rel [i ].r_info ));
205208 return - ENOEXEC ;
206209
207210 default :
208- pr_err ( "unknown relocation: %u\n" ,
211+ mod_err ( mod , "unknown relocation: %u\n" ,
209212 ELF32_R_TYPE (rel [i ].r_info ));
210213 return - ENOEXEC ;
211214 }
@@ -222,7 +225,7 @@ apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
222225 isram_memcpy ((void * )location , & value , size );
223226 break ;
224227 default :
225- pr_err ( "invalid relocation for %#lx\n" , location );
228+ mod_err ( mod , "invalid relocation for %#lx\n" , location );
226229 return - ENOEXEC ;
227230 }
228231 }
0 commit comments