aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-04-08 08:12:53 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-04-08 08:12:53 -0400
commite01f251fd09fa7cb3d352eac7de17bb5d5bd1f9d (patch)
treedb287f1b8be1ce7ed8e951ed297d95c2d29be5de /drivers/ide
parent98036abf31994244cb5772ecc291f4293a52c20b (diff)
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>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-cd.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index e946f0ecbb9c..43db330d7b5d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -340,15 +340,14 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
340 if (blk_pc_request(rq) && !rq->errors) 340 if (blk_pc_request(rq) && !rq->errors)
341 rq->errors = SAM_STAT_CHECK_CONDITION; 341 rq->errors = SAM_STAT_CHECK_CONDITION;
342 342
343 /* check for tray open */ 343 switch (sense_key) {
344 if (sense_key == NOT_READY) { 344 case NOT_READY:
345 cdrom_saw_media_change(drive); 345 cdrom_saw_media_change(drive);
346 } else if (sense_key == UNIT_ATTENTION) { 346 break;
347 /* check for media change */ 347 case UNIT_ATTENTION:
348 cdrom_saw_media_change(drive); 348 cdrom_saw_media_change(drive);
349 return 0; 349 return 0;
350 } else if (sense_key == ILLEGAL_REQUEST && 350 case ILLEGAL_REQUEST:
351 rq->cmd[0] == GPCMD_START_STOP_UNIT) {
352 /* 351 /*
353 * Don't print error message for this condition-- 352 * Don't print error message for this condition--
354 * SFF8090i indicates that 5/24/00 is the correct 353 * SFF8090i indicates that 5/24/00 is the correct
@@ -356,9 +355,13 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
356 * drive doesn't have that capability. 355 * drive doesn't have that capability.
357 * cdrom_log_sense() knows this! 356 * cdrom_log_sense() knows this!
358 */ 357 */
359 } else if (!quiet) { 358 if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
360 /* otherwise, print an error */ 359 break;
361 ide_dump_status(drive, "packet command error", stat); 360 /* fall-through */
361 default:
362 if (!quiet)
363 ide_dump_status(drive, "packet command error",
364 stat);
362 } 365 }
363 366
364 rq->cmd_flags |= REQ_FAILED; 367 rq->cmd_flags |= REQ_FAILED;
@@ -378,12 +381,11 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
378 if (blk_noretry_request(rq)) 381 if (blk_noretry_request(rq))
379 do_end_request = 1; 382 do_end_request = 1;
380 383
381 if (sense_key == NOT_READY) { 384 switch (sense_key) {
382 /* tray open */ 385 case NOT_READY:
383 if (rq_data_dir(rq) == READ) { 386 if (rq_data_dir(rq) == READ) {
384 cdrom_saw_media_change(drive); 387 cdrom_saw_media_change(drive);
385 388
386 /* fail the request */
387 if (!quiet) 389 if (!quiet)
388 printk(KERN_ERR PFX "%s: tray open\n", 390 printk(KERN_ERR PFX "%s: tray open\n",
389 drive->name); 391 drive->name);
@@ -392,8 +394,8 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
392 return 1; 394 return 1;
393 } 395 }
394 do_end_request = 1; 396 do_end_request = 1;
395 } else if (sense_key == UNIT_ATTENTION) { 397 break;
396 /* media change */ 398 case UNIT_ATTENTION:
397 cdrom_saw_media_change(drive); 399 cdrom_saw_media_change(drive);
398 400
399 /* 401 /*
@@ -402,8 +404,9 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
402 */ 404 */
403 if (++rq->errors > ERROR_MAX) 405 if (++rq->errors > ERROR_MAX)
404 do_end_request = 1; 406 do_end_request = 1;
405 } else if (sense_key == ILLEGAL_REQUEST || 407 break;
406 sense_key == DATA_PROTECT) { 408 case ILLEGAL_REQUEST:
409 case DATA_PROTECT:
407 /* 410 /*
408 * No point in retrying after an illegal request or data 411 * No point in retrying after an illegal request or data
409 * protect error. 412 * protect error.
@@ -411,7 +414,8 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
411 if (!quiet) 414 if (!quiet)
412 ide_dump_status(drive, "command error", stat); 415 ide_dump_status(drive, "command error", stat);
413 do_end_request = 1; 416 do_end_request = 1;
414 } else if (sense_key == MEDIUM_ERROR) { 417 break;
418 case MEDIUM_ERROR:
415 /* 419 /*
416 * No point in re-trying a zillion times on a bad 420 * No point in re-trying a zillion times on a bad
417 * sector. If we got here the error is not correctable. 421 * 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)
420 ide_dump_status(drive, "media error " 424 ide_dump_status(drive, "media error "
421 "(bad sector)", stat); 425 "(bad sector)", stat);
422 do_end_request = 1; 426 do_end_request = 1;
423 } else if (sense_key == BLANK_CHECK) { 427 break;
428 case BLANK_CHECK:
424 /* disk appears blank ?? */ 429 /* disk appears blank ?? */
425 if (!quiet) 430 if (!quiet)
426 ide_dump_status(drive, "media error (blank)", 431 ide_dump_status(drive, "media error (blank)",
427 stat); 432 stat);
428 do_end_request = 1; 433 do_end_request = 1;
429 } else if ((err & ~ATA_ABORTED) != 0) { 434 break;
430 /* go to the default handler for other errors */ 435 default:
431 ide_error(drive, "cdrom_decode_status", stat); 436 if (err & ~ATA_ABORTED) {
432 return 1; 437 /* go to the default handler for other errors */
433 } else if ((++rq->errors > ERROR_MAX)) { 438 ide_error(drive, "cdrom_decode_status", stat);
434 /* we've racked up too many retries, abort */ 439 return 1;
435 do_end_request = 1; 440 } else if (++rq->errors > ERROR_MAX)
441 /* we've racked up too many retries, abort */
442 do_end_request = 1;
436 } 443 }
437 444
438 /* 445 /*