Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hannes Reinecke and committed by
Christoph Hellwig
2dd951ec 026f8da8

+69 -52
+2 -2
drivers/scsi/Kconfig
··· 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"
+2 -2
drivers/scsi/Makefile
··· 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
-44
drivers/scsi/constants.c
··· 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 ··· 33 35 const char * name; 34 36 }; 35 37 36 - #ifdef CONFIG_SCSI_CONSTANTS 37 38 static const char * cdb_byte0_names[] = { 38 39 /* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense", 39 40 /* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, ··· 256 259 {0, NULL, 0}, 257 260 }; 258 261 259 - #else /* ifndef CONFIG_SCSI_CONSTANTS */ 260 - static const char *cdb_byte0_names[0]; 261 - 262 - static struct sa_name_list sa_names_arr[] = { 263 - {VARIABLE_LENGTH_CMD, NULL, 0}, 264 - {MAINTENANCE_IN, NULL, 0}, 265 - {MAINTENANCE_OUT, NULL, 0}, 266 - {PERSISTENT_RESERVE_IN, NULL, 0}, 267 - {PERSISTENT_RESERVE_OUT, NULL, 0}, 268 - {SERVICE_ACTION_IN_12, NULL, 0}, 269 - {SERVICE_ACTION_OUT_12, NULL, 0}, 270 - {SERVICE_ACTION_BIDIRECTIONAL, NULL, 0}, 271 - {SERVICE_ACTION_IN_16, NULL, 0}, 272 - {SERVICE_ACTION_OUT_16, NULL, 0}, 273 - {THIRD_PARTY_COPY_IN, NULL, 0}, 274 - {THIRD_PARTY_COPY_OUT, NULL, 0}, 275 - {0, NULL, 0}, 276 - }; 277 - #endif /* CONFIG_SCSI_CONSTANTS */ 278 - 279 262 bool scsi_opcode_sa_name(int opcode, int service_action, 280 263 const char **cdb_name, const char **sa_name) 281 264 { ··· 289 312 290 313 return true; 291 314 } 292 - 293 - #ifdef CONFIG_SCSI_CONSTANTS 294 315 295 316 struct error_info { 296 317 unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */ ··· 1178 1203 "Completed", /* F: command completed sense data reported, 1179 1204 may occur for successful command */ 1180 1205 }; 1181 - #endif 1182 1206 1183 1207 /* Get sense key string or NULL if not available */ 1184 1208 const char * 1185 1209 scsi_sense_key_string(unsigned char key) { 1186 - #ifdef CONFIG_SCSI_CONSTANTS 1187 1210 if (key <= 0xE) 1188 1211 return snstext[key]; 1189 - #endif 1190 1212 return NULL; 1191 1213 } 1192 1214 EXPORT_SYMBOL(scsi_sense_key_string); ··· 1195 1223 const char * 1196 1224 scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt) 1197 1225 { 1198 - #ifdef CONFIG_SCSI_CONSTANTS 1199 1226 int i; 1200 1227 unsigned short code = ((asc << 8) | ascq); 1201 1228 ··· 1210 1239 return additional2[i].str; 1211 1240 } 1212 1241 } 1213 - #else 1214 - *fmt = NULL; 1215 - #endif 1216 1242 return NULL; 1217 1243 } 1218 1244 EXPORT_SYMBOL(scsi_extd_sense_format); 1219 - 1220 - #ifdef CONFIG_SCSI_CONSTANTS 1221 1245 1222 1246 static const char * const hostbyte_table[]={ 1223 1247 "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", ··· 1225 1259 "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 1226 1260 "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 1227 1261 1228 - #endif 1229 - 1230 1262 const char *scsi_hostbyte_string(int result) 1231 1263 { 1232 1264 const char *hb_string = NULL; 1233 - #ifdef CONFIG_SCSI_CONSTANTS 1234 1265 int hb = host_byte(result); 1235 1266 1236 1267 if (hb < ARRAY_SIZE(hostbyte_table)) 1237 1268 hb_string = hostbyte_table[hb]; 1238 - #endif 1239 1269 return hb_string; 1240 1270 } 1241 1271 EXPORT_SYMBOL(scsi_hostbyte_string); ··· 1239 1277 const char *scsi_driverbyte_string(int result) 1240 1278 { 1241 1279 const char *db_string = NULL; 1242 - #ifdef CONFIG_SCSI_CONSTANTS 1243 1280 int db = driver_byte(result); 1244 1281 1245 1282 if (db < ARRAY_SIZE(driverbyte_table)) 1246 1283 db_string = driverbyte_table[db]; 1247 - #endif 1248 1284 return db_string; 1249 1285 } 1250 1286 EXPORT_SYMBOL(scsi_driverbyte_string); 1251 1287 1252 - #ifdef CONFIG_SCSI_CONSTANTS 1253 1288 #define scsi_mlreturn_name(result) { result, #result } 1254 1289 static const struct value_name_pair scsi_mlreturn_arr[] = { 1255 1290 scsi_mlreturn_name(NEEDS_RETRY), ··· 1259 1300 scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED), 1260 1301 scsi_mlreturn_name(FAST_IO_FAIL) 1261 1302 }; 1262 - #endif 1263 1303 1264 1304 const char *scsi_mlreturn_string(int result) 1265 1305 { 1266 - #ifdef CONFIG_SCSI_CONSTANTS 1267 1306 const struct value_name_pair *arr = scsi_mlreturn_arr; 1268 1307 int k; 1269 1308 ··· 1269 1312 if (result == arr->value) 1270 1313 return arr->name; 1271 1314 } 1272 - #endif 1273 1315 return NULL; 1274 1316 } 1275 1317 EXPORT_SYMBOL(scsi_mlreturn_string);
+1
drivers/xen/xen-scsiback.c
··· 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>
+64 -4
include/scsi/scsi_dbg.h
··· 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); ··· 21 22 const unsigned char *sense_buffer, 22 23 int sense_len); 23 24 extern void scsi_print_result(const struct scsi_cmnd *, const char *, int); 24 - extern const char *scsi_hostbyte_string(int); 25 - extern const char *scsi_driverbyte_string(int); 26 - extern const char *scsi_mlreturn_string(int); 25 + 26 + #ifdef CONFIG_SCSI_CONSTANTS 27 + extern bool scsi_opcode_sa_name(int, int, const char **, const char **); 27 28 extern const char *scsi_sense_key_string(unsigned char); 28 29 extern const char *scsi_extd_sense_format(unsigned char, unsigned char, 29 30 const char **); 31 + extern const char *scsi_mlreturn_string(int); 32 + extern const char *scsi_hostbyte_string(int); 33 + extern const char *scsi_driverbyte_string(int); 34 + #else 35 + static inline bool 36 + scsi_opcode_sa_name(int cmd, int sa, 37 + const char **cdb_name, const char **sa_name) 38 + { 39 + *cdb_name = NULL; 40 + switch (cmd) { 41 + case VARIABLE_LENGTH_CMD: 42 + case MAINTENANCE_IN: 43 + case MAINTENANCE_OUT: 44 + case PERSISTENT_RESERVE_IN: 45 + case PERSISTENT_RESERVE_OUT: 46 + case SERVICE_ACTION_IN_12: 47 + case SERVICE_ACTION_OUT_12: 48 + case SERVICE_ACTION_BIDIRECTIONAL: 49 + case SERVICE_ACTION_IN_16: 50 + case SERVICE_ACTION_OUT_16: 51 + case EXTENDED_COPY: 52 + case RECEIVE_COPY_RESULTS: 53 + *sa_name = NULL; 54 + return true; 55 + default: 56 + return false; 57 + } 58 + } 59 + 60 + static inline const char * 61 + scsi_sense_key_string(unsigned char key) 62 + { 63 + return NULL; 64 + } 65 + 66 + static inline const char * 67 + scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt) 68 + { 69 + *fmt = NULL; 70 + return NULL; 71 + } 72 + 73 + static inline const char * 74 + scsi_mlreturn_string(int result) 75 + { 76 + return NULL; 77 + } 78 + 79 + static inline const char * 80 + scsi_hostbyte_string(int result) 81 + { 82 + return NULL; 83 + } 84 + 85 + static inline const char * 86 + scsi_driverbyte_string(int result) 87 + { 88 + return NULL; 89 + } 90 + 91 + #endif 30 92 31 93 #endif /* _SCSI_SCSI_DBG_H */