Move wdc_kill_pending() to ata.c and rename it ata_kill_pending().

This commit is contained in:
thorpej 2004-08-12 22:33:45 +00:00
parent 2600c55e01
commit 2eaa5c6142
5 changed files with 45 additions and 44 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata.c,v 1.41 2004/08/12 21:34:52 thorpej Exp $ */
/* $NetBSD: ata.c,v 1.42 2004/08/12 22:33:46 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.41 2004/08/12 21:34:52 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.42 2004/08/12 22:33:46 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@ -529,6 +529,40 @@ ata_free_xfer(struct wdc_channel *chp, struct ata_xfer *xfer)
splx(s);
}
/*
* Kill off all pending xfers for a wdc_channel.
*
* Must be called at splbio().
*/
void
ata_kill_pending(struct ata_drive_datas *drvp)
{
struct wdc_channel *chp = drvp->chnl_softc;
struct ata_xfer *xfer, *next_xfer;
int s = splbio();
for (xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer);
xfer != NULL; xfer = next_xfer) {
next_xfer = TAILQ_NEXT(xfer, c_xferchain);
if (xfer->c_chp != chp || xfer->c_drive != drvp->drive)
continue;
TAILQ_REMOVE(&chp->ch_queue->queue_xfer, xfer, c_xferchain);
(*xfer->c_kill_xfer)(chp, xfer, KILL_GONE);
}
while ((xfer = chp->ch_queue->active_xfer) != NULL) {
if (xfer->c_chp == chp && xfer->c_drive == drvp->drive) {
drvp->drive_flags |= DRIVE_WAITDRAIN;
(void) tsleep(&chp->ch_queue->active_xfer,
PRIBIO, "atdrn", 0);
} else {
/* no more xfer for us */
break;
}
}
splx(s);
}
void
ata_print_modes(struct wdc_channel *chp)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata_wdc.c,v 1.65 2004/08/12 21:34:52 thorpej Exp $ */
/* $NetBSD: ata_wdc.c,v 1.66 2004/08/12 22:33:46 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.65 2004/08/12 21:34:52 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.66 2004/08/12 22:33:46 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@ -137,7 +137,7 @@ const struct ata_bustype wdc_ata_bustype = {
ata_get_params,
wdc_ata_addref,
wdc_ata_delref,
wdc_kill_pending,
ata_kill_pending,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: atavar.h,v 1.54 2004/08/12 21:34:52 thorpej Exp $ */
/* $NetBSD: atavar.h,v 1.55 2004/08/12 22:33:46 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@ -313,6 +313,8 @@ void ata_free_xfer(struct wdc_channel *, struct ata_xfer *);
#define ATAXF_CANSLEEP 0x00
#define ATAXF_NOSLEEP 0x01
void ata_kill_pending(struct ata_drive_datas *);
void ata_print_modes(struct wdc_channel *);
int ata_downgrade_mode(struct ata_drive_datas *, int);
void ata_probe_caps(struct ata_drive_datas *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc.c,v 1.198 2004/08/12 21:34:52 thorpej Exp $ */
/* $NetBSD: wdc.c,v 1.199 2004/08/12 22:33:45 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.198 2004/08/12 21:34:52 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.199 2004/08/12 22:33:45 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@ -1825,40 +1825,6 @@ wdc_exec_xfer(struct wdc_channel *chp, struct ata_xfer *xfer)
wdcstart(chp);
}
/*
* Kill off all pending xfers for a wdc_channel.
*
* Must be called at splbio().
*/
void
wdc_kill_pending(struct ata_drive_datas *drvp)
{
struct wdc_channel *chp = drvp->chnl_softc;
struct ata_xfer *xfer, *next_xfer;
int s = splbio();
for (xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer);
xfer != NULL; xfer = next_xfer) {
next_xfer = TAILQ_NEXT(xfer, c_xferchain);
if (xfer->c_chp != chp || xfer->c_drive != drvp->drive)
continue;
TAILQ_REMOVE(&chp->ch_queue->queue_xfer, xfer, c_xferchain);
(*xfer->c_kill_xfer)(chp, xfer, KILL_GONE);
}
while ((xfer = chp->ch_queue->active_xfer) != NULL) {
if (xfer->c_chp == chp && xfer->c_drive == drvp->drive) {
drvp->drive_flags |= DRIVE_WAITDRAIN;
(void) tsleep(&chp->ch_queue->active_xfer,
PRIBIO, "atdrn", 0);
} else {
/* no more xfer for us */
break;
}
}
splx(s);
}
static void
__wdcerror(struct wdc_channel *chp, char *msg)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdcvar.h,v 1.69 2004/08/12 21:34:52 thorpej Exp $ */
/* $NetBSD: wdcvar.h,v 1.70 2004/08/12 22:33:45 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@ -223,7 +223,6 @@ int wdc_exec_command(struct ata_drive_datas *, struct ata_command*);
int wdc_addref(struct wdc_channel *);
void wdc_delref(struct wdc_channel *);
void wdc_kill_pending(struct ata_drive_datas *);
/*
* ST506 spec says that if READY or SEEKCMPLT go off, then the read or write