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

[SCSI] arcmsr: simplify some double loops in sleeping functions

I removed outer loops in ...wait_msgint_ready the sleeptime and
retrycount are in fact never changed so I changed them into
defines. In arcmsr_flush_hba_cache is a loop removed, which printed
the same printk 100 times, one line in log is enough I think. The
arcmsr_sleep_for_bus_reset has lost a functionality with the latest
patches, The only thing the function does is a long sleep, so it's
replaced with a ssleep.

[jejb: checkpatch fixes]
Signed-off-by: Tomas henzl <thenzl@redhat.com>
Acked-by: Nick Cheng <nick.cheng@areca.com.tw>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

authored by

Tomas Henzl and committed by
James Bottomley
8b7eb86f 134a4e27

+52 -74
+52 -74
drivers/scsi/arcmsr/arcmsr_hba.c
··· 75 75 MODULE_DESCRIPTION("ARECA (ARC11xx/12xx/16xx/1880) SATA/SAS RAID Host Bus Adapter"); 76 76 MODULE_LICENSE("Dual BSD/GPL"); 77 77 MODULE_VERSION(ARCMSR_DRIVER_VERSION); 78 - static int sleeptime = 10; 79 - static int retrycount = 12; 78 + 79 + #define ARCMSR_SLEEPTIME 10 80 + #define ARCMSR_RETRYCOUNT 12 81 + 80 82 wait_queue_head_t wait_q; 81 83 static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, 82 84 struct scsi_cmnd *cmd); ··· 173 171 **************************************************************************** 174 172 **************************************************************************** 175 173 */ 176 - int arcmsr_sleep_for_bus_reset(struct scsi_cmnd *cmd) 177 - { 178 - struct Scsi_Host *shost = NULL; 179 - int i, isleep; 180 - shost = cmd->device->host; 181 - isleep = sleeptime / 10; 182 - if (isleep > 0) { 183 - for (i = 0; i < isleep; i++) { 184 - msleep(10000); 185 - } 186 - } 187 - 188 - isleep = sleeptime % 10; 189 - if (isleep > 0) { 190 - msleep(isleep*1000); 191 - } 192 - return 0; 193 - } 194 174 195 175 static void arcmsr_free_hbb_mu(struct AdapterControlBlock *acb) 196 176 { ··· 307 323 308 324 default: acb->adapter_type = ACB_ADAPTER_TYPE_A; 309 325 } 310 - } 326 + } 311 327 312 328 static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb) 313 329 { 314 330 struct MessageUnit_A __iomem *reg = acb->pmuA; 315 - uint32_t Index; 316 - uint8_t Retries = 0x00; 317 - do { 318 - for (Index = 0; Index < 100; Index++) { 319 - if (readl(&reg->outbound_intstatus) & 320 - ARCMSR_MU_OUTBOUND_MESSAGE0_INT) { 321 - writel(ARCMSR_MU_OUTBOUND_MESSAGE0_INT, 322 - &reg->outbound_intstatus); 323 - return true; 324 - } 325 - msleep(10); 326 - }/*max 1 seconds*/ 331 + int i; 327 332 328 - } while (Retries++ < 20);/*max 20 sec*/ 333 + for (i = 0; i < 2000; i++) { 334 + if (readl(&reg->outbound_intstatus) & 335 + ARCMSR_MU_OUTBOUND_MESSAGE0_INT) { 336 + writel(ARCMSR_MU_OUTBOUND_MESSAGE0_INT, 337 + &reg->outbound_intstatus); 338 + return true; 339 + } 340 + msleep(10); 341 + } /* max 20 seconds */ 342 + 329 343 return false; 330 344 } 331 345 332 346 static uint8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb) 333 347 { 334 348 struct MessageUnit_B *reg = acb->pmuB; 335 - uint32_t Index; 336 - uint8_t Retries = 0x00; 337 - do { 338 - for (Index = 0; Index < 100; Index++) { 339 - if (readl(reg->iop2drv_doorbell) 340 - & ARCMSR_IOP2DRV_MESSAGE_CMD_DONE) { 341 - writel(ARCMSR_MESSAGE_INT_CLEAR_PATTERN 342 - , reg->iop2drv_doorbell); 343 - writel(ARCMSR_DRV2IOP_END_OF_INTERRUPT, reg->drv2iop_doorbell); 344 - return true; 345 - } 346 - msleep(10); 347 - }/*max 1 seconds*/ 349 + int i; 348 350 349 - } while (Retries++ < 20);/*max 20 sec*/ 351 + for (i = 0; i < 2000; i++) { 352 + if (readl(reg->iop2drv_doorbell) 353 + & ARCMSR_IOP2DRV_MESSAGE_CMD_DONE) { 354 + writel(ARCMSR_MESSAGE_INT_CLEAR_PATTERN, 355 + reg->iop2drv_doorbell); 356 + writel(ARCMSR_DRV2IOP_END_OF_INTERRUPT, 357 + reg->drv2iop_doorbell); 358 + return true; 359 + } 360 + msleep(10); 361 + } /* max 20 seconds */ 362 + 350 363 return false; 351 364 } 352 365 353 366 static uint8_t arcmsr_hbc_wait_msgint_ready(struct AdapterControlBlock *pACB) 354 367 { 355 368 struct MessageUnit_C *phbcmu = (struct MessageUnit_C *)pACB->pmuC; 356 - unsigned char Retries = 0x00; 357 - uint32_t Index; 358 - do { 359 - for (Index = 0; Index < 100; Index++) { 360 - if (readl(&phbcmu->outbound_doorbell) & ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE) { 361 - writel(ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE_DOORBELL_CLEAR, &phbcmu->outbound_doorbell_clear);/*clear interrupt*/ 362 - return true; 363 - } 364 - /* one us delay */ 365 - msleep(10); 366 - } /*max 1 seconds*/ 367 - } while (Retries++ < 20); /*max 20 sec*/ 369 + int i; 370 + 371 + for (i = 0; i < 2000; i++) { 372 + if (readl(&phbcmu->outbound_doorbell) 373 + & ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE) { 374 + writel(ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE_DOORBELL_CLEAR, 375 + &phbcmu->outbound_doorbell_clear); /*clear interrupt*/ 376 + return true; 377 + } 378 + msleep(10); 379 + } /* max 20 seconds */ 380 + 368 381 return false; 369 382 } 383 + 370 384 static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb) 371 385 { 372 386 struct MessageUnit_A __iomem *reg = acb->pmuA; ··· 2584 2602 if (cdb_phyaddr_hi32 != 0) { 2585 2603 struct MessageUnit_C *reg = (struct MessageUnit_C *)acb->pmuC; 2586 2604 2587 - if (cdb_phyaddr_hi32 != 0) { 2588 - unsigned char Retries = 0x00; 2589 - do { 2590 - printk(KERN_NOTICE "arcmsr%d: cdb_phyaddr_hi32=0x%x \n", acb->adapter_index, cdb_phyaddr_hi32); 2591 - } while (Retries++ < 100); 2592 - } 2605 + printk(KERN_NOTICE "arcmsr%d: cdb_phyaddr_hi32=0x%x\n", 2606 + acb->adapter_index, cdb_phyaddr_hi32); 2593 2607 writel(ARCMSR_SIGNATURE_SET_CONFIG, &reg->msgcode_rwbuffer[0]); 2594 2608 writel(cdb_phyaddr_hi32, &reg->msgcode_rwbuffer[1]); 2595 2609 writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, &reg->inbound_msgaddr0); ··· 2933 2955 arcmsr_hardware_reset(acb); 2934 2956 acb->acb_flags &= ~ACB_F_IOP_INITED; 2935 2957 sleep_again: 2936 - arcmsr_sleep_for_bus_reset(cmd); 2958 + ssleep(ARCMSR_SLEEPTIME); 2937 2959 if ((readl(&reg->outbound_msgaddr1) & ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK) == 0) { 2938 - printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, retry=%d \n", acb->host->host_no, retry_count); 2939 - if (retry_count > retrycount) { 2960 + printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, retry=%d\n", acb->host->host_no, retry_count); 2961 + if (retry_count > ARCMSR_RETRYCOUNT) { 2940 2962 acb->fw_flag = FW_DEADLOCK; 2941 - printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, RETRY TERMINATED!! \n", acb->host->host_no); 2963 + printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, RETRY TERMINATED!!\n", acb->host->host_no); 2942 2964 return FAILED; 2943 2965 } 2944 2966 retry_count++; ··· 3003 3025 arcmsr_hardware_reset(acb); 3004 3026 acb->acb_flags &= ~ACB_F_IOP_INITED; 3005 3027 sleep: 3006 - arcmsr_sleep_for_bus_reset(cmd); 3028 + ssleep(ARCMSR_SLEEPTIME); 3007 3029 if ((readl(&reg->host_diagnostic) & 0x04) != 0) { 3008 - printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, retry=%d \n", acb->host->host_no, retry_count); 3009 - if (retry_count > retrycount) { 3030 + printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, retry=%d\n", acb->host->host_no, retry_count); 3031 + if (retry_count > ARCMSR_RETRYCOUNT) { 3010 3032 acb->fw_flag = FW_DEADLOCK; 3011 - printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, RETRY TERMINATED!! \n", acb->host->host_no); 3033 + printk(KERN_ERR "arcmsr%d: waiting for hw bus reset return, RETRY TERMINATED!!\n", acb->host->host_no); 3012 3034 return FAILED; 3013 3035 } 3014 3036 retry_count++;