X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fscsi%2Fscsi_lib.c;h=1e7c9e9ef772e10c40789ebf44eb428360ac7f77;hb=9d11251709f31d49c8167a619d4475fdf6cd7f73;hp=e5a9526d20376ab341b54618248dbdd93db3ded3;hpb=b73b636e8987f8728c6c700377615757691b9a55;p=linux-2.6-omap-h63xx.git diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index e5a9526d203..1e7c9e9ef77 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -529,6 +529,14 @@ static void scsi_single_lun_run(struct scsi_device *current_sdev) spin_unlock_irqrestore(shost->host_lock, flags); } +static inline int scsi_device_is_busy(struct scsi_device *sdev) +{ + if (sdev->device_busy >= sdev->queue_depth || sdev->device_blocked) + return 1; + + return 0; +} + static inline int scsi_target_is_busy(struct scsi_target *starget) { return ((starget->can_queue > 0 && @@ -536,6 +544,15 @@ static inline int scsi_target_is_busy(struct scsi_target *starget) starget->target_blocked); } +static inline int scsi_host_is_busy(struct Scsi_Host *shost) +{ + if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) || + shost->host_blocked || shost->host_self_blocked) + return 1; + + return 0; +} + /* * Function: scsi_run_queue() * @@ -558,11 +575,7 @@ static void scsi_run_queue(struct request_queue *q) scsi_single_lun_run(sdev); spin_lock_irqsave(shost->host_lock, flags); - while (!list_empty(&shost->starved_list) && - !shost->host_blocked && !shost->host_self_blocked && - !((shost->can_queue > 0) && - (shost->host_busy >= shost->can_queue))) { - + while (!list_empty(&shost->starved_list) && !scsi_host_is_busy(shost)) { int flagset; /* @@ -1348,8 +1361,6 @@ int scsi_prep_fn(struct request_queue *q, struct request *req) static inline int scsi_dev_queue_ready(struct request_queue *q, struct scsi_device *sdev) { - if (sdev->device_busy >= sdev->queue_depth) - return 0; if (sdev->device_busy == 0 && sdev->device_blocked) { /* * unblock after device_blocked iterates to zero @@ -1363,7 +1374,7 @@ static inline int scsi_dev_queue_ready(struct request_queue *q, return 0; } } - if (sdev->device_blocked) + if (scsi_device_is_busy(sdev)) return 0; return 1; @@ -1440,8 +1451,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q, return 0; } } - if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) || - shost->host_blocked || shost->host_self_blocked) { + if (scsi_host_is_busy(shost)) { if (list_empty(&sdev->starved_entry)) list_add_tail(&sdev->starved_entry, &shost->starved_list); return 0; @@ -2105,22 +2115,21 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries, do { result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr, timeout, retries); - } while ((driver_byte(result) & DRIVER_SENSE) && - sshdr && sshdr->sense_key == UNIT_ATTENTION && - --retries); + if (sdev->removable && scsi_sense_valid(sshdr) && + sshdr->sense_key == UNIT_ATTENTION) + sdev->changed = 1; + } while (scsi_sense_valid(sshdr) && + sshdr->sense_key == UNIT_ATTENTION && --retries); if (!sshdr) /* could not allocate sense buffer, so can't process it */ return result; - if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) { - - if ((scsi_sense_valid(sshdr)) && - ((sshdr->sense_key == UNIT_ATTENTION) || - (sshdr->sense_key == NOT_READY))) { - sdev->changed = 1; - result = 0; - } + if (sdev->removable && scsi_sense_valid(sshdr) && + (sshdr->sense_key == UNIT_ATTENTION || + sshdr->sense_key == NOT_READY)) { + sdev->changed = 1; + result = 0; } if (!sshdr_external) kfree(sshdr);