diff options
author | Christoph Hellwig <hch@lst.de> | 2018-10-11 16:17:13 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-10-17 21:34:20 -0400 |
commit | cd29660dc8675ec235db23e38435fad833158e1c (patch) | |
tree | 7e43624c93a3ec6b9044e981486730910e196b41 | |
parent | 77266186397c6c782a3f670d32808a9671806ec5 (diff) | |
download | linux-cd29660dc8675ec235db23e38435fad833158e1c.tar.gz linux-cd29660dc8675ec235db23e38435fad833158e1c.tar.bz2 linux-cd29660dc8675ec235db23e38435fad833158e1c.zip |
scsi: dc395x: simplify list handling
Remove the list wrappers, including the pointless list iteration before
deletion.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/dc395x.c | 152 |
1 files changed, 26 insertions, 126 deletions
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 1ed2cd82129d..8705730b2e5a 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -753,105 +753,6 @@ static inline struct ScsiReqBlk *find_cmd(struct scsi_cmnd *cmd, return NULL; } - -static struct ScsiReqBlk *srb_get_free(struct AdapterCtlBlk *acb) -{ - struct list_head *head = &acb->srb_free_list; - struct ScsiReqBlk *srb = NULL; - - if (!list_empty(head)) { - srb = list_entry(head->next, struct ScsiReqBlk, list); - list_del(head->next); - dprintkdbg(DBG_0, "srb_get_free: srb=%p\n", srb); - } - return srb; -} - - -static void srb_free_insert(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb) -{ - dprintkdbg(DBG_0, "srb_free_insert: srb=%p\n", srb); - list_add_tail(&srb->list, &acb->srb_free_list); -} - - -static void srb_waiting_insert(struct DeviceCtlBlk *dcb, - struct ScsiReqBlk *srb) -{ - dprintkdbg(DBG_0, "srb_waiting_insert: (0x%p) <%02i-%i> srb=%p\n", - srb->cmd, dcb->target_id, dcb->target_lun, srb); - list_add(&srb->list, &dcb->srb_waiting_list); -} - - -static void srb_waiting_append(struct DeviceCtlBlk *dcb, - struct ScsiReqBlk *srb) -{ - dprintkdbg(DBG_0, "srb_waiting_append: (0x%p) <%02i-%i> srb=%p\n", - srb->cmd, dcb->target_id, dcb->target_lun, srb); - list_add_tail(&srb->list, &dcb->srb_waiting_list); -} - - -static void srb_going_append(struct DeviceCtlBlk *dcb, struct ScsiReqBlk *srb) -{ - dprintkdbg(DBG_0, "srb_going_append: (0x%p) <%02i-%i> srb=%p\n", - srb->cmd, dcb->target_id, dcb->target_lun, srb); - list_add_tail(&srb->list, &dcb->srb_going_list); -} - - -static void srb_going_remove(struct DeviceCtlBlk *dcb, struct ScsiReqBlk *srb) -{ - struct ScsiReqBlk *i; - struct ScsiReqBlk *tmp; - dprintkdbg(DBG_0, "srb_going_remove: (0x%p) <%02i-%i> srb=%p\n", - srb->cmd, dcb->target_id, dcb->target_lun, srb); - - list_for_each_entry_safe(i, tmp, &dcb->srb_going_list, list) - if (i == srb) { - list_del(&srb->list); - break; - } -} - - -static void srb_waiting_remove(struct DeviceCtlBlk *dcb, - struct ScsiReqBlk *srb) -{ - struct ScsiReqBlk *i; - struct ScsiReqBlk *tmp; - dprintkdbg(DBG_0, "srb_waiting_remove: (0x%p) <%02i-%i> srb=%p\n", - srb->cmd, dcb->target_id, dcb->target_lun, srb); - - list_for_each_entry_safe(i, tmp, &dcb->srb_waiting_list, list) - if (i == srb) { - list_del(&srb->list); - break; - } -} - - -static void srb_going_to_waiting_move(struct DeviceCtlBlk *dcb, - struct ScsiReqBlk *srb) -{ - dprintkdbg(DBG_0, - "srb_going_to_waiting_move: (0x%p) <%02i-%i> srb=%p\n", - srb->cmd, dcb->target_id, dcb->target_lun, srb); - list_move(&srb->list, &dcb->srb_waiting_list); -} - - -static void srb_waiting_to_going_move(struct DeviceCtlBlk *dcb, - struct ScsiReqBlk *srb) -{ - dprintkdbg(DBG_0, - "srb_waiting_to_going_move: (0x%p) <%02i-%i> srb=%p\n", - srb->cmd, dcb->target_id, dcb->target_lun, srb); - list_move(&srb->list, &dcb->srb_going_list); -} - - /* Sets the timer to wake us up */ static void waiting_set_timer(struct AdapterCtlBlk *acb, unsigned long to) { @@ -923,7 +824,7 @@ static void waiting_process_next(struct AdapterCtlBlk *acb) /* Try to send to the bus */ if (!start_scsi(acb, pos, srb)) - srb_waiting_to_going_move(pos, srb); + list_move(&srb->list, &pos->srb_going_list); else waiting_set_timer(acb, HZ/50); break; @@ -960,15 +861,15 @@ static void send_srb(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb) if (dcb->max_command <= list_size(&dcb->srb_going_list) || acb->active_dcb || (acb->acb_flag & (RESET_DETECT + RESET_DONE + RESET_DEV))) { - srb_waiting_append(dcb, srb); + list_add_tail(&srb->list, &dcb->srb_waiting_list); waiting_process_next(acb); return; } - if (!start_scsi(acb, dcb, srb)) - srb_going_append(dcb, srb); - else { - srb_waiting_insert(dcb, srb); + if (!start_scsi(acb, dcb, srb)) { + list_add_tail(&srb->list, &dcb->srb_going_list); + } else { + list_add(&srb->list, &dcb->srb_waiting_list); waiting_set_timer(acb, HZ / 50); } } @@ -1116,9 +1017,9 @@ static int dc395x_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct s cmd->scsi_done = done; cmd->result = 0; - srb = srb_get_free(acb); - if (!srb) - { + srb = list_first_entry_or_null(&acb->srb_free_list, + struct ScsiReqBlk, list); + if (!srb) { /* * Return 1 since we are unable to queue this command at this * point in time. @@ -1126,12 +1027,13 @@ static int dc395x_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct s dprintkdbg(DBG_0, "queue_command: No free srb's\n"); return 1; } + list_del(&srb->list); build_srb(cmd, dcb, srb); if (!list_empty(&dcb->srb_waiting_list)) { /* append to waiting queue */ - srb_waiting_append(dcb, srb); + list_add_tail(&srb->list, &dcb->srb_waiting_list); waiting_process_next(acb); } else { /* process immediately */ @@ -1376,11 +1278,11 @@ static int dc395x_eh_abort(struct scsi_cmnd *cmd) srb = find_cmd(cmd, &dcb->srb_waiting_list); if (srb) { - srb_waiting_remove(dcb, srb); + list_del(&srb->list); pci_unmap_srb_sense(acb, srb); pci_unmap_srb(acb, srb); free_tag(dcb, srb); - srb_free_insert(acb, srb); + list_add_tail(&srb->list, &acb->srb_free_list); dprintkl(KERN_DEBUG, "eh_abort: Command was waiting\n"); cmd->result = DID_ABORT << 16; return SUCCESS; @@ -3083,7 +2985,7 @@ static void disconnect(struct AdapterCtlBlk *acb) goto disc1; } free_tag(dcb, srb); - srb_going_to_waiting_move(dcb, srb); + list_move(&srb->list, &dcb->srb_waiting_list); dprintkdbg(DBG_KG, "disconnect: (0x%p) Retry\n", srb->cmd); @@ -3148,7 +3050,7 @@ static void reselect(struct AdapterCtlBlk *acb) srb->state = SRB_READY; free_tag(dcb, srb); - srb_going_to_waiting_move(dcb, srb); + list_move(&srb->list, &dcb->srb_waiting_list); waiting_set_timer(acb, HZ / 20); /* return; */ @@ -3411,7 +3313,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, tempcnt--; dcb->max_command = tempcnt; free_tag(dcb, srb); - srb_going_to_waiting_move(dcb, srb); + list_move(&srb->list, &dcb->srb_waiting_list); waiting_set_timer(acb, HZ / 20); srb->adapter_status = 0; srb->target_status = 0; @@ -3498,14 +3400,13 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, cmd->cmnd[0], srb->total_xfer_length); } - srb_going_remove(dcb, srb); - /* Add to free list */ - if (srb == acb->tmp_srb) - dprintkl(KERN_ERR, "srb_done: ERROR! Completed cmd with tmp_srb\n"); - else { + if (srb != acb->tmp_srb) { + /* Add to free list */ dprintkdbg(DBG_0, "srb_done: (0x%p) done result=0x%08x\n", cmd, cmd->result); - srb_free_insert(acb, srb); + list_move_tail(&srb->list, &acb->srb_free_list); + } else { + dprintkl(KERN_ERR, "srb_done: ERROR! Completed cmd with tmp_srb\n"); } pci_unmap_srb(acb, srb); @@ -3535,9 +3436,9 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag, result = MK_RES(0, did_flag, 0, 0); printk("G:%p(%02i-%i) ", p, p->device->id, (u8)p->device->lun); - srb_going_remove(dcb, srb); + list_del(&srb->list); free_tag(dcb, srb); - srb_free_insert(acb, srb); + list_add_tail(&srb->list, &acb->srb_free_list); p->result = result; pci_unmap_srb_sense(acb, srb); pci_unmap_srb(acb, srb); @@ -3565,8 +3466,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag, result = MK_RES(0, did_flag, 0, 0); printk("W:%p<%02i-%i>", p, p->device->id, (u8)p->device->lun); - srb_waiting_remove(dcb, srb); - srb_free_insert(acb, srb); + list_move_tail(&srb->list, &acb->srb_free_list); p->result = result; pci_unmap_srb_sense(acb, srb); pci_unmap_srb(acb, srb); @@ -3705,7 +3605,7 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, dprintkl(KERN_DEBUG, "request_sense: (0x%p) failed <%02i-%i>\n", srb->cmd, dcb->target_id, dcb->target_lun); - srb_going_to_waiting_move(dcb, srb); + list_move(&srb->list, &dcb->srb_waiting_list); waiting_set_timer(acb, HZ / 100); } } @@ -4392,7 +4292,7 @@ static void adapter_init_params(struct AdapterCtlBlk *acb) /* link static array of srbs into the srb free list */ for (i = 0; i < acb->srb_count - 1; i++) - srb_free_insert(acb, &acb->srb_array[i]); + list_add_tail(&acb->srb_array[i].list, &acb->srb_free_list); } |