aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/constants.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@nuerscht.ch>2006-06-09 01:23:48 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-06-10 11:45:30 -0400
commit6391a11375de5e2bb1eb8481e54619761dc65d9f (patch)
tree956aae1d278a3f731b2e6148ff40a69aa7957ea8 /drivers/scsi/constants.c
parent9dc399de0840a478adb71278becf598d3ab3aacc (diff)
[SCSI] drivers/scsi: Use ARRAY_SIZE macro
Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove duplicates of the macro. Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/constants.c')
-rw-r--r--drivers/scsi/constants.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 30a335349cee..e24835b38b54 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -114,8 +114,7 @@ static const struct value_name_pair maint_in_arr[] = {
114 {0xd, "Report supported task management functions"}, 114 {0xd, "Report supported task management functions"},
115 {0xe, "Report priority"}, 115 {0xe, "Report priority"},
116}; 116};
117#define MAINT_IN_SZ \ 117#define MAINT_IN_SZ ARRAY_SIZE(maint_in_arr)
118 (int)(sizeof(maint_in_arr) / sizeof(maint_in_arr[0]))
119 118
120static const struct value_name_pair maint_out_arr[] = { 119static const struct value_name_pair maint_out_arr[] = {
121 {0x6, "Set device identifier"}, 120 {0x6, "Set device identifier"},
@@ -123,34 +122,29 @@ static const struct value_name_pair maint_out_arr[] = {
123 {0xb, "Change aliases"}, 122 {0xb, "Change aliases"},
124 {0xe, "Set priority"}, 123 {0xe, "Set priority"},
125}; 124};
126#define MAINT_OUT_SZ \ 125#define MAINT_OUT_SZ ARRAY_SIZE(maint_out_arr)
127 (int)(sizeof(maint_out_arr) / sizeof(maint_out_arr[0]))
128 126
129static const struct value_name_pair serv_in12_arr[] = { 127static const struct value_name_pair serv_in12_arr[] = {
130 {0x1, "Read media serial number"}, 128 {0x1, "Read media serial number"},
131}; 129};
132#define SERV_IN12_SZ \ 130#define SERV_IN12_SZ ARRAY_SIZE(serv_in12_arr)
133 (int)(sizeof(serv_in12_arr) / sizeof(serv_in12_arr[0]))
134 131
135static const struct value_name_pair serv_out12_arr[] = { 132static const struct value_name_pair serv_out12_arr[] = {
136 {-1, "dummy entry"}, 133 {-1, "dummy entry"},
137}; 134};
138#define SERV_OUT12_SZ \ 135#define SERV_OUT12_SZ ARRAY_SIZE(serv_out12_arr)
139 (int)(sizeof(serv_out12_arr) / sizeof(serv_in12_arr[0]))
140 136
141static const struct value_name_pair serv_in16_arr[] = { 137static const struct value_name_pair serv_in16_arr[] = {
142 {0x10, "Read capacity(16)"}, 138 {0x10, "Read capacity(16)"},
143 {0x11, "Read long(16)"}, 139 {0x11, "Read long(16)"},
144}; 140};
145#define SERV_IN16_SZ \ 141#define SERV_IN16_SZ ARRAY_SIZE(serv_in16_arr)
146 (int)(sizeof(serv_in16_arr) / sizeof(serv_in16_arr[0]))
147 142
148static const struct value_name_pair serv_out16_arr[] = { 143static const struct value_name_pair serv_out16_arr[] = {
149 {0x11, "Write long(16)"}, 144 {0x11, "Write long(16)"},
150 {0x1f, "Notify data transfer device(16)"}, 145 {0x1f, "Notify data transfer device(16)"},
151}; 146};
152#define SERV_OUT16_SZ \ 147#define SERV_OUT16_SZ ARRAY_SIZE(serv_out16_arr)
153 (int)(sizeof(serv_out16_arr) / sizeof(serv_in16_arr[0]))
154 148
155static const struct value_name_pair variable_length_arr[] = { 149static const struct value_name_pair variable_length_arr[] = {
156 {0x1, "Rebuild(32)"}, 150 {0x1, "Rebuild(32)"},
@@ -190,8 +184,7 @@ static const struct value_name_pair variable_length_arr[] = {
190 {0x8f7e, "Perform SCSI command (osd)"}, 184 {0x8f7e, "Perform SCSI command (osd)"},
191 {0x8f7f, "Perform task management function (osd)"}, 185 {0x8f7f, "Perform task management function (osd)"},
192}; 186};
193#define VARIABLE_LENGTH_SZ \ 187#define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
194 (int)(sizeof(variable_length_arr) / sizeof(variable_length_arr[0]))
195 188
196static const char * get_sa_name(const struct value_name_pair * arr, 189static const char * get_sa_name(const struct value_name_pair * arr,
197 int arr_sz, int service_action) 190 int arr_sz, int service_action)
@@ -1290,10 +1283,10 @@ EXPORT_SYMBOL(scsi_print_command);
1290#ifdef CONFIG_SCSI_CONSTANTS 1283#ifdef CONFIG_SCSI_CONSTANTS
1291 1284
1292static const char * const hostbyte_table[]={ 1285static const char * const hostbyte_table[]={
1293"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", 1286"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
1294"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", 1287"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
1295"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; 1288"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
1296#define NUM_HOSTBYTE_STRS (sizeof(hostbyte_table) / sizeof(const char *)) 1289#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
1297 1290
1298void scsi_print_hostbyte(int scsiresult) 1291void scsi_print_hostbyte(int scsiresult)
1299{ 1292{
@@ -1303,7 +1296,7 @@ void scsi_print_hostbyte(int scsiresult)
1303 if (hb < NUM_HOSTBYTE_STRS) 1296 if (hb < NUM_HOSTBYTE_STRS)
1304 printk("(%s) ", hostbyte_table[hb]); 1297 printk("(%s) ", hostbyte_table[hb]);
1305 else 1298 else
1306 printk("is invalid "); 1299 printk("is invalid ");
1307} 1300}
1308#else 1301#else
1309void scsi_print_hostbyte(int scsiresult) 1302void scsi_print_hostbyte(int scsiresult)
@@ -1315,14 +1308,14 @@ void scsi_print_hostbyte(int scsiresult)
1315#ifdef CONFIG_SCSI_CONSTANTS 1308#ifdef CONFIG_SCSI_CONSTANTS
1316 1309
1317static const char * const driverbyte_table[]={ 1310static const char * const driverbyte_table[]={
1318"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 1311"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1319"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 1312"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
1320#define NUM_DRIVERBYTE_STRS (sizeof(driverbyte_table) / sizeof(const char *)) 1313#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table)
1321 1314
1322static const char * const driversuggest_table[]={"SUGGEST_OK", 1315static const char * const driversuggest_table[]={"SUGGEST_OK",
1323"SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", 1316"SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
1324"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; 1317"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
1325#define NUM_SUGGEST_STRS (sizeof(driversuggest_table) / sizeof(const char *)) 1318#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table)
1326 1319
1327void scsi_print_driverbyte(int scsiresult) 1320void scsi_print_driverbyte(int scsiresult)
1328{ 1321{