Reduce sequential pointer derefs in scsi_error.c and reduce size as well

This patch reduces the number of sequential pointer derefs in
drivers/scsi/scsi_error.c

This has been submitted a number of times over a couple of years. I
believe this version adresses all comments it has gathered over time.
Please apply or reject with a reason.

The benefits are:

- makes the code easier to read. Lots of sequential derefs of the same
pointers is not easy on the eye.

- theoretically at least, just dereferencing the pointers once can
allow the compiler to generally slightly faster code, so in theory
this could also be a micro speed optimization.

- reduces size of object file (tiny effect: on x86-64, in at least one
configuration, the text size decreased from 9439 bytes to 9400)

- removes some pointless (mostly trailing) whitespace.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Jesper Juhl and committed by Linus Torvalds 0bf8c869 38f7aa23

+49 -45
+49 -45
drivers/scsi/scsi_error.c
··· 3 3 * 4 4 * SCSI error/timeout handling 5 5 * Initial versions: Eric Youngdale. Based upon conversations with 6 - * Leonard Zubkoff and David Miller at Linux Expo, 6 + * Leonard Zubkoff and David Miller at Linux Expo, 7 7 * ideas originating from all over the place. 8 8 * 9 9 * Restructured scsi_unjam_host and associated functions. 10 10 * September 04, 2002 Mike Anderson (andmike@us.ibm.com) 11 11 * 12 12 * Forward port of Russell King's (rmk@arm.linux.org.uk) changes and 13 - * minor cleanups. 13 + * minor cleanups. 14 14 * September 30, 2002 Mike Anderson (andmike@us.ibm.com) 15 15 */ 16 16 ··· 129 129 { 130 130 struct scsi_cmnd *scmd = req->special; 131 131 enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; 132 + struct Scsi_Host *host = scmd->device->host; 132 133 133 134 trace_scsi_dispatch_cmd_timeout(scmd); 134 135 scsi_log_completion(scmd, TIMEOUT_ERROR); 135 136 136 - if (scmd->device->host->transportt->eh_timed_out) 137 - rtn = scmd->device->host->transportt->eh_timed_out(scmd); 138 - else if (scmd->device->host->hostt->eh_timed_out) 139 - rtn = scmd->device->host->hostt->eh_timed_out(scmd); 137 + if (host->transportt->eh_timed_out) 138 + rtn = host->transportt->eh_timed_out(scmd); 139 + else if (host->hostt->eh_timed_out) 140 + rtn = host->hostt->eh_timed_out(scmd); 140 141 141 142 if (unlikely(rtn == BLK_EH_NOT_HANDLED && 142 143 !scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) { ··· 196 195 ++total_failures; 197 196 if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) 198 197 ++cmd_cancel; 199 - else 198 + else 200 199 ++cmd_failed; 201 200 } 202 201 } ··· 215 214 216 215 SCSI_LOG_ERROR_RECOVERY(2, printk("Total of %d commands on %d" 217 216 " devices require eh work\n", 218 - total_failures, devices_failed)); 217 + total_failures, devices_failed)); 219 218 } 220 219 #endif 221 220 ··· 295 294 return NEEDS_RETRY; 296 295 } 297 296 /* 298 - * if the device is in the process of becoming ready, we 297 + * if the device is in the process of becoming ready, we 299 298 * should retry. 300 299 */ 301 300 if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01)) ··· 489 488 */ 490 489 static void scsi_eh_done(struct scsi_cmnd *scmd) 491 490 { 492 - struct completion *eh_action; 491 + struct completion *eh_action; 493 492 494 493 SCSI_LOG_ERROR_RECOVERY(3, 495 494 printk("%s scmd: %p result: %x\n", ··· 508 507 { 509 508 unsigned long flags; 510 509 int rtn; 510 + struct Scsi_Host *host = scmd->device->host; 511 + struct scsi_host_template *hostt = host->hostt; 511 512 512 513 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n", 513 514 __func__)); 514 515 515 - if (!scmd->device->host->hostt->eh_host_reset_handler) 516 + if (!hostt->eh_host_reset_handler) 516 517 return FAILED; 517 518 518 - rtn = scmd->device->host->hostt->eh_host_reset_handler(scmd); 519 + rtn = hostt->eh_host_reset_handler(scmd); 519 520 520 521 if (rtn == SUCCESS) { 521 - if (!scmd->device->host->hostt->skip_settle_delay) 522 + if (!hostt->skip_settle_delay) 522 523 ssleep(HOST_RESET_SETTLE_TIME); 523 - spin_lock_irqsave(scmd->device->host->host_lock, flags); 524 - scsi_report_bus_reset(scmd->device->host, 525 - scmd_channel(scmd)); 526 - spin_unlock_irqrestore(scmd->device->host->host_lock, flags); 524 + spin_lock_irqsave(host->host_lock, flags); 525 + scsi_report_bus_reset(host, scmd_channel(scmd)); 526 + spin_unlock_irqrestore(host->host_lock, flags); 527 527 } 528 528 529 529 return rtn; ··· 538 536 { 539 537 unsigned long flags; 540 538 int rtn; 539 + struct Scsi_Host *host = scmd->device->host; 540 + struct scsi_host_template *hostt = host->hostt; 541 541 542 542 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n", 543 543 __func__)); 544 544 545 - if (!scmd->device->host->hostt->eh_bus_reset_handler) 545 + if (!hostt->eh_bus_reset_handler) 546 546 return FAILED; 547 547 548 - rtn = scmd->device->host->hostt->eh_bus_reset_handler(scmd); 548 + rtn = hostt->eh_bus_reset_handler(scmd); 549 549 550 550 if (rtn == SUCCESS) { 551 - if (!scmd->device->host->hostt->skip_settle_delay) 551 + if (!hostt->skip_settle_delay) 552 552 ssleep(BUS_RESET_SETTLE_TIME); 553 - spin_lock_irqsave(scmd->device->host->host_lock, flags); 554 - scsi_report_bus_reset(scmd->device->host, 555 - scmd_channel(scmd)); 556 - spin_unlock_irqrestore(scmd->device->host->host_lock, flags); 553 + spin_lock_irqsave(host->host_lock, flags); 554 + scsi_report_bus_reset(host, scmd_channel(scmd)); 555 + spin_unlock_irqrestore(host->host_lock, flags); 557 556 } 558 557 559 558 return rtn; ··· 580 577 { 581 578 unsigned long flags; 582 579 int rtn; 580 + struct Scsi_Host *host = scmd->device->host; 581 + struct scsi_host_template *hostt = host->hostt; 583 582 584 - if (!scmd->device->host->hostt->eh_target_reset_handler) 583 + if (!hostt->eh_target_reset_handler) 585 584 return FAILED; 586 585 587 - rtn = scmd->device->host->hostt->eh_target_reset_handler(scmd); 586 + rtn = hostt->eh_target_reset_handler(scmd); 588 587 if (rtn == SUCCESS) { 589 - spin_lock_irqsave(scmd->device->host->host_lock, flags); 588 + spin_lock_irqsave(host->host_lock, flags); 590 589 __starget_for_each_device(scsi_target(scmd->device), NULL, 591 590 __scsi_report_device_reset); 592 - spin_unlock_irqrestore(scmd->device->host->host_lock, flags); 591 + spin_unlock_irqrestore(host->host_lock, flags); 593 592 } 594 593 595 594 return rtn; ··· 610 605 static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd) 611 606 { 612 607 int rtn; 608 + struct scsi_host_template *hostt = scmd->device->host->hostt; 613 609 614 - if (!scmd->device->host->hostt->eh_device_reset_handler) 610 + if (!hostt->eh_device_reset_handler) 615 611 return FAILED; 616 612 617 - rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd); 613 + rtn = hostt->eh_device_reset_handler(scmd); 618 614 if (rtn == SUCCESS) 619 615 __scsi_report_device_reset(scmd->device, NULL); 620 616 return rtn; 621 617 } 622 618 623 - static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd) 619 + static int scsi_try_to_abort_cmd(struct scsi_host_template *hostt, struct scsi_cmnd *scmd) 624 620 { 625 - if (!scmd->device->host->hostt->eh_abort_handler) 621 + if (!hostt->eh_abort_handler) 626 622 return FAILED; 627 623 628 - return scmd->device->host->hostt->eh_abort_handler(scmd); 624 + return hostt->eh_abort_handler(scmd); 629 625 } 630 626 631 627 static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) 632 628 { 633 - if (scsi_try_to_abort_cmd(scmd) != SUCCESS) 629 + if (scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd) != SUCCESS) 634 630 if (scsi_try_bus_device_reset(scmd) != SUCCESS) 635 631 if (scsi_try_target_reset(scmd) != SUCCESS) 636 632 if (scsi_try_bus_reset(scmd) != SUCCESS) ··· 852 846 * 853 847 * Description: 854 848 * See if we need to request sense information. if so, then get it 855 - * now, so we have a better idea of what to do. 849 + * now, so we have a better idea of what to do. 856 850 * 857 851 * Notes: 858 852 * This has the unfortunate side effect that if a shost adapter does ··· 964 958 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting cmd:" 965 959 "0x%p\n", current->comm, 966 960 scmd)); 967 - rtn = scsi_try_to_abort_cmd(scmd); 961 + rtn = scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd); 968 962 if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { 969 963 scmd->eh_eflags &= ~SCSI_EH_CANCEL_CMD; 970 964 if (!scsi_device_online(scmd->device) || ··· 972 966 !scsi_eh_tur(scmd)) { 973 967 scsi_eh_finish_cmd(scmd, done_q); 974 968 } 975 - 976 969 } else 977 970 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting" 978 971 " cmd failed:" ··· 1015 1010 * 1016 1011 * Notes: 1017 1012 * If commands are failing due to not ready, initializing command required, 1018 - * try revalidating the device, which will end up sending a start unit. 1013 + * try revalidating the device, which will end up sending a start unit. 1019 1014 */ 1020 1015 static int scsi_eh_stu(struct Scsi_Host *shost, 1021 1016 struct list_head *work_q, ··· 1069 1064 * Try a bus device reset. Still, look to see whether we have multiple 1070 1065 * devices that are jammed or not - if we have multiple devices, it 1071 1066 * makes no sense to try bus_device_reset - we really would need to try 1072 - * a bus_reset instead. 1067 + * a bus_reset instead. 1073 1068 */ 1074 1069 static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, 1075 1070 struct list_head *work_q, ··· 1169 1164 } 1170 1165 1171 1166 /** 1172 - * scsi_eh_bus_reset - send a bus reset 1167 + * scsi_eh_bus_reset - send a bus reset 1173 1168 * @shost: &scsi host being recovered. 1174 1169 * @work_q: &list_head for pending commands. 1175 1170 * @done_q: &list_head for processed commands. ··· 1186 1181 * we really want to loop over the various channels, and do this on 1187 1182 * a channel by channel basis. we should also check to see if any 1188 1183 * of the failed commands are on soft_reset devices, and if so, skip 1189 - * the reset. 1184 + * the reset. 1190 1185 */ 1191 1186 1192 1187 for (channel = 0; channel <= shost->max_channel; channel++) { ··· 1228 1223 } 1229 1224 1230 1225 /** 1231 - * scsi_eh_host_reset - send a host reset 1226 + * scsi_eh_host_reset - send a host reset 1232 1227 * @work_q: list_head for processed commands. 1233 1228 * @done_q: list_head for processed commands. 1234 1229 */ ··· 1381 1376 return SUCCESS; 1382 1377 /* 1383 1378 * when the low level driver returns did_soft_error, 1384 - * it is responsible for keeping an internal retry counter 1379 + * it is responsible for keeping an internal retry counter 1385 1380 * in order to avoid endless loops (db) 1386 1381 * 1387 1382 * actually this is a bug in this function here. we should ··· 1419 1414 */ 1420 1415 break; 1421 1416 /* fallthrough */ 1422 - 1423 1417 case DID_BUS_BUSY: 1424 1418 case DID_PARITY: 1425 1419 goto maybe_retry; ··· 1986 1982 if (sb_len > 7) 1987 1983 sshdr->additional_length = sense_buffer[7]; 1988 1984 } else { 1989 - /* 1985 + /* 1990 1986 * fixed format 1991 1987 */ 1992 1988 if (sb_len > 2)