Commit 2dd951ecd511756f405ae9324db87bb0159f6225

Authored by Hannes Reinecke
Committed by Christoph Hellwig
1 parent 026f8da8da

scsi: Conditionally compile in constants.c

Instead of having constants.c littered with ifdef statements we should
be moving dummy functions into the header and condintionally compile in
constants.c if selected. And update the Kconfig description to reflect
the actual size difference.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>

Showing 5 changed files with 69 additions and 52 deletions Side-by-side Diff

drivers/scsi/Kconfig
... ... @@ -201,12 +201,12 @@
201 201 certain enclosure conditions to be reported and is not required.
202 202  
203 203 config SCSI_CONSTANTS
204   - bool "Verbose SCSI error reporting (kernel size +=12K)"
  204 + bool "Verbose SCSI error reporting (kernel size +=75K)"
205 205 depends on SCSI
206 206 help
207 207 The error messages regarding your SCSI hardware will be easier to
208 208 understand if you say Y here; it will enlarge your kernel by about
209   - 12 KB. If in doubt, say Y.
  209 + 75 KB. If in doubt, say Y.
210 210  
211 211 config SCSI_LOGGING
212 212 bool "SCSI logging facility"
drivers/scsi/Makefile
... ... @@ -159,9 +159,9 @@
159 159  
160 160 # This goes last, so that "real" scsi devices probe earlier
161 161 obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
162   -
163   -scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
  162 +scsi_mod-y += scsi.o hosts.o scsi_ioctl.o \
164 163 scsicam.o scsi_error.o scsi_lib.o
  164 +scsi_mod-$(CONFIG_SCSI_CONSTANTS) += constants.o
