Re: [PATCH 03/18] ide-cd: cdrom_decode_status: factor out block pc error handling code

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Borislav Petkov
Date: Friday, August 15, 2008 - 12:34 am

On Sat, Jun 14, 2008 at 07:29:21PM +0200, Bartlomiej Zolnierkiewicz wrote:

Hi Bart,

here's a first attempt at that. These are only RFC of nature, please take a look
when there's time. They've been lightly tested but I'll do more later since this
path is not hit that often and a special test case will be required.

---
From: Borislav Petkov <petkovbb@gmail.com>
Date: Sun, 10 Aug 2008 18:54:03 +0200
Subject: [PATCH 1/2] ide-cd: move error handling outside of cdrom_decode_status()

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-cd.c |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index f675cee..f2c12be 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -284,20 +284,11 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st)
  * 0: if the request should be continued.
  * 1: if the request was ended.
  */
-static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
+static int cdrom_decode_status(ide_drive_t *drive, int stat)
 {
 	ide_hwif_t *hwif = drive->hwif;
 	struct request *rq = hwif->hwgroup->rq;
-	int stat, err, sense_key;
-
-	/* check for errors */
-	stat = hwif->tp_ops->read_status(hwif);
-
-	if (stat_ret)
-		*stat_ret = stat;
-
-	if (OK_STAT(stat, good_stat, BAD_R_STAT))
-		return 0;
+	int err, sense_key;
 
 	/* get the IDE error register */
 	err = ide_read_error(drive);
@@ -563,7 +554,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
 					  ide_handler_t *handler)
 {
 	ide_hwif_t *hwif = drive->hwif;
-	int cmd_len;
+	int cmd_len, stat;
 	struct cdrom_info *info = drive->driver_data;
 	ide_startstop_t startstop;
 
@@ -574,8 +565,11 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
 		 */
 
 		/* check for errors */
-		if (cdrom_decode_status(drive, ATA_DRQ, NULL))
-			return ide_stopped;
+		stat = hwif->tp_ops->read_status(hwif);
+
+		if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT))
+			if (cdrom_decode_status(drive, stat))
+				return ide_stopped;
 
 		/* ok, next interrupt will be DMA interrupt */
 		if (info->dma)
@@ -739,8 +733,11 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
 	int stat;
 	static int retry = 10;
 
-	if (cdrom_decode_status(drive, 0, &stat))
-		return ide_stopped;
+	stat = drive->hwif->tp_ops->read_status(drive->hwif);
+
+	if (!OK_STAT(stat, 0, BAD_R_STAT))
+		if (cdrom_decode_status(drive, stat))
+			return ide_stopped;
 
 	drive->atapi_flags |= IDE_AFLAG_SEEKING;
 
@@ -917,8 +914,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 		}
 	}
 
-	if (cdrom_decode_status(drive, 0, &stat))
-		return ide_stopped;
+	stat = hwif->tp_ops->read_status(hwif);
+
+	if (!OK_STAT(stat, 0, BAD_R_STAT))
+		if (cdrom_decode_status(drive, stat))
+			return ide_stopped;
 
 	/* using dma, transfer is complete now */
 	if (dma) {
-- 
1.5.5.4


-- 
Regards/Gruss,
    Boris.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/18] misc generic ide stuff, Borislav Petkov, (Wed Jun 11, 11:40 pm)
[PATCH 01/18] ide-cd: remove wait-for-idle-controller bit ..., Borislav Petkov, (Wed Jun 11, 11:40 pm)
[PATCH 07/18] ide-cd: mv ide_do_rw_cdrom ide_cd_do_request, Borislav Petkov, (Wed Jun 11, 11:40 pm)
[PATCH 08/18] ide-cd: simplify request issuing path, Borislav Petkov, (Wed Jun 11, 11:41 pm)
[PATCH 13/18] ide-floppy: replace pc-&gt;c with rq-&gt;cmd, Borislav Petkov, (Wed Jun 11, 11:41 pm)
[PATCH 17/18] ide-floppy: cleanup idefloppy_create_rw_cmd, Borislav Petkov, (Wed Jun 11, 11:41 pm)
[PATCH 18/18] ide: use flags in IRQ handler, Borislav Petkov, (Wed Jun 11, 11:41 pm)
Re: [PATCH 00/18] misc generic ide stuff, Bartlomiej Zolnierki ..., (Sat Jun 14, 10:29 am)
Re: [PATCH 02/18] ide-cd: remove ide_cd_drain_data and ide ..., Bartlomiej Zolnierki ..., (Sat Jun 14, 10:29 am)
Re: [PATCH 03/18] ide-cd: cdrom_decode_status: factor out ..., Bartlomiej Zolnierki ..., (Sat Jun 14, 10:29 am)
Re: [PATCH 13/18] ide-floppy: replace pc-&gt;c with rq-&gt;cmd, Bartlomiej Zolnierki ..., (Sat Jun 14, 10:40 am)
Re: [PATCH 18/18] ide: use flags in IRQ handler, Bartlomiej Zolnierki ..., (Sat Jun 14, 10:47 am)
Re: [PATCH 00/18] misc generic ide stuff, Borislav Petkov, (Sun Jun 15, 3:27 am)
Re: [PATCH 13/18] ide-floppy: replace pc-&gt;c with rq-&gt;cmd, Bartlomiej Zolnierki ..., (Sun Jun 15, 7:57 am)
Re: [PATCH 03/18] ide-cd: cdrom_decode_status: factor out ..., Borislav Petkov, (Fri Aug 15, 12:34 am)
Re: [PATCH 03/18] ide-cd: cdrom_decode_status: factor out ..., Borislav Petkov, (Fri Aug 15, 12:34 am)