Skip to content

Commit 674f0ea

Browse files
committed
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>
1 parent 1920c48 commit 674f0ea

1 file changed

Lines changed: 88 additions & 97 deletions

File tree

‎drivers/ide/ide-cd.c‎

Lines changed: 88 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
311311
{
312312
ide_hwif_t *hwif = drive->hwif;
313313
struct request *rq = hwif->rq;
314-
int err, sense_key;
314+
int err, sense_key, do_end_request = 0;
315315
u8 quiet = rq->cmd_flags & REQ_QUIET;
316316

317317
/* get the IDE error register */
@@ -330,117 +330,108 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
330330
*/
331331
rq->cmd_flags |= REQ_FAILED;
332332
return 2;
333-
} else {
334-
int do_end_request = 0;
335-
336-
/*
337-
* if we have an error, pass back CHECK_CONDITION as the
338-
* scsi status byte
339-
*/
340-
if (blk_pc_request(rq) && !rq->errors)
341-
rq->errors = SAM_STAT_CHECK_CONDITION;
333+
}
342334

343-
if (blk_noretry_request(rq))
344-
do_end_request = 1;
335+
/* if we have an error, pass CHECK_CONDITION as the SCSI status byte */
336+
if (blk_pc_request(rq) && !rq->errors)
337+
rq->errors = SAM_STAT_CHECK_CONDITION;
345338