165 165 scsi_mod-$(CONFIG_SCSI_DMA) += scsi_lib_dma.o
166 166 scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o
167 167 scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o
drivers/scsi/constants.c
... ... @@ -18,8 +18,6 @@
18 18 #include <scsi/scsi_eh.h>
19 19 #include <scsi/scsi_dbg.h>
20 20  
21   -
22   -
23 21 /* Commands with service actions that change the command name */
24 22 #define THIRD_PARTY_COPY_OUT 0x83
25 23 #define THIRD_PARTY_COPY_IN 0x84
... ... @@ -35,7 +33,6 @@
35 33 const char * name;
36 34 };
37 35  
38   -#ifdef CONFIG_SCSI_CONSTANTS
39 36 static const char * cdb_byte0_names[] = {
40 37 /* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense",
41 38 /* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL,
... ... @@ -259,26 +256,6 @@
259 256 {0, NULL, 0},
260 257 };
261 258  
262   -#else /* ifndef CONFIG_SCSI_CONSTANTS */
263   -static const char *cdb_byte0_names[0];
264   -
265   -static struct sa_name_list sa_names_arr[] = {
266   - {VARIABLE_LENGTH_CMD, NULL, 0},
267   - {MAINTENANCE_IN, NULL, 0},
268   - {MAINTENANCE_OUT, NULL, 0},
269   - {PERSISTENT_RESERVE_IN, NULL, 0},
270   - {PERSISTENT_RESERVE_OUT, NULL, 0},
271   - {SERVICE_ACTION_IN_12, NULL, 0},
272   - {SERVICE_ACTION_OUT_12, NULL, 0},
273   - {SERVICE_ACTION_BIDIRECTIONAL, NULL, 0},
274   - {SERVICE_ACTION_IN_16, NULL, 0},
275   - {SERVICE_ACTION_OUT_16, NULL, 0},
276   - {THIRD_PARTY_COPY_IN, NULL, 0},
277   - {THIRD_PARTY_COPY_OUT, NULL, 0},
278   - {0, NULL, 0},
279   -};
280   -#endif /* CONFIG_SCSI_CONSTANTS */
281   -
282 259 bool scsi_opcode_sa_name(int opcode, int service_action,
283 260 const char **cdb_name, const char **sa_name)
284 261 {
... ... @@ -313,8 +290,6 @@
313 290 return true;
314 291 }
315 292  
316   -#ifdef CONFIG_SCSI_CONSTANTS
317   -
318 293 struct error_info {
319 294 unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */
320 295 const char * text;
321 296  
322 297  
... ... @@ -1203,15 +1178,12 @@
1203 1178 "Completed", /* F: command completed sense data reported,
1204 1179 may occur for successful command */
1205 1180 };
1206   -#endif
1207 1181  
1208 1182 /* Get sense key string or NULL if not available */
1209 1183 const char *
1210 1184 scsi_sense_key_string(unsigned char key) {
1211   -#ifdef CONFIG_SCSI_CONSTANTS
1212 1185 if (key <= 0xE)
1213 1186 return snstext[key];
1214   -#endif
1215 1187 return NULL;
1216 1188 }
1217 1189 EXPORT_SYMBOL(scsi_sense_key_string);
... ... @@ -1223,7 +1195,6 @@
1223 1195 const char *
1224 1196 scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
1225 1197 {
1226   -#ifdef CONFIG_SCSI_CONSTANTS
1227 1198 int i;
1228 1199 unsigned short code = ((asc << 8) | ascq);
1229 1200  
1230 1201  
... ... @@ -1239,15 +1210,10 @@
1239 1210 return additional2[i].str;
1240 1211 }
1241 1212 }
1242   -#else
1243   - *fmt = NULL;
1244   -#endif
1245 1213 return NULL;
1246 1214 }
1247 1215 EXPORT_SYMBOL(scsi_extd_sense_format);
1248 1216  
1249   -#ifdef CONFIG_SCSI_CONSTANTS
1250   -
1251 1217 static const char * const hostbyte_table[]={
1252 1218 "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
1253 1219 "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
1254 1220  
1255 1221  
... ... @@ -1259,17 +1225,13 @@
1259 1225 "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1260 1226 "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
1261 1227  
1262   -#endif
1263   -
1264 1228 const char *scsi_hostbyte_string(int result)
1265 1229 {
1266 1230 const char *hb_string = NULL;
1267   -#ifdef CONFIG_SCSI_CONSTANTS
1268 1231 int hb = host_byte(result);
1269 1232  
1270 1233 if (hb < ARRAY_SIZE(hostbyte_table))
1271 1234 hb_string = hostbyte_table[hb];
1272   -#endif
1273 1235 return hb_string;
1274 1236 }
1275 1237 EXPORT_SYMBOL(scsi_hostbyte_string);
1276 1238  
1277 1239  
... ... @@ -1277,17 +1239,14 @@
1277 1239 const char *scsi_driverbyte_string(int result)
1278 1240 {
1279 1241 const char *db_string = NULL;
1280   -#ifdef CONFIG_SCSI_CONSTANTS
1281 1242 int db = driver_byte(result);
1282 1243  
1283 1244 if (db < ARRAY_SIZE(driverbyte_table))
1284 1245 db_string = driverbyte_table[db];
1285   -#endif
1286 1246 return db_string;
1287 1247 }
1288 1248 EXPORT_SYMBOL(scsi_driverbyte_string);
1289 1249  
1290   -#ifdef CONFIG_SCSI_CONSTANTS
1291 1250 #define scsi_mlreturn_name(result) { result, #result }
1292 1251 static const struct value_name_pair scsi_mlreturn_arr[] = {
1293 1252 scsi_mlreturn_name(NEEDS_RETRY),
1294 1253  
... ... @@ -1300,11 +1259,9 @@
1300 1259 scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED),
1301 1260 scsi_mlreturn_name(FAST_IO_FAIL)
1302 1261 };
1303   -#endif
1304 1262  
1305 1263 const char *scsi_mlreturn_string(int result)
1306 1264 {
1307   -#ifdef CONFIG_SCSI_CONSTANTS
1308 1265 const struct value_name_pair *arr = scsi_mlreturn_arr;
1309 1266 int k;
1310 1267  
... ... @@ -1312,7 +1269,6 @@
1312 1269 if (result == arr->value)
1313 1270 return arr->name;
1314 1271 }
1315   -#endif
1316 1272 return NULL;
1317 1273 }
1318 1274 EXPORT_SYMBOL(scsi_mlreturn_string);
drivers/xen/xen-scsiback.c
... ... @@ -47,6 +47,7 @@
47 47  
48 48 #include <generated/utsrelease.h>
49 49  
  50 +#include <scsi/scsi.h>
50 51 #include <scsi/scsi_dbg.h>
51 52 #include <scsi/scsi_eh.h>
52 53 #include <scsi/scsi_tcq.h>
include/scsi/scsi_dbg.h
... ... @@ -7,7 +7,6 @@
7 7  
8 8 #define SCSI_LOG_BUFSIZE 128
9 9  
10   -extern bool scsi_opcode_sa_name(int, int, const char **, const char **);
11 10 extern void scsi_print_command(struct scsi_cmnd *);
12 11 extern size_t __scsi_format_command(char *, size_t,
13 12 const unsigned char *, size_t);
14 13  
... ... @@ -22,12 +21,73 @@
22 21 const unsigned char *sense_buffer,
23 22 int sense_len);
24 23 extern void scsi_print_result(const struct scsi_cmnd *, const char *, int);
25   -extern const char *scsi_hostbyte_string(int);
26   -extern const char *scsi_driverbyte_string(int);
27   -extern const char *scsi_mlreturn_string(int);
  24 +
  25 +#ifdef CONFIG_SCSI_CONSTANTS
  26 +extern bool scsi_opcode_sa_name(int, int, const char **, const char **);
28 27 extern const char *scsi_sense_key_string(unsigned char);
29 28 extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
30 29 const char **);
  30 +extern const char *scsi_mlreturn_string(int);
  31 +extern const char *scsi_hostbyte_string(int);
  32 +extern const char *scsi_driverbyte_string(int);
  33 +#else
  34 +static inline bool
  35 +scsi_opcode_sa_name(int cmd, int sa,
  36 + const char **cdb_name, const char **sa_name)
  37 +{
  38 + *cdb_name = NULL;
  39 + switch (cmd) {
  40 + case VARIABLE_LENGTH_CMD:
  41 + case MAINTENANCE_IN:
  42 + case MAINTENANCE_OUT:
  43 + case PERSISTENT_RESERVE_IN:
  44 + case PERSISTENT_RESERVE_OUT:
  45 + case SERVICE_ACTION_IN_12:
  46 + case SERVICE_ACTION_OUT_12:
  47 + case SERVICE_ACTION_BIDIRECTIONAL:
  48 + case SERVICE_ACTION_IN_16:
  49 + case SERVICE_ACTION_OUT_16:
  50 + case EXTENDED_COPY:
  51 + case RECEIVE_COPY_RESULTS:
  52 + *sa_name = NULL;
  53 + return true;
  54 + default:
  55 + return false;
  56 + }
  57 +}
  58 +
  59 +static inline const char *
  60 +scsi_sense_key_string(unsigned char key)
  61 +{
  62 + return NULL;
  63 +}
  64 +
  65 +static inline const char *
  66 +scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
  67 +{
  68 + *fmt = NULL;
  69 + return NULL;
  70 +}
  71 +
  72 +static inline const char *
  73 +scsi_mlreturn_string(int result)
  74 +{
  75 + return NULL;
  76 +}
  77 +
  78 +static inline const char *
  79 +scsi_hostbyte_string(int result)
  80 +{
  81 + return NULL;
  82 +}
  83 +
  84 +static inline const char *
  85 +scsi_driverbyte_string(int result)
  86 +{
  87 + return NULL;
  88 +}
  89 +
  90 +#endif
31 91  
32 92 #endif /* _SCSI_SCSI_DBG_H */