linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ide-taskfile.c fixups/cleanups part #2 [1/9]
@ 2004-06-30 15:24 Bartlomiej Zolnierkiewicz
  2004-07-02 12:20 ` Pavel Machek
  0 siblings, 1 reply; 4+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-06-30 15:24 UTC (permalink / raw)
  To: linux-ide; +Cc: linux-kernel


[PATCH] ide: PIO-out fixes for ide-taskfile.c (CONFIG_IDE_TASKFILE_IO=n)

- in task_out_intr() fix off-by-1 bug and (stat & DRQ_STAT) check,
  previously "if" was always true for rq->current_nr_sectors == 1
- fail request if DRQ_STAT is not set and rq->current_nr_sectors != 0
  (instead of setting handler and waiting for the next IRQ) or if DRQ_STAT
  is set but !rq->current_nr_sectors (in task_mulout_intr() this was OK)
- in task_mulout_intr() check also DRIVE_READY and WRERR_STAT status bits

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>

 linux-2.6.7-bk11-bzolnier/drivers/ide/ide-taskfile.c |   31 +++++++++----------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff -puN drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes drivers/ide/ide-taskfile.c
--- linux-2.6.7-bk11/drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes	2004-06-28 21:15:54.030210376 +0200
+++ linux-2.6.7-bk11-bzolnier/drivers/ide/ide-taskfile.c	2004-06-28 21:15:54.035209616 +0200
@@ -409,6 +409,10 @@ ide_startstop_t task_out_intr (ide_drive
 	if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), DRIVE_READY, drive->bad_wstat)) {
 		return DRIVER(drive)->error(drive, "task_out_intr", stat);
 	}
+
+	if (((stat & DRQ_STAT) == 0) ^ !rq->current_nr_sectors)
+		return DRIVER(drive)->error(drive, __FUNCTION__, stat);
+
 	/*
 	 * Safe to update request for partial completions.
 	 * We have a good STATUS CHECK!!!
@@ -416,9 +420,8 @@ ide_startstop_t task_out_intr (ide_drive
 	if (!rq->current_nr_sectors)
 		if (!DRIVER(drive)->end_request(drive, 1, 0))
 			return ide_stopped;
-	if ((rq->current_nr_sectors==1) ^ (stat & DRQ_STAT)) {
-		task_buffer_sectors(drive, rq, 1, IDE_PIO_OUT);
-	}
+
+	task_buffer_sectors(drive, rq, 1, IDE_PIO_OUT);
 	ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
 	return ide_started;
 }
@@ -461,18 +464,16 @@ ide_startstop_t task_mulout_intr (ide_dr
 	u8 stat				= hwif->INB(IDE_STATUS_REG);
 	struct request *rq		= HWGROUP(drive)->rq;
 
-	if (!OK_STAT(stat, DATA_READY, BAD_R_STAT) || !rq->current_nr_sectors) {
-		if (stat & (ERR_STAT|DRQ_STAT)) {
-			return DRIVER(drive)->error(drive, "task_mulout_intr", stat);
-		}
-		/* Handle last IRQ, occurs after all data was sent. */
-		if (!rq->current_nr_sectors) {
-			DRIVER(drive)->end_request(drive, 1, 0);
-			return ide_stopped;
-		}
-		/* no data yet, so wait for another interrupt */
-		ide_set_handler(drive, &task_mulout_intr, WAIT_WORSTCASE, NULL);
-		return ide_started;
+	if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
+		return DRIVER(drive)->error(drive, __FUNCTION__, stat);
+
+	if (((stat & DRQ_STAT) == 0) ^ !rq->current_nr_sectors)
+		return DRIVER(drive)->error(drive, __FUNCTION__, stat);
+
+	/* Handle last IRQ, occurs after all data was sent. */
+	if (!rq->current_nr_sectors) {
+		DRIVER(drive)->end_request(drive, 1, 0);
+		return ide_stopped;
 	}
 
 	task_buffer_multi_sectors(drive, rq, IDE_PIO_OUT);

_


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ide-taskfile.c fixups/cleanups part #2 [1/9]
  2004-06-30 15:24 [PATCH] ide-taskfile.c fixups/cleanups part #2 [1/9] Bartlomiej Zolnierkiewicz
@ 2004-07-02 12:20 ` Pavel Machek
  2004-07-02 16:43   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2004-07-02 12:20 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel

Hi!

> diff -puN drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes drivers/ide/ide-taskfile.c
> --- linux-2.6.7-bk11/drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes	2004-06-28 21:15:54.030210376 +0200
> +++ linux-2.6.7-bk11-bzolnier/drivers/ide/ide-taskfile.c	2004-06-28 21:15:54.035209616 +0200
> @@ -409,6 +409,10 @@ ide_startstop_t task_out_intr (ide_drive
>  	if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), DRIVE_READY, drive->bad_wstat)) {
>  		return DRIVER(drive)->error(drive, "task_out_intr", stat);
>  	}
> +
> +	if (((stat & DRQ_STAT) == 0) ^ !rq->current_nr_sectors)
> +		return DRIVER(drive)->error(drive, __FUNCTION__, stat);
> +

Looks pretty close to obfuscated c code contents... Can't you use !=
or kill ! in second clause and use == or something?
								Pavel
-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ide-taskfile.c fixups/cleanups part #2 [1/9]
  2004-07-02 12:20 ` Pavel Machek
@ 2004-07-02 16:43   ` Bartlomiej Zolnierkiewicz
  2004-07-02 19:20     ` Pavel Machek
  0 siblings, 1 reply; 4+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-07-02 16:43 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-ide, linux-kernel

On Friday 02 of July 2004 14:20, Pavel Machek wrote:
> Hi!

Hi,

> > diff -puN drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes
> > drivers/ide/ide-taskfile.c ---
> > linux-2.6.7-bk11/drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes	2004-06-
> >28 21:15:54.030210376 +0200 +++
> > linux-2.6.7-bk11-bzolnier/drivers/ide/ide-taskfile.c	2004-06-28
> > 21:15:54.035209616 +0200 @@ -409,6 +409,10 @@ ide_startstop_t
> > task_out_intr (ide_drive
> >  	if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), DRIVE_READY,
> > drive->bad_wstat)) { return DRIVER(drive)->error(drive, "task_out_intr",
> > stat);
> >  	}
> > +
> > +	if (((stat & DRQ_STAT) == 0) ^ !rq->current_nr_sectors)
> > +		return DRIVER(drive)->error(drive, __FUNCTION__, stat);
> > +
>
> Looks pretty close to obfuscated c code contents... Can't you use !=

wrrr...

> or kill ! in second clause and use == or something?
> 								Pavel

is

	if (((stat & DRQ_STAT) != 0) ^ (rq->current_nr_sectors != 0))

better?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ide-taskfile.c fixups/cleanups part #2 [1/9]
  2004-07-02 16:43   ` Bartlomiej Zolnierkiewicz
@ 2004-07-02 19:20     ` Pavel Machek
  0 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2004-07-02 19:20 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel

Hi!

> > > diff -puN drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes
> > > drivers/ide/ide-taskfile.c ---
> > > linux-2.6.7-bk11/drivers/ide/ide-taskfile.c~ide_tf_pio_out_fixes	2004-06-
> > >28 21:15:54.030210376 +0200 +++
> > > linux-2.6.7-bk11-bzolnier/drivers/ide/ide-taskfile.c	2004-06-28
> > > 21:15:54.035209616 +0200 @@ -409,6 +409,10 @@ ide_startstop_t
> > > task_out_intr (ide_drive
> > >  	if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), DRIVE_READY,
> > > drive->bad_wstat)) { return DRIVER(drive)->error(drive, "task_out_intr",
> > > stat);
> > >  	}
> > > +
> > > +	if (((stat & DRQ_STAT) == 0) ^ !rq->current_nr_sectors)
> > > +		return DRIVER(drive)->error(drive, __FUNCTION__, stat);
> > > +
> >
> > Looks pretty close to obfuscated c code contents... Can't you use !=
> 
> wrrr...
> 
> > or kill ! in second clause and use == or something?
> > 								Pavel
> 
> is
> 
> 	if (((stat & DRQ_STAT) != 0) ^ (rq->current_nr_sectors != 0))
> 
> better?

Not much... maybe its just me but I find bitwise xor hard to read in
logical expression. Perhaps

 	if (!(stat & DRQ_STAT) != !rq->current_nr_sectors)
?

								Pavel
-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-07-02 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-30 15:24 [PATCH] ide-taskfile.c fixups/cleanups part #2 [1/9] Bartlomiej Zolnierkiewicz
2004-07-02 12:20 ` Pavel Machek
2004-07-02 16:43   ` Bartlomiej Zolnierkiewicz
2004-07-02 19:20     ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).