1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

Convert three drivers not covered by any of our kernel configs.

We really need a LINT98 and possibly LINTALPHA kernels.
This commit is contained in:
Poul-Henning Kamp 2000-04-18 13:21:46 +00:00
parent 19583a8007
commit 0991b97a30
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59362
2 changed files with 58 additions and 58 deletions

View File

@ -128,7 +128,7 @@ struct wfd {
int flags; /* Device state flags */
int refcnt; /* The number of raw opens */
int maxblks; /* transfer size limit */
struct buf_queue_head buf_queue; /* Queue of i/o requests */
struct bio_queue_head buf_queue; /* Queue of i/o requests */
struct atapi_params *param; /* Drive parameters table */
struct cappage cap; /* Capabilities page info */
char description[80]; /* Device description */
@ -141,7 +141,7 @@ static struct wfd *wfdtab[NUNIT]; /* Drive info by unit number */
static int wfdnlun = 0; /* Number of configured drives */
static void wfd_start (struct wfd *t);
static void wfd_done (struct wfd *t, struct buf *bp, int resid,
static void wfd_done (struct wfd *t, struct bio *bp, int resid,
struct atapires result);
static void wfd_error (struct wfd *t, struct atapires result);
static int wfd_request_wait (struct wfd *t, u_char cmd, u_char a1, u_char a2,
@ -186,7 +186,7 @@ wfdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug)
}
wfdtab[wfdnlun] = t;
bzero (t, sizeof (struct wfd));
bufq_init(&t->buf_queue);
bioq_init(&t->buf_queue);
t->ata = ata;
t->unit = unit;
lun = t->lun = wfdnlun;
@ -397,21 +397,21 @@ int wfdclose (dev_t dev, int flags, int fmt, struct proc *p)
* understand. The transfer is described by a buf and will include only one
* physical transfer.
*/
void wfdstrategy (struct buf *bp)
void wfdstrategy (struct bio *bp)
{
int lun = UNIT(bp->b_dev);
int lun = UNIT(bp->bio_dev);
struct wfd *t = wfdtab[lun];
int x;
/* If it's a null transfer, return immediatly. */
if (bp->b_bcount == 0) {
bp->b_resid = 0;
if (bp->bio_bcount == 0) {
bp->bio_resid = 0;
biodone (bp);
return;
}
/*
* Do bounds checking, adjust transfer, and set b_pblkno.
* Do bounds checking, adjust transfer, and set bio_pblkno.
*/
if (dscheck(bp, t->dk_slices) <= 0) {
biodone(bp);
@ -421,7 +421,7 @@ void wfdstrategy (struct buf *bp)
x = splbio();
/* Place it in the queue of disk activities for this disk. */
bufqdisksort (&t->buf_queue, bp);
bioqdisksort (&t->buf_queue, bp);
/* Tell the device to get going on the transfer if it's
* not doing anything, otherwise just wait for completion. */
@ -439,7 +439,7 @@ void wfdstrategy (struct buf *bp)
*/
static void wfd_start (struct wfd *t)
{
struct buf *bp = bufq_first(&t->buf_queue);
struct bio *bp = bioq_first(&t->buf_queue);
u_long blkno, nblk;
u_char op_code;
long count;
@ -452,7 +452,7 @@ static void wfd_start (struct wfd *t)
return;
/* Unqueue the request. */
bufq_remove(&t->buf_queue, bp);
bioq_remove(&t->buf_queue, bp);
/* Tell devstat we are starting on the transaction */
devstat_start_transaction(&t->device_stats);
@ -460,27 +460,27 @@ static void wfd_start (struct wfd *t)
/* We have a buf, now we should make a command
* First, translate the block to absolute and put it in terms of the
* logical blocksize of the device. */
blkno = bp->b_pblkno / (t->cap.sector_size / 512);
nblk = (bp->b_bcount + (t->cap.sector_size - 1)) / t->cap.sector_size;
blkno = bp->bio_pblkno / (t->cap.sector_size / 512);
nblk = (bp->bio_bcount + (t->cap.sector_size - 1)) / t->cap.sector_size;
if ((t->maxblks == 0) || (nblk <= t->maxblks)) {
if(bp->b_flags & B_READ) {
if(bp->bio_cmd & BIO_READ) {
op_code = ATAPI_READ_BIG;
count = bp->b_bcount;
count = bp->bio_bcount;
} else {
op_code = ATAPI_WRITE_BIG;
count = -bp->b_bcount;
count = -bp->bio_bcount;
}
/* only one transfer */
(int)bp->b_driver1 = 0;
(int)bp->b_driver2 = 0;
(int)bp->bio_driver1 = 0;
(int)bp->bio_driver2 = 0;
atapi_request_callback (t->ata, t->unit, op_code, 0,
blkno>>24, blkno>>16, blkno>>8, blkno,
0, nblk>>8, nblk, 0, 0,
0, 0, 0, 0, 0,
(u_char*) bp->b_data, count,
(u_char*) bp->bio_data, count,
(void*)wfd_done, t, bp);
} else {
@ -488,22 +488,22 @@ static void wfd_start (struct wfd *t)
* We can't handle this request in a single
* read/write operation. Instead, queue a set of
* transfers, and record the number of transfers
* and the running residual in the b_driver
* and the running residual in the bio_driver
* fields of the bp.
*/
if(bp->b_flags & B_READ) {
if(bp->bio_cmd & BIO_READ) {
op_code = ATAPI_READ_BIG;
} else {
op_code = ATAPI_WRITE_BIG;
}
/* calculate number of transfers */
(int)bp->b_driver1 = (nblk - 1) / t->maxblks;
(int)bp->b_driver2 = 0;
(int)bp->bio_driver1 = (nblk - 1) / t->maxblks;
(int)bp->bio_driver2 = 0;
pxdest = (u_char *)bp->b_data;
pxcount = bp->b_bcount;
pxdest = (u_char *)bp->bio_data;
pxcount = bp->bio_bcount;
/* construct partial transfer requests */
while (nblk > 0) {
@ -515,7 +515,7 @@ static void wfd_start (struct wfd *t)
blkno, 0, pxnblk>>8, pxnblk,
0, 0, 0, 0, 0, 0, 0,
pxdest,
(bp->b_flags & B_READ) ?
(bp->bio_cmd & BIO_READ) ?
count : -count,
(void*)wfd_done, t, bp);
nblk -= pxnblk;
@ -526,25 +526,25 @@ static void wfd_start (struct wfd *t)
}
}
static void wfd_done (struct wfd *t, struct buf *bp, int resid,
static void wfd_done (struct wfd *t, struct bio *bp, int resid,
struct atapires result)
{
if (result.code) {
wfd_error (t, result);
bp->b_error = EIO;
bp->b_ioflags |= BIO_ERROR;
bp->bio_error = EIO;
bp->bio_flags |= BIO_ERROR;
} else
(int)bp->b_driver2 += resid;
(int)bp->bio_driver2 += resid;
/*
* We can't call biodone until all outstanding
* transfer fragments are handled. If one hits
* an error, we will be returning an error, but
* only when all are complete.
*/
if (((int)bp->b_driver1)-- <= 0) {
bp->b_resid = (int)bp->b_driver2;
devstat_end_transaction_buf(&t->device_stats, bp);
if (((int)bp->bio_driver1)-- <= 0) {
bp->bio_resid = (int)bp->bio_driver2;
devstat_end_transaction_bio(&t->device_stats, bp);
biodone (bp);
}

View File

@ -179,7 +179,7 @@ struct wst {
int lun; /* Logical device unit */
int flags; /* Device state flags */
int blksize; /* Block size (512 | 1024) */
struct buf_queue_head buf_queue; /* Queue of i/o requests */
struct bio_queue_head buf_queue; /* Queue of i/o requests */
struct atapi_params *param; /* Drive parameters table */
struct wst_header header; /* MODE SENSE param header */
struct wst_cappage cap; /* Capabilities page info */
@ -193,7 +193,7 @@ static int wst_sense(struct wst *t);
static void wst_describe(struct wst *t);
static void wst_poll_dsc(struct wst *t);
static void wst_start(struct wst *t);
static void wst_done(struct wst *t, struct buf *bp, int resid, struct atapires result);
static void wst_done(struct wst *t, struct bio *bp, int resid, struct atapires result);
static int wst_error(struct wst *t, struct atapires result);
static void wst_drvinit(void *unused);
static int wst_space_cmd(struct wst *t, u_char function, u_int count);
@ -241,7 +241,7 @@ wstattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug)
}
wsttab[wstnlun] = t;
bzero(t, sizeof(struct wst));
bufq_init(&t->buf_queue);
bioq_init(&t->buf_queue);
t->ata = ata;
t->unit = unit;
t->ata->use_dsc = 1;
@ -380,39 +380,39 @@ wstclose(dev_t dev, int flags, int fmt, struct proc *p)
}
void
wststrategy(struct buf *bp)
wststrategy(struct bio *bp)
{
int lun = UNIT(bp->b_dev);
int lun = UNIT(bp->bio_dev);
struct wst *t = wsttab[lun];
int x;
/* If it's a null transfer, return immediatly. */
if (bp->b_bcount == 0) {
bp->b_resid = 0;
if (bp->bio_bcount == 0) {
bp->bio_resid = 0;
biodone(bp);
return;
}
/* Check for != blocksize requests */
if (bp->b_bcount % t->blksize) {
if (bp->bio_bcount % t->blksize) {
printf("wst%d: bad request, must be multiple of %d\n", lun, t->blksize);
bp->b_error = EIO;
bp->b_ioflags |= BIO_ERROR;
bp->bio_error = EIO;
bp->bio_flags |= BIO_ERROR;
biodone(bp);
return;
}
if (bp->b_bcount > t->blksize*t->cap.ctl) {
if (bp->bio_bcount > t->blksize*t->cap.ctl) {
if ((t->flags & WST_CTL_WARN) == 0) {
printf("wst%d: WARNING: CTL exceeded %ld>%d\n",
lun, bp->b_bcount, t->blksize*t->cap.ctl);
lun, bp->bio_bcount, t->blksize*t->cap.ctl);
t->flags |= WST_CTL_WARN;
}
}
x = splbio();
wst_total += bp->b_bcount;
bufq_insert_tail(&t->buf_queue, bp);
wst_total += bp->bio_bcount;
bioq_insert_tail(&t->buf_queue, bp);
wst_start(t);
splx(x);
}
@ -432,7 +432,7 @@ wst_poll_dsc(struct wst *t)
static void
wst_start(struct wst *t)
{
struct buf *bp = bufq_first(&t->buf_queue);
struct bio *bp = bioq_first(&t->buf_queue);
u_long blk_count;
u_char op_code;
long byte_count;
@ -450,37 +450,37 @@ wst_start(struct wst *t)
tsleep((caddr_t) t, 0, "wstdsc", 0);
}
bufq_remove(&t->buf_queue, bp);
blk_count = bp->b_bcount / t->blksize;
bioq_remove(&t->buf_queue, bp);
blk_count = bp->bio_bcount / t->blksize;
if (bp->b_flags & B_READ) {
if (bp->bio_cmd & BIO_READ) {
op_code = ATAPI_TAPE_READ_CMD;
byte_count = bp->b_bcount;
byte_count = bp->bio_bcount;
} else {
op_code = ATAPI_TAPE_WRITE_CMD;
t->flags |= WST_DATA_WRITTEN;
byte_count = -bp->b_bcount;
byte_count = -bp->bio_bcount;
}
atapi_request_callback(t->ata, t->unit, op_code, 1,
blk_count>>16, blk_count>>8, blk_count,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
(u_char*) bp->b_data, byte_count,
(u_char*) bp->bio_data, byte_count,
(void*)wst_done, t, bp);
}
static void
wst_done(struct wst *t, struct buf *bp, int resid,
wst_done(struct wst *t, struct bio *bp, int resid,
struct atapires result)
{
if (result.code) {
printf("wst_done: ");
wst_error(t, result);
bp->b_error = EIO;
bp->b_ioflags |= BIO_ERROR;
bp->bio_error = EIO;
bp->bio_flags |= BIO_ERROR;
}
else
bp->b_resid = resid;
bp->bio_resid = resid;
biodone(bp);
/*wst_start(t);*/