summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-10-05 15:49:39 +0000
committerphk <phk@FreeBSD.org>2002-10-05 15:49:39 +0000
commit6bb5f004e13113c8e17149184fb05458048d72cc (patch)
tree1ca924e75ce78bc51d2fbf2e709ff914411b9a6c
parentde27611d217b814c30bb86b0224235c8322c2ec5 (diff)
downloadFreeBSD-src-6bb5f004e13113c8e17149184fb05458048d72cc.zip
FreeBSD-src-6bb5f004e13113c8e17149184fb05458048d72cc.tar.gz
Don't use dkunit() to find our softc when we can hang it off the dev_t.
This removes yet a dependency on the old disklabel stuff. Sponsored by: DARPA & NAI Labs.
-rw-r--r--sys/pc98/pc98/wd.c28
-rw-r--r--sys/pc98/pc98/wd_cd.c23
2 files changed, 24 insertions, 27 deletions
diff --git a/sys/pc98/pc98/wd.c b/sys/pc98/pc98/wd.c
index 3c24a21a..a74ad8b 100644
--- a/sys/pc98/pc98/wd.c
+++ b/sys/pc98/pc98/wd.c
@@ -471,6 +471,7 @@ wdattach(struct isa_device *dvp)
struct wdparams *wp;
static char buf[] = "wdcXXX";
const char *dname;
+ dev_t dev;
dvp->id_intr = wdintr;
@@ -598,8 +599,10 @@ wdattach(struct isa_device *dvp)
/*
* Register this media as a disk
*/
- disk_create(lunit, &du->disk, 0, &wd_cdevsw,
+ dev = disk_create(lunit, &du->disk, 0, &wd_cdevsw,
&wddisk_cdevsw);
+ dev->si_drv1 = &wddrives[lunit];
+
} else {
free(du, M_TEMP);
wddrives[lunit] = NULL;
@@ -645,17 +648,18 @@ void
wdstrategy(register struct bio *bp)
{
struct softc *du;
- int lunit = dkunit(bp->bio_dev);
+ int lunit;
int s;
- /* valid unit, controller, and request? */
- if (lunit >= NWD || bp->bio_blkno < 0 || (du = wddrives[lunit]) == NULL
- || bp->bio_bcount % DEV_BSIZE != 0) {
+ du = bp->bio_dev->si_drv1;
+ if (du == NULL || bp->bio_blkno < 0 ||
+ bp->bio_bcount % DEV_BSIZE != 0) {
bp->bio_error = EINVAL;
bp->bio_flags |= BIO_ERROR;
goto done;
}
+ lunit = du->dk_unit;
#ifdef PC98
outb(0x432,(du->dk_unit)%2);
@@ -768,8 +772,8 @@ wdstart(int ctrlr)
}
/* obtain controller and drive information */
- lunit = dkunit(bp->bio_dev);
- du = wddrives[lunit];
+ du = bp->bio_dev->si_drv1;
+ lunit = du->dk_unit;
#ifdef PC98
outb(0x432,(du->dk_unit)%2);
@@ -1033,7 +1037,7 @@ wdintr(void *unitnum)
return;
}
bp = bioq_first(&wdtab[unit].controller_queue);
- du = wddrives[dkunit(bp->bio_dev)];
+ du = bp->bio_dev->si_drv1;
#ifdef PC98
outb(0x432,(du->dk_unit)%2);
@@ -1227,13 +1231,9 @@ done: ;
int
wdopen(dev_t dev, int flags, int fmt, struct thread *td)
{
- register unsigned int lunit;
register struct softc *du;
- lunit = dkunit(dev);
- if (lunit >= NWD || dksparebits(dev) != 0)
- return (ENXIO);
- du = wddrives[lunit];
+ du = dev->si_drv1;
if (du == NULL)
return (ENXIO);
@@ -1279,7 +1279,7 @@ wdcontrol(register struct bio *bp)
register struct softc *du;
int ctrlr;
- du = wddrives[dkunit(bp->bio_dev)];
+ du = bp->bio_dev->si_drv1;
ctrlr = du->dk_ctrlr_cmd640;
#ifdef PC98
diff --git a/sys/pc98/pc98/wd_cd.c b/sys/pc98/pc98/wd_cd.c
index f0e6093..a9c07fe 100644
--- a/sys/pc98/pc98/wd_cd.c
+++ b/sys/pc98/pc98/wd_cd.c
@@ -128,15 +128,15 @@ acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun,
else
ptr->device_stats = device_stats;
- make_dev(&acd_cdevsw, dkmakeminor(lun, 0, 0),
+ pdev = make_dev(&acd_cdevsw, dkmakeminor(lun, 0, 0),
UID_ROOT, GID_OPERATOR, 0640, "wcd%da", lun);
- pdev = makedev(acd_cdevsw.d_maj, dkmakeminor(lun, 0, 0));
make_dev_alias(pdev, "rwcd%da", lun);
+ pdev->si_drv1 = ptr;
- make_dev(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART),
+ pdev = make_dev(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART),
UID_ROOT, GID_OPERATOR, 0640, "wcd%dc", lun);
- pdev = makedev(acd_cdevsw.d_maj, dkmakeminor(lun, 0, RAW_PART));
make_dev_alias(pdev, "rwcd%dc", lun);
+ pdev->si_drv1 = ptr;
return ptr;
}
@@ -381,12 +381,11 @@ acd_describe(struct acd *cdp)
static int
acdopen(dev_t dev, int flags, int fmt, struct thread *td)
{
- int lun = dkunit(dev);
struct acd *cdp;
- if (lun >= acdnlun || !atapi_request_immediate)
+ cdp = dev->si_drv1;
+ if (cdp == NULL)
return ENXIO;
- cdp = acdtab[lun];
if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) {
/* Prevent user eject */
@@ -400,14 +399,14 @@ acdopen(dev_t dev, int flags, int fmt, struct thread *td)
++cdp->refcnt;
dev->si_bsize_phys = cdp->block_size;
if (!(flags & O_NONBLOCK) && acd_read_toc(cdp) && !(flags & FWRITE))
- printf("acd%d: read_toc failed\n", lun);
+ printf("acd%d: read_toc failed\n", cdp->unit);
return 0;
}
int
acdclose(dev_t dev, int flags, int fmt, struct thread *td)
{
- struct acd *cdp = acdtab[dkunit(dev)];
+ struct acd *cdp = dev->si_drv1;
if (fmt == S_IFBLK)
cdp->flags &= ~F_BOPEN;
@@ -434,8 +433,7 @@ acdclose(dev_t dev, int flags, int fmt, struct thread *td)
void
acdstrategy(struct bio *bp)
{
- int lun = dkunit(bp->bio_dev);
- struct acd *cdp = acdtab[lun];
+ struct acd *cdp = bp->bio_dev->si_drv1;
int x;
#ifdef NOTYET
@@ -578,8 +576,7 @@ msf2lba(u_char m, u_char s, u_char f)
int
acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
{
- int lun = dkunit(dev);
- struct acd *cdp = acdtab[lun];
+ struct acd *cdp = dev->si_drv1;
int error = 0;
if (cdp->flags & F_MEDIA_CHANGED)
OpenPOWER on IntegriCloud