Commit 0ae16cbb40a2881f6dfbe00fcb023ee7b548bc5c
1 parent
be9f643ae6
Exists in
v2017.01-smarct4x
and in
37 other branches
fpga: altera: Clean up the printing and debug
Clean up the printf() statements and get rid of the PRINTF() macro by replacing it with debug_cond(). Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chin Liang See <clsee@altera.com> Cc: Dinh Nguyen <dinguyen@altera.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net> Cc: Tom Rini <trini@ti.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Pavel Machek <pavel@denx.de> Acked-by: Pavel Machek <pavel@denx.de>
Showing 1 changed file with 58 additions and 59 deletions Side-by-side Diff
drivers/fpga/altera.c
... | ... | @@ -15,15 +15,9 @@ |
15 | 15 | #include <ACEX1K.h> |
16 | 16 | #include <stratixII.h> |
17 | 17 | |
18 | -/* Define FPGA_DEBUG to get debug printf's */ | |
19 | -/* #define FPGA_DEBUG */ | |
18 | +/* Define FPGA_DEBUG to 1 to get debug printf's */ | |
19 | +#define FPGA_DEBUG 0 | |
20 | 20 | |
21 | -#ifdef FPGA_DEBUG | |
22 | -#define PRINTF(fmt,args...) printf (fmt ,##args) | |
23 | -#else | |
24 | -#define PRINTF(fmt,args...) | |
25 | -#endif | |
26 | - | |
27 | 21 | /* Local Static Functions */ |
28 | 22 | static int altera_validate (Altera_desc * desc, const char *fn); |
29 | 23 | |
30 | 24 | |
31 | 25 | |
32 | 26 | |
33 | 27 | |
34 | 28 | |
... | ... | @@ -32,36 +26,39 @@ |
32 | 26 | { |
33 | 27 | int ret_val = FPGA_FAIL; /* assume a failure */ |
34 | 28 | |
35 | - if (!altera_validate (desc, (char *)__FUNCTION__)) { | |
36 | - printf ("%s: Invalid device descriptor\n", __FUNCTION__); | |
29 | + if (!altera_validate (desc, (char *)__func__)) { | |
30 | + printf("%s: Invalid device descriptor\n", __func__); | |
37 | 31 | } else { |
38 | 32 | switch (desc->family) { |
39 | 33 | case Altera_ACEX1K: |
40 | 34 | case Altera_CYC2: |
41 | 35 | #if defined(CONFIG_FPGA_ACEX1K) |
42 | - PRINTF ("%s: Launching the ACEX1K Loader...\n", | |
43 | - __FUNCTION__); | |
36 | + debug_cond(FPGA_DEBUG, | |
37 | + "%s: Launching the ACEX1K Loader...\n", | |
38 | + __func__); | |
44 | 39 | ret_val = ACEX1K_load (desc, buf, bsize); |
45 | 40 | #elif defined(CONFIG_FPGA_CYCLON2) |
46 | - PRINTF ("%s: Launching the CYCLONE II Loader...\n", | |
47 | - __FUNCTION__); | |
41 | + debug_cond(FPGA_DEBUG, | |
42 | + "%s: Launching the CYCLONE II Loader...\n", | |
43 | + __func__); | |
48 | 44 | ret_val = CYC2_load (desc, buf, bsize); |
49 | 45 | #else |
50 | - printf ("%s: No support for ACEX1K devices.\n", | |
51 | - __FUNCTION__); | |
46 | + printf("%s: No support for ACEX1K devices.\n", | |
47 | + __func__); | |
52 | 48 | #endif |
53 | 49 | break; |
54 | 50 | |
55 | 51 | #if defined(CONFIG_FPGA_STRATIX_II) |
56 | 52 | case Altera_StratixII: |
57 | - PRINTF ("%s: Launching the Stratix II Loader...\n", | |
58 | - __FUNCTION__); | |
53 | + debug_cond(FPGA_DEBUG, | |
54 | + "%s: Launching the Stratix II Loader...\n", | |
55 | + __func__); | |
59 | 56 | ret_val = StratixII_load (desc, buf, bsize); |
60 | 57 | break; |
61 | 58 | #endif |
62 | 59 | default: |
63 | - printf ("%s: Unsupported family type, %d\n", | |
64 | - __FUNCTION__, desc->family); | |
60 | + printf("%s: Unsupported family type, %d\n", | |
61 | + __func__, desc->family); | |
65 | 62 | } |
66 | 63 | } |
67 | 64 | |
68 | 65 | |
69 | 66 | |
70 | 67 | |
71 | 68 | |
... | ... | @@ -72,31 +69,33 @@ |
72 | 69 | { |
73 | 70 | int ret_val = FPGA_FAIL; /* assume a failure */ |
74 | 71 | |
75 | - if (!altera_validate (desc, (char *)__FUNCTION__)) { | |
76 | - printf ("%s: Invalid device descriptor\n", __FUNCTION__); | |
72 | + if (!altera_validate (desc, (char *)__func__)) { | |
73 | + printf("%s: Invalid device descriptor\n", __func__); | |
77 | 74 | } else { |
78 | 75 | switch (desc->family) { |
79 | 76 | case Altera_ACEX1K: |
80 | 77 | #if defined(CONFIG_FPGA_ACEX) |
81 | - PRINTF ("%s: Launching the ACEX1K Reader...\n", | |
82 | - __FUNCTION__); | |
78 | + debug_cond(FPGA_DEBUG, | |
79 | + "%s: Launching the ACEX1K Reader...\n", | |
80 | + __func__); | |
83 | 81 | ret_val = ACEX1K_dump (desc, buf, bsize); |
84 | 82 | #else |
85 | - printf ("%s: No support for ACEX1K devices.\n", | |
86 | - __FUNCTION__); | |
83 | + printf("%s: No support for ACEX1K devices.\n", | |
84 | + __func__); | |
87 | 85 | #endif |
88 | 86 | break; |
89 | 87 | |
90 | 88 | #if defined(CONFIG_FPGA_STRATIX_II) |
91 | 89 | case Altera_StratixII: |
92 | - PRINTF ("%s: Launching the Stratix II Reader...\n", | |
93 | - __FUNCTION__); | |
90 | + debug_cond(FPGA_DEBUG, | |
91 | + "%s: Launching the Stratix II Reader...\n", | |
92 | + __func__); | |
94 | 93 | ret_val = StratixII_dump (desc, buf, bsize); |
95 | 94 | break; |
96 | 95 | #endif |
97 | 96 | default: |
98 | - printf ("%s: Unsupported family type, %d\n", | |
99 | - __FUNCTION__, desc->family); | |
97 | + printf("%s: Unsupported family type, %d\n", | |
98 | + __func__, desc->family); | |
100 | 99 | } |
101 | 100 | } |
102 | 101 | |
103 | 102 | |
104 | 103 | |
105 | 104 | |
106 | 105 | |
107 | 106 | |
108 | 107 | |
109 | 108 | |
110 | 109 | |
111 | 110 | |
112 | 111 | |
113 | 112 | |
... | ... | @@ -107,42 +106,42 @@ |
107 | 106 | { |
108 | 107 | int ret_val = FPGA_FAIL; |
109 | 108 | |
110 | - if (altera_validate (desc, (char *)__FUNCTION__)) { | |
111 | - printf ("Family: \t"); | |
109 | + if (altera_validate (desc, (char *)__func__)) { | |
110 | + printf("Family: \t"); | |
112 | 111 | switch (desc->family) { |
113 | 112 | case Altera_ACEX1K: |
114 | - printf ("ACEX1K\n"); | |
113 | + printf("ACEX1K\n"); | |
115 | 114 | break; |
116 | 115 | case Altera_CYC2: |
117 | - printf ("CYCLON II\n"); | |
116 | + printf("CYCLON II\n"); | |
118 | 117 | break; |
119 | 118 | case Altera_StratixII: |
120 | - printf ("Stratix II\n"); | |
119 | + printf("Stratix II\n"); | |
121 | 120 | break; |
122 | 121 | /* Add new family types here */ |
123 | 122 | default: |
124 | - printf ("Unknown family type, %d\n", desc->family); | |
123 | + printf("Unknown family type, %d\n", desc->family); | |
125 | 124 | } |
126 | 125 | |
127 | - printf ("Interface type:\t"); | |
126 | + printf("Interface type:\t"); | |
128 | 127 | switch (desc->iface) { |
129 | 128 | case passive_serial: |
130 | - printf ("Passive Serial (PS)\n"); | |
129 | + printf("Passive Serial (PS)\n"); | |
131 | 130 | break; |
132 | 131 | case passive_parallel_synchronous: |
133 | - printf ("Passive Parallel Synchronous (PPS)\n"); | |
132 | + printf("Passive Parallel Synchronous (PPS)\n"); | |
134 | 133 | break; |
135 | 134 | case passive_parallel_asynchronous: |
136 | - printf ("Passive Parallel Asynchronous (PPA)\n"); | |
135 | + printf("Passive Parallel Asynchronous (PPA)\n"); | |
137 | 136 | break; |
138 | 137 | case passive_serial_asynchronous: |
139 | - printf ("Passive Serial Asynchronous (PSA)\n"); | |
138 | + printf("Passive Serial Asynchronous (PSA)\n"); | |
140 | 139 | break; |
141 | 140 | case altera_jtag_mode: /* Not used */ |
142 | - printf ("JTAG Mode\n"); | |
141 | + printf("JTAG Mode\n"); | |
143 | 142 | break; |
144 | 143 | case fast_passive_parallel: |
145 | - printf ("Fast Passive Parallel (FPP)\n"); | |
144 | + printf("Fast Passive Parallel (FPP)\n"); | |
146 | 145 | break; |
147 | 146 | case fast_passive_parallel_security: |
148 | 147 | printf |
149 | 148 | |
150 | 149 | |
151 | 150 | |
152 | 151 | |
153 | 152 | |
154 | 153 | |
... | ... | @@ -150,31 +149,31 @@ |
150 | 149 | break; |
151 | 150 | /* Add new interface types here */ |
152 | 151 | default: |
153 | - printf ("Unsupported interface type, %d\n", desc->iface); | |
152 | + printf("Unsupported interface type, %d\n", desc->iface); | |
154 | 153 | } |
155 | 154 | |
156 | 155 | printf("Device Size: \t%zd bytes\n" |
157 | - "Cookie: \t0x%x (%d)\n", | |
158 | - desc->size, desc->cookie, desc->cookie); | |
156 | + "Cookie: \t0x%x (%d)\n", | |
157 | + desc->size, desc->cookie, desc->cookie); | |
159 | 158 | |
160 | 159 | if (desc->iface_fns) { |
161 | - printf ("Device Function Table @ 0x%p\n", desc->iface_fns); | |
160 | + printf("Device Function Table @ 0x%p\n", desc->iface_fns); | |
162 | 161 | switch (desc->family) { |
163 | 162 | case Altera_ACEX1K: |
164 | 163 | case Altera_CYC2: |
165 | 164 | #if defined(CONFIG_FPGA_ACEX1K) |
166 | - ACEX1K_info (desc); | |
165 | + ACEX1K_info(desc); | |
167 | 166 | #elif defined(CONFIG_FPGA_CYCLON2) |
168 | - CYC2_info (desc); | |
167 | + CYC2_info(desc); | |
169 | 168 | #else |
170 | 169 | /* just in case */ |
171 | - printf ("%s: No support for ACEX1K devices.\n", | |
172 | - __FUNCTION__); | |
170 | + printf("%s: No support for ACEX1K devices.\n", | |
171 | + __func__); | |
173 | 172 | #endif |
174 | 173 | break; |
175 | 174 | #if defined(CONFIG_FPGA_STRATIX_II) |
176 | 175 | case Altera_StratixII: |
177 | - StratixII_info (desc); | |
176 | + StratixII_info(desc); | |
178 | 177 | break; |
179 | 178 | #endif |
180 | 179 | /* Add new family types here */ |
181 | 180 | |
... | ... | @@ -183,12 +182,12 @@ |
183 | 182 | break; |
184 | 183 | } |
185 | 184 | } else { |
186 | - printf ("No Device Function Table.\n"); | |
185 | + printf("No Device Function Table.\n"); | |
187 | 186 | } |
188 | 187 | |
189 | 188 | ret_val = FPGA_SUCCESS; |
190 | 189 | } else { |
191 | - printf ("%s: Invalid device descriptor\n", __FUNCTION__); | |
190 | + printf("%s: Invalid device descriptor\n", __func__); | |
192 | 191 | } |
193 | 192 | |
194 | 193 | return ret_val; |
195 | 194 | |
196 | 195 | |
197 | 196 | |
... | ... | @@ -208,17 +207,17 @@ |
208 | 207 | if (desc->size) { |
209 | 208 | ret_val = true; |
210 | 209 | } else { |
211 | - printf ("%s: NULL part size\n", fn); | |
210 | + printf("%s: NULL part size\n", fn); | |
212 | 211 | } |
213 | 212 | } else { |
214 | - printf ("%s: Invalid Interface type, %d\n", | |
215 | - fn, desc->iface); | |
213 | + printf("%s: Invalid Interface type, %d\n", | |
214 | + fn, desc->iface); | |
216 | 215 | } |
217 | 216 | } else { |
218 | - printf ("%s: Invalid family type, %d\n", fn, desc->family); | |
217 | + printf("%s: Invalid family type, %d\n", fn, desc->family); | |
219 | 218 | } |
220 | 219 | } else { |
221 | - printf ("%s: NULL descriptor!\n", fn); | |
220 | + printf("%s: NULL descriptor!\n", fn); | |
222 | 221 | } |
223 | 222 | |
224 | 223 | return ret_val; |