mirror of https://gitee.com/openkylin/linux.git
ide-cd: fix intendation in cdrom_decode_status()
Based on earlier work by Borislav Petkov. Fix intendation in cdrom_decode_status(), no real code changes. While at it: - beautify comments There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
parent
1920c48d79
commit
674f0ea111
|
@ -311,7 +311,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
|
||||||
{
|
{
|
||||||
ide_hwif_t *hwif = drive->hwif;
|
ide_hwif_t *hwif = drive->hwif;
|
||||||
struct request *rq = hwif->rq;
|
struct request *rq = hwif->rq;
|
||||||
int err, sense_key;
|
int err, sense_key, do_end_request = 0;
|
||||||
u8 quiet = rq->cmd_flags & REQ_QUIET;
|
u8 quiet = rq->cmd_flags & REQ_QUIET;
|
||||||
|
|
||||||
/* get the IDE error register */
|
/* get the IDE error register */
|
||||||
|
@ -330,117 +330,108 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
|
||||||
*/
|
*/
|
||||||
rq->cmd_flags |= REQ_FAILED;
|
rq->cmd_flags |= REQ_FAILED;
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
}
|
||||||
int do_end_request = 0;
|
|
||||||
|
|
||||||
/*
|
/* if we have an error, pass CHECK_CONDITION as the SCSI status byte */
|
||||||
* if we have an error, pass back CHECK_CONDITION as the
|
if (blk_pc_request(rq) && !rq->errors)
|
||||||
* scsi status byte
|
rq->errors = SAM_STAT_CHECK_CONDITION;
|
||||||
*/
|
|
||||||
if (blk_pc_request(rq) && !rq->errors)
|
|
||||||
rq->errors = SAM_STAT_CHECK_CONDITION;
|
|
||||||
|
|
||||||
if (blk_noretry_request(rq))
|
if (blk_noretry_request(rq))
|
||||||
do_end_request = 1;
|
do_end_request = 1;
|
||||||
|
|
||||||
switch (sense_key) {
|
switch (sense_key) {
|
||||||
case NOT_READY:
|
case NOT_READY:
|
||||||
if (blk_fs_request(rq) == 0 ||
|
if (blk_fs_request(rq) == 0 || rq_data_dir(rq) == READ) {
|
||||||
rq_data_dir(rq) == READ) {
|
|
||||||
cdrom_saw_media_change(drive);
|
|
||||||
|
|
||||||
if (blk_fs_request(rq) && !quiet)
|
|
||||||
printk(KERN_ERR PFX "%s: tray open\n",
|
|
||||||
drive->name);
|
|
||||||
} else {
|
|
||||||
if (ide_cd_breathe(drive, rq))
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
do_end_request = 1;
|
|
||||||
break;
|
|
||||||
case UNIT_ATTENTION:
|
|
||||||
cdrom_saw_media_change(drive);
|
cdrom_saw_media_change(drive);
|
||||||
|
|
||||||
if (blk_fs_request(rq) == 0)
|
if (blk_fs_request(rq) && !quiet)
|
||||||
return 0;
|
printk(KERN_ERR PFX "%s: tray open\n",
|
||||||
/*
|
drive->name);
|
||||||
* Arrange to retry the request but be sure to give up
|
} else {
|
||||||
* if we've retried too many times.
|
if (ide_cd_breathe(drive, rq))
|
||||||
*/
|
|
||||||
if (++rq->errors > ERROR_MAX)
|
|
||||||
do_end_request = 1;
|
|
||||||
break;
|
|
||||||
case ILLEGAL_REQUEST:
|
|
||||||
/*
|
|
||||||
* Don't print error message for this condition--
|
|
||||||
* SFF8090i indicates that 5/24/00 is the correct
|
|
||||||
* response to a request to close the tray if the
|
|
||||||
* drive doesn't have that capability.
|
|
||||||
* cdrom_log_sense() knows this!
|
|
||||||
*/
|
|
||||||
if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
|
|
||||||
break;
|
|
||||||
/* fall-through */
|
|
||||||
case DATA_PROTECT:
|
|
||||||
/*
|
|
||||||
* No point in retrying after an illegal request or data
|
|
||||||
* protect error.
|
|
||||||
*/
|
|
||||||
if (!quiet)
|
|
||||||
ide_dump_status(drive, "command error", stat);
|
|
||||||
do_end_request = 1;
|
|
||||||
break;
|
|
||||||
case MEDIUM_ERROR:
|
|
||||||
/*
|
|
||||||
* No point in re-trying a zillion times on a bad
|
|
||||||
* sector. If we got here the error is not correctable.
|
|
||||||
*/
|
|
||||||
if (!quiet)
|
|
||||||
ide_dump_status(drive, "media error "
|
|
||||||
"(bad sector)", stat);
|
|
||||||
do_end_request = 1;
|
|
||||||
break;
|
|
||||||
case BLANK_CHECK:
|
|
||||||
/* disk appears blank ?? */
|
|
||||||
if (!quiet)
|
|
||||||
ide_dump_status(drive, "media error (blank)",
|
|
||||||
stat);
|
|
||||||
do_end_request = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (blk_fs_request(rq) == 0)
|
|
||||||
break;
|
|
||||||
if (err & ~ATA_ABORTED) {
|
|
||||||
/* go to the default handler for other errors */
|
|
||||||
ide_error(drive, "cdrom_decode_status", stat);
|
|
||||||
return 1;
|
return 1;
|
||||||
} else if (++rq->errors > ERROR_MAX)
|
|
||||||
/* we've racked up too many retries, abort */
|
|
||||||
do_end_request = 1;
|
|
||||||
}
|
}
|
||||||
|
do_end_request = 1;
|
||||||
|
break;
|
||||||
|
case UNIT_ATTENTION:
|
||||||
|
cdrom_saw_media_change(drive);
|
||||||
|
|
||||||
if (blk_fs_request(rq) == 0) {
|
if (blk_fs_request(rq) == 0)
|
||||||
rq->cmd_flags |= REQ_FAILED;
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Arrange to retry the request but be sure to give up if we've
|
||||||
|
* retried too many times.
|
||||||
|
*/
|
||||||
|
if (++rq->errors > ERROR_MAX)
|
||||||
do_end_request = 1;
|
do_end_request = 1;
|
||||||
}
|
break;
|
||||||
|
case ILLEGAL_REQUEST:
|
||||||
/*
|
/*
|
||||||
* End a request through request sense analysis when we have
|
* Don't print error message for this condition -- SFF8090i
|
||||||
* sense data. We need this in order to perform end of media
|
* indicates that 5/24/00 is the correct response to a request
|
||||||
* processing.
|
* to close the tray if the drive doesn't have that capability.
|
||||||
|
*
|
||||||
|
* cdrom_log_sense() knows this!
|
||||||
*/
|
*/
|
||||||
if (do_end_request)
|
if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
|
||||||
goto end_request;
|
break;
|
||||||
|
/* fall-through */
|
||||||
|
case DATA_PROTECT:
|
||||||
/*
|
/*
|
||||||
* If we got a CHECK_CONDITION status, queue
|
* No point in retrying after an illegal request or data
|
||||||
* a request sense command.
|
* protect error.
|
||||||
*/
|
*/
|
||||||
if (stat & ATA_ERR)
|
if (!quiet)
|
||||||
cdrom_queue_request_sense(drive, NULL, NULL);
|
ide_dump_status(drive, "command error", stat);
|
||||||
return 1;
|
do_end_request = 1;
|
||||||
|
break;
|
||||||
|
case MEDIUM_ERROR:
|
||||||
|
/*
|
||||||
|
* No point in re-trying a zillion times on a bad sector.
|
||||||
|
* If we got here the error is not correctable.
|
||||||
|
*/
|
||||||
|
if (!quiet)
|
||||||
|
ide_dump_status(drive, "media error "
|
||||||
|
"(bad sector)", stat);
|
||||||
|
do_end_request = 1;
|
||||||
|
break;
|
||||||
|
case BLANK_CHECK:
|
||||||
|
/* disk appears blank? */
|
||||||
|
if (!quiet)
|
||||||
|
ide_dump_status(drive, "media error (blank)",
|
||||||
|
stat);
|
||||||
|
do_end_request = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (blk_fs_request(rq) == 0)
|
||||||
|
break;
|
||||||
|
if (err & ~ATA_ABORTED) {
|
||||||
|
/* go to the default handler for other errors */
|
||||||
|
ide_error(drive, "cdrom_decode_status", stat);
|
||||||
|
return 1;
|
||||||
|
} else if (++rq->errors > ERROR_MAX)
|
||||||
|
/* we've racked up too many retries, abort */
|
||||||
|
do_end_request = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blk_fs_request(rq) == 0) {
|
||||||
|
rq->cmd_flags |= REQ_FAILED;
|
||||||
|
do_end_request = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* End a request through request sense analysis when we have sense data.
|
||||||
|
* We need this in order to perform end of media processing.
|
||||||
|
*/
|
||||||
|
if (do_end_request)
|
||||||
|
goto end_request;
|
||||||
|
|
||||||
|
/* if we got a CHECK_CONDITION status, queue a request sense command */
|
||||||
|
if (stat & ATA_ERR)
|
||||||
|
cdrom_queue_request_sense(drive, NULL, NULL);
|
||||||
|
return 1;
|
||||||
|
|
||||||
end_request:
|
end_request:
|
||||||
if (stat & ATA_ERR) {
|
if (stat & ATA_ERR) {
|
||||||
struct request_queue *q = drive->queue;
|
struct request_queue *q = drive->queue;
|
||||||
|
|
Loading…
Reference in New Issue