diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-04-12 11:33:14 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-04-12 11:33:14 +0000 |
commit | 148bc5ddc98fe1eeb56bd565312e7d9ee13ab5ee (patch) | |
tree | 0b68db22340ea2d0e166a9b14c3dde9091e4d25c /sys/scsi/cd.c | |
parent | 713b6626e7fa8eb042aa3ed6287f8a4f41dc6ea4 (diff) |
Add cd_kill_buffers() as a separate function, like sd_kill_buffers()
and for the same reason of preparing for safer handling of users
yanking usb devices out. No functional change.
Copied from bluhm@'s change to sd.c.
Diffstat (limited to 'sys/scsi/cd.c')
-rw-r--r-- | sys/scsi/cd.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index 8940d1bb30b..231dcaac737 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.121 2007/04/10 17:47:56 miod Exp $ */ +/* $OpenBSD: cd.c,v 1.122 2007/04/12 11:33:13 krw Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -108,6 +108,7 @@ void cdgetdisklabel(dev_t, struct cd_softc *, struct disklabel *, struct cpu_disklabel *, int); void cddone(struct scsi_xfer *); u_long cd_size(struct cd_softc *, int); +void cd_kill_buffers(struct cd_softc *); void lba2msf(u_long, u_char *, u_char *, u_char *); u_long msf2lba(u_char, u_char, u_char); int cd_setchan(struct cd_softc *, int, int, int, int, int); @@ -261,19 +262,9 @@ cddetach(self, flags) int flags; { struct cd_softc *cd = (struct cd_softc *)self; - struct buf *dp, *bp; - int s, bmaj, cmaj, mn; + int bmaj, cmaj, mn; - /* Remove unprocessed buffers from queue */ - s = splbio(); - for (dp = &cd->buf_queue; (bp = dp->b_actf) != NULL; ) { - dp->b_actf = bp->b_actf; - - bp->b_error = ENXIO; - bp->b_flags |= B_ERROR; - biodone(bp); - } - splx(s); + cd_kill_buffers(cd); /* locate the minor number */ mn = CDMINOR(self->dv_unit, 0); @@ -2124,3 +2115,23 @@ cd_interpret_sense(xs) } return (EJUSTRETURN); /* use generic handler in scsi_base */ } + +/* + * Remove unprocessed buffers from queue. + */ +void +cd_kill_buffers(struct cd_softc *cd) +{ + struct buf *dp, *bp; + int s; + + s = splbio(); + for (dp = &cd->buf_queue; (bp = dp->b_actf) != NULL; ) { + dp->b_actf = bp->b_actf; + + bp->b_error = ENXIO; + bp->b_flags |= B_ERROR; + biodone(bp); + } + splx(s); +} |