346-
switch (sense_key) {
347-
case NOT_READY:
348-
if (blk_fs_request(rq) == 0 ||
349-
rq_data_dir(rq) == READ) {
350-
cdrom_saw_media_change(drive);
339+
if (blk_noretry_request(rq))
340+
do_end_request = 1;
351341

352-
if (blk_fs_request(rq) && !quiet)
353-
printk(KERN_ERR PFX "%s: tray open\n",
354-
drive->name);
355-
} else {
356-
if (ide_cd_breathe(drive, rq))
357-
return 1;
358-
}
359-
do_end_request = 1;
360-
break;
361-
case UNIT_ATTENTION:
342+
switch (sense_key) {
343+
case NOT_READY:
344+
if (blk_fs_request(rq) == 0 || rq_data_dir(rq) == READ) {
362345
cdrom_saw_media_change(drive);
363346

364-
if (blk_fs_request(rq) == 0)
365-
return 0;
366-
/*
367-
* Arrange to retry the request but be sure to give up
368-
* if we've retried too many times.
369-
*/
370-
if (++rq->errors > ERROR_MAX)
371-
do_end_request = 1;
372-
break;
373-
case ILLEGAL_REQUEST:
374-
/*
375-
* Don't print error message for this condition--
376-
* SFF8090i indicates that 5/24/00 is the correct
377-
* response to a request to close the tray if the
378-
* drive doesn't have that capability.
379-
* cdrom_log_sense() knows this!
380-
*/
381-
if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
382-
break;
383-
/* fall-through */
384-
case DATA_PROTECT:
385-
/*
386-
* No point in retrying after an illegal request or data
387-
* protect error.
388-
*/
389-
if (!quiet)
390-
ide_dump_status(drive, "command error", stat);
391-
do_end_request = 1;
392-
break;
393-
case MEDIUM_ERROR:
394-
/*
395-
* No point in re-trying a zillion times on a bad
396-
* sector. If we got here the error is not correctable.
397-
*/
398-
if (!quiet)
399-
ide_dump_status(drive, "media error "
400-
"(bad sector)", stat);
401-
do_end_request = 1;
402-
break;
403-
case BLANK_CHECK:
404-
/* disk appears blank ?? */
405-
if (!quiet)
406-
ide_dump_status(drive, "media error (blank)",
407-
stat);
408-
do_end_request = 1;
409-
break;
410-
default:
411-
if (blk_fs_request(rq) == 0)
412-
break;
413-
if (err & ~ATA_ABORTED) {
414-
/* go to the default handler for other errors */
415-
ide_error(drive, "cdrom_decode_status", stat);
347+
if (blk_fs_request(rq) && !quiet)
348+
printk(KERN_ERR PFX "%s: tray open\n",
349+
drive->name);
350+
} else {
351+
if (ide_cd_breathe(drive, rq))
416352
return 1;
417-
} else if (++rq->errors > ERROR_MAX)
418-
/* we've racked up too many retries, abort */
419-
do_end_request = 1;
420353
}
354+
do_end_request = 1;
355+
break;
356+
case UNIT_ATTENTION:
357+
cdrom_saw_media_change(drive);
421358

422-
if (blk_fs_request(rq) == 0) {
423-
rq->cmd_flags |= REQ_FAILED;
424-
do_end_request = 1;
425-
}
359+
if (blk_fs_request(rq) == 0)
360+
return 0;
426361

427362
/*
428-
* End a request through request sense analysis when we have
429-
* sense data. We need this in order to perform end of media
430-
* processing.
363+
* Arrange to retry the request but be sure to give up if we've
364+
* retried too many times.
431365
*/
432-
if (do_end_request)
433-
goto end_request;
434-
366+
if (++rq->errors > ERROR_MAX)
367+
do_end_request = 1;
368+
break;
369+
case ILLEGAL_REQUEST:
370+
/*
371+
* Don't print error message for this condition -- SFF8090i
372+
* indicates that 5/24/00 is the correct response to a request
373+
* to close the tray if the drive doesn't have that capability.
374+
*
375+
* cdrom_log_sense() knows this!
376+
*/
377+
if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
378+
break;
379+
/* fall-through */
380+
case DATA_PROTECT:
435381
/*
436-
* If we got a CHECK_CONDITION status, queue
437-
* a request sense command.
382+
* No point in retrying after an illegal request or data
383+
* protect error.
438384
*/
439-
if (stat & ATA_ERR)
440-
cdrom_queue_request_sense(drive, NULL, NULL);
441-
return 1;
385+
if (!quiet)
386+
ide_dump_status(drive, "command error", stat);
387+
do_end_request = 1;
388+
break;
389+
case MEDIUM_ERROR:
390+
/*
391+
* No point in re-trying a zillion times on a bad sector.
392+
* If we got here the error is not correctable.
393+
*/
394+
if (!quiet)
395+
ide_dump_status(drive, "media error "
396+
"(bad sector)", stat);
397+
do_end_request = 1;
398+
break;
399+
case BLANK_CHECK:
400+
/* disk appears blank? */
401+
if (!quiet)
402+
ide_dump_status(drive, "media error (blank)",
403+
stat);
404+
do_end_request = 1;
405+
break;
406+
default:
407+
if (blk_fs_request(rq) == 0)
408+
break;
409+
if (err & ~ATA_ABORTED) {
410+
/* go to the default handler for other errors */
411+
ide_error(drive, "cdrom_decode_status", stat);
412+
return 1;
413+
} else if (++rq->errors > ERROR_MAX)
414+
/* we've racked up too many retries, abort */
415+
do_end_request = 1;
442416
}
443417

418+
if (blk_fs_request(rq) == 0) {
419+
rq->cmd_flags |= REQ_FAILED;
420+
do_end_request = 1;
421+
}
422+
423+
/*
424+
* End a request through request sense analysis when we have sense data.
425+
* We need this in order to perform end of media processing.
426+
*/
427+
if (do_end_request)
428+
goto end_request;
429+
430+
/* if we got a CHECK_CONDITION status, queue a request sense command */
431+
if (stat & ATA_ERR)
432+
cdrom_queue_request_sense(drive, NULL, NULL);
433+
return 1;
434+
444435
end_request:
445436
if (stat & ATA_ERR) {
446437
struct request_queue *q = drive->queue;

0 commit comments

Comments
 (0)