]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/scsi_error.c
Merge master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6-omap-h63xx.git] / drivers / scsi / scsi_error.c
index 4f312da021f175c9e87d782c8ec8427f2f9df191..0fc8b48f052bf1fa8fcd02bd5b312ae7a34b1503 100644 (file)
@@ -73,7 +73,7 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
 
        spin_lock_irqsave(shost->host_lock, flags);
 
-       scsi_eh_eflags_set(scmd, eh_flag);
+       scmd->eh_eflags |= eh_flag;
        list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q);
        set_bit(SHOST_RECOVERY, &shost->shost_state);
        shost->host_failed++;
@@ -228,8 +228,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
                list_for_each_entry(scmd, work_q, eh_entry) {
                        if (scmd->device == sdev) {
                                ++total_failures;
-                               if (scsi_eh_eflags_chk(scmd,
-                                                      SCSI_EH_CANCEL_CMD))
+                               if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD)
                                        ++cmd_cancel;
                                else 
                                        ++cmd_failed;
@@ -425,7 +424,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
  **/
 static void scsi_eh_times_out(struct scsi_cmnd *scmd)
 {
-       scsi_eh_eflags_set(scmd, SCSI_EH_REC_TIMEOUT);
+       scmd->eh_eflags |= SCSI_EH_REC_TIMEOUT;
        SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd:%p\n", __FUNCTION__,
                                          scmd));
 
@@ -504,8 +503,8 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
         * see if timeout.  if so, tell the host to forget about it.
         * in other words, we don't want a callback any more.
         */
-       if (scsi_eh_eflags_chk(scmd, SCSI_EH_REC_TIMEOUT)) {
-               scsi_eh_eflags_clr(scmd,  SCSI_EH_REC_TIMEOUT);
+       if (scmd->eh_eflags & SCSI_EH_REC_TIMEOUT) {
+               scmd->eh_eflags &= ~SCSI_EH_REC_TIMEOUT;
 
                /*
                 * as far as the low level driver is
@@ -630,7 +629,7 @@ static void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
                               struct list_head *done_q)
 {
        scmd->device->host->host_failed--;
-       scsi_eh_eflags_clr_all(scmd);
+       scmd->eh_eflags = 0;
 
        /*
         * set this back so that the upper level can correctly free up
@@ -663,13 +662,11 @@ static void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
 static int scsi_eh_get_sense(struct list_head *work_q,
                             struct list_head *done_q)
 {
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd;
+       struct scsi_cmnd *scmd, *next;
        int rtn;
 
-       list_for_each_safe(lh, lh_sf, work_q) {
-               scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
-               if (scsi_eh_eflags_chk(scmd, SCSI_EH_CANCEL_CMD) ||
+       list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
+               if ((scmd->eh_eflags & SCSI_EH_CANCEL_CMD) ||
                    SCSI_SENSE_VALID(scmd))
                        continue;
 
@@ -799,20 +796,18 @@ retry_tur:
 static int scsi_eh_abort_cmds(struct list_head *work_q,
                              struct list_head *done_q)
 {
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd;
+       struct scsi_cmnd *scmd, *next;
        int rtn;
 
-       list_for_each_safe(lh, lh_sf, work_q) {
-               scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
-               if (!scsi_eh_eflags_chk(scmd, SCSI_EH_CANCEL_CMD))
+       list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
+               if (!(scmd->eh_eflags & SCSI_EH_CANCEL_CMD))
                        continue;
                SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting cmd:"
                                                  "0x%p\n", current->comm,
                                                  scmd));
                rtn = scsi_try_to_abort_cmd(scmd);
                if (rtn == SUCCESS) {
-                       scsi_eh_eflags_clr(scmd,  SCSI_EH_CANCEL_CMD);
+                       scmd->eh_eflags &= ~SCSI_EH_CANCEL_CMD;
                        if (!scsi_device_online(scmd->device) ||
                            !scsi_eh_tur(scmd)) {
                                scsi_eh_finish_cmd(scmd, done_q);
@@ -919,8 +914,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
                              struct list_head *work_q,
                              struct list_head *done_q)
 {
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd, *stu_scmd;
+       struct scsi_cmnd *scmd, *stu_scmd, *next;
        struct scsi_device *sdev;
 
        shost_for_each_device(sdev, shost) {
@@ -941,8 +935,8 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
                if (!scsi_eh_try_stu(stu_scmd)) {
                        if (!scsi_device_online(sdev) ||
                            !scsi_eh_tur(stu_scmd)) {
-                               list_for_each_safe(lh, lh_sf, work_q) {
-                                       scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
+                               list_for_each_entry_safe(scmd, next,
+                                                         work_q, eh_entry) {
                                        if (scmd->device == sdev)
                                                scsi_eh_finish_cmd(scmd, done_q);
                                }
@@ -973,8 +967,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
                                    struct list_head *work_q,
                                    struct list_head *done_q)
 {
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd, *bdr_scmd;
+       struct scsi_cmnd *scmd, *bdr_scmd, *next;
        struct scsi_device *sdev;
        int rtn;
 
@@ -996,11 +989,8 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
                if (rtn == SUCCESS) {
                        if (!scsi_device_online(sdev) ||
                            !scsi_eh_tur(bdr_scmd)) {
-                               list_for_each_safe(lh, lh_sf,
-                                                  work_q) {
-                                       scmd = list_entry(lh, struct
-                                                         scsi_cmnd,
-                                                         eh_entry);
+                               list_for_each_entry_safe(scmd, next,
+                                                        work_q, eh_entry) {
                                        if (scmd->device == sdev)
                                                scsi_eh_finish_cmd(scmd,
                                                                   done_q);
@@ -1083,9 +1073,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
                             struct list_head *work_q,
                             struct list_head *done_q)
 {
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd;
-       struct scsi_cmnd *chan_scmd;
+       struct scsi_cmnd *scmd, *chan_scmd, *next;
        unsigned int channel;
        int rtn;
 
@@ -1116,9 +1104,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
                                                  channel));
                rtn = scsi_try_bus_reset(chan_scmd);
                if (rtn == SUCCESS) {
-                       list_for_each_safe(lh, lh_sf, work_q) {
-                               scmd = list_entry(lh, struct scsi_cmnd,
-                                                 eh_entry);
+                       list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
                                if (channel == scmd->device->channel)
                                        if (!scsi_device_online(scmd->device) ||
                                            !scsi_eh_tur(scmd))
@@ -1143,9 +1129,8 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
 static int scsi_eh_host_reset(struct list_head *work_q,
                              struct list_head *done_q)
 {
+       struct scsi_cmnd *scmd, *next;
        int rtn;
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd;
 
        if (!list_empty(work_q)) {
                scmd = list_entry(work_q->next,
@@ -1156,8 +1141,7 @@ static int scsi_eh_host_reset(struct list_head *work_q,
 
                rtn = scsi_try_host_reset(scmd);
                if (rtn == SUCCESS) {
-                       list_for_each_safe(lh, lh_sf, work_q) {
-                               scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
+                       list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
                                if (!scsi_device_online(scmd->device) ||
                                    (!scsi_eh_try_stu(scmd) && !scsi_eh_tur(scmd)) ||
                                    !scsi_eh_tur(scmd))
@@ -1181,11 +1165,9 @@ static int scsi_eh_host_reset(struct list_head *work_q,
 static void scsi_eh_offline_sdevs(struct list_head *work_q,
                                  struct list_head *done_q)
 {
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd;
+       struct scsi_cmnd *scmd, *next;
 
-       list_for_each_safe(lh, lh_sf, work_q) {
-               scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
+       list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
                printk(KERN_INFO "scsi: Device offlined - not"
                                " ready after error recovery: host"
                                " %d channel %d id %d lun %d\n",
@@ -1194,7 +1176,7 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q,
                                scmd->device->id,
                                scmd->device->lun);
                scsi_device_set_state(scmd->device, SDEV_OFFLINE);
-               if (scsi_eh_eflags_chk(scmd, SCSI_EH_CANCEL_CMD)) {
+               if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) {
                        /*
                         * FIXME: Handle lost cmds.
                         */
@@ -1513,12 +1495,10 @@ static void scsi_eh_ready_devs(struct Scsi_Host *shost,
  **/
 static void scsi_eh_flush_done_q(struct list_head *done_q)
 {
-       struct list_head *lh, *lh_sf;
-       struct scsi_cmnd *scmd;
+       struct scsi_cmnd *scmd, *next;
 
-       list_for_each_safe(lh, lh_sf, done_q) {
-               scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
-               list_del_init(lh);
+       list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
+               list_del_init(&scmd->eh_entry);
                if (scsi_device_online(scmd->device) &&
                    !blk_noretry_request(scmd->request) &&
                    (++scmd->retries < scmd->allowed)) {