ide-cd: convert cdrom_decode_status() to use switch statements

Based on earlier work by Borislav Petkov.

Convert cdrom_decode_status() to use switch statements in
preparation to unify handling of fs and pc requests.

While at it:
- remove superfluous comments and do minor CodingStyle fixups

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:
Bartlomiej Zolnierkiewicz 2009-04-08 14:12:53 +02:00
parent 98036abf31
commit e01f251fd0

View file

@ -340,15 +340,14 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
if (blk_pc_request(rq) && !rq->errors) if (blk_pc_request(rq) && !rq->errors)
rq->errors = SAM_STAT_CHECK_CONDITION; rq->errors = SAM_STAT_CHECK_CONDITION;
/* check for tray open */ switch (sense_key) {
if (sense_key == NOT_READY) { case NOT_READY:
cdrom_saw_media_change(drive); cdrom_saw_media_change(drive);
} else if (sense_key == UNIT_ATTENTION) { break;
/* check for media change */ case UNIT_ATTENTION:
cdrom_saw_media_change(drive); cdrom_saw_media_change(drive);
return 0; return 0;
} else if (sense_key == ILLEGAL_REQUEST && case ILLEGAL_REQUEST:
rq->cmd[0] == GPCMD_START_STOP_UNIT) {
/* /*
* Don't print error message for this condition-- * Don't print error message for this condition--
* SFF8090i indicates that 5/24/00 is the correct * SFF8090i indicates that 5/24/00 is the correct
@ -356,9 +355,13 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
* drive doesn't have that capability. * drive doesn't have that capability.
* cdrom_log_sense() knows this! * cdrom_log_sense() knows this!
*/ */
} else if (!quiet) { if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
/* otherwise, print an error */ break;
ide_dump_status(drive, "packet command error", stat); /* fall-through */
default:
if (!quiet)
ide_dump_status(drive, "packet command error",
stat);
} }
rq->cmd_flags |= REQ_FAILED; rq->cmd_flags |= REQ_FAILED;
@ -378,12 +381,11 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
if (blk_noretry_request(rq)) if (blk_noretry_request(rq))
do_end_request = 1; do_end_request = 1;
if (sense_key == NOT_READY) { switch (sense_key) {
/* tray open */ case NOT_READY:
if (rq_data_dir(rq) == READ) { if (rq_data_dir(rq) == READ) {
cdrom_saw_media_change(drive); cdrom_saw_media_change(drive);
/* fail the request */
if (!quiet) if (!quiet)
printk(KERN_ERR PFX "%s: tray open\n", printk(KERN_ERR PFX "%s: tray open\n",
drive->name); drive->name);
@ -392,8 +394,8 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
return 1; return 1;
} }
do_end_request = 1; do_end_request = 1;
} else if (sense_key == UNIT_ATTENTION) { break;
/* media change */ case UNIT_ATTENTION:
cdrom_saw_media_change(drive); cdrom_saw_media_change(drive);
/* /*
@ -402,8 +404,9 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
*/ */
if (++rq->errors > ERROR_MAX) if (++rq->errors > ERROR_MAX)
do_end_request = 1; do_end_request = 1;
} else if (sense_key == ILLEGAL_REQUEST || break;
sense_key == DATA_PROTECT) { case ILLEGAL_REQUEST:
case DATA_PROTECT:
/* /*
* No point in retrying after an illegal request or data * No point in retrying after an illegal request or data
* protect error. * protect error.
@ -411,7 +414,8 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
if (!quiet) if (!quiet)
ide_dump_status(drive, "command error", stat); ide_dump_status(drive, "command error", stat);
do_end_request = 1; do_end_request = 1;
} else if (sense_key == MEDIUM_ERROR) { break;
case MEDIUM_ERROR:
/* /*
* No point in re-trying a zillion times on a bad * No point in re-trying a zillion times on a bad
* sector. If we got here the error is not correctable. * sector. If we got here the error is not correctable.
@ -420,19 +424,22 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
ide_dump_status(drive, "media error " ide_dump_status(drive, "media error "
"(bad sector)", stat); "(bad sector)", stat);
do_end_request = 1; do_end_request = 1;
} else if (sense_key == BLANK_CHECK) { break;
case BLANK_CHECK:
/* disk appears blank ?? */ /* disk appears blank ?? */
if (!quiet) if (!quiet)
ide_dump_status(drive, "media error (blank)", ide_dump_status(drive, "media error (blank)",
stat); stat);
do_end_request = 1; do_end_request = 1;
} else if ((err & ~ATA_ABORTED) != 0) { break;
/* go to the default handler for other errors */ default:
ide_error(drive, "cdrom_decode_status", stat); if (err & ~ATA_ABORTED) {
return 1; /* go to the default handler for other errors */
} else if ((++rq->errors > ERROR_MAX)) { ide_error(drive, "cdrom_decode_status", stat);
/* we've racked up too many retries, abort */ return 1;
do_end_request = 1; } else if (++rq->errors > ERROR_MAX)
/* we've racked up too many retries, abort */
do_end_request = 1;
} }
/* /*