NO_GEOM cleanup:

Move ida driver to "struct disk *" centric api.

Retire major number 109.
This commit is contained in:
Poul-Henning Kamp 2003-02-23 18:45:50 +00:00
parent 7d0bbeb87c
commit e5dc8339ae
5 changed files with 19 additions and 67 deletions

View File

@ -126,7 +126,7 @@ chrdev name comments
106 smb System Management Bus generic i/o 106 smb System Management Bus generic i/o
107 3dfx 3Dfx driver <cokane> 107 3dfx 3Dfx driver <cokane>
108 usb Universal Serial Bus <n_hibma> 108 usb Universal Serial Bus <n_hibma>
109 ida Intelligent Disk [Array] (md@doc.ic.ac.uk) 109
110 ses SCSI Environmental Services driver (mjacob@feral.com) 110 ses SCSI Environmental Services driver (mjacob@feral.com)
111 ums USB Mouse <n_hibma> 111 ums USB Mouse <n_hibma>
112 kbd keyboard 112 kbd keyboard

View File

@ -47,6 +47,7 @@
#include <sys/bio.h> #include <sys/bio.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <sys/devicestat.h> #include <sys/devicestat.h>
#include <sys/conf.h>
#include <sys/disk.h> #include <sys/disk.h>
#include <machine/bus_memio.h> #include <machine/bus_memio.h>

View File

@ -58,31 +58,10 @@ static int idad_probe(device_t dev);
static int idad_attach(device_t dev); static int idad_attach(device_t dev);
static int idad_detach(device_t dev); static int idad_detach(device_t dev);
static d_open_t idad_open;
static d_close_t idad_close;
static d_strategy_t idad_strategy; static d_strategy_t idad_strategy;
static dumper_t idad_dump; static dumper_t idad_dump;
#define IDAD_CDEV_MAJOR 109
static struct cdevsw id_cdevsw = {
/* open */ idad_open,
/* close */ idad_close,
/* read */ physread,
/* write */ physwrite,
/* ioctl */ noioctl,
/* poll */ nopoll,
/* mmap */ nommap,
/* strategy */ idad_strategy,
/* name */ "idad",
/* maj */ IDAD_CDEV_MAJOR,
/* dump */ idad_dump,
/* psize */ nopsize,
/* flags */ D_DISK,
};
static devclass_t idad_devclass; static devclass_t idad_devclass;
static struct cdevsw idaddisk_cdevsw;
static device_method_t idad_methods[] = { static device_method_t idad_methods[] = {
DEVMETHOD(device_probe, idad_probe), DEVMETHOD(device_probe, idad_probe),
@ -99,41 +78,6 @@ static driver_t idad_driver = {
DRIVER_MODULE(idad, ida, idad_driver, idad_devclass, 0, 0); DRIVER_MODULE(idad, ida, idad_driver, idad_devclass, 0, 0);
static __inline struct idad_softc *
idad_getsoftc(dev_t dev)
{
return ((struct idad_softc *)dev->si_drv1);
}
static int
idad_open(dev_t dev, int flags, int fmt, struct thread *td)
{
struct idad_softc *drv;
drv = idad_getsoftc(dev);
if (drv == NULL)
return (ENXIO);
drv->disk.d_sectorsize = drv->secsize;
drv->disk.d_mediasize = (off_t)drv->secperunit * drv->secsize;
drv->disk.d_fwsectors = drv->sectors;
drv->disk.d_fwheads = drv->heads;
return (0);
}
static int
idad_close(dev_t dev, int flags, int fmt, struct thread *td)
{
struct idad_softc *drv;
drv = idad_getsoftc(dev);
if (drv == NULL)
return (ENXIO);
return (0);
}
/* /*
* Read/write routine for a buffer. Finds the proper unit, range checks * Read/write routine for a buffer. Finds the proper unit, range checks
* arguments, and schedules the transfer. Does not wait for the transfer * arguments, and schedules the transfer. Does not wait for the transfer
@ -146,7 +90,7 @@ idad_strategy(struct bio *bp)
struct idad_softc *drv; struct idad_softc *drv;
int s; int s;
drv = idad_getsoftc(bp->bio_dev); drv = bp->bio_disk->d_drv1;
if (drv == NULL) { if (drv == NULL) {
bp->bio_error = EINVAL; bp->bio_error = EINVAL;
goto bad; goto bad;
@ -160,7 +104,6 @@ idad_strategy(struct bio *bp)
goto bad; goto bad;
} }
bp->bio_driver1 = drv;
s = splbio(); s = splbio();
devstat_start_transaction(&drv->stats); devstat_start_transaction(&drv->stats);
ida_submit_buf(drv->controller, bp); ida_submit_buf(drv->controller, bp);
@ -187,7 +130,7 @@ idad_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t l
struct disk *dp; struct disk *dp;
dp = arg; dp = arg;
drv = idad_getsoftc(dp->d_dev); drv = dp->d_drv1;
if (drv == NULL) if (drv == NULL)
return (ENXIO); return (ENXIO);
@ -204,7 +147,9 @@ idad_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t l
void void
idad_intr(struct bio *bp) idad_intr(struct bio *bp)
{ {
struct idad_softc *drv = (struct idad_softc *)bp->bio_driver1; struct idad_softc *drv;
drv = bp->bio_disk->d_drv1;
if (bp->bio_flags & BIO_ERROR) if (bp->bio_flags & BIO_ERROR)
bp->bio_error = EIO; bp->bio_error = EIO;
@ -228,7 +173,6 @@ idad_attach(device_t dev)
struct ida_drive_info dinfo; struct ida_drive_info dinfo;
struct idad_softc *drv; struct idad_softc *drv;
device_t parent; device_t parent;
dev_t dsk;
int error; int error;
drv = (struct idad_softc *)device_get_softc(dev); drv = (struct idad_softc *)device_get_softc(dev);
@ -263,11 +207,16 @@ idad_attach(device_t dev)
DEVSTAT_TYPE_STORARRAY| DEVSTAT_TYPE_IF_OTHER, DEVSTAT_TYPE_STORARRAY| DEVSTAT_TYPE_IF_OTHER,
DEVSTAT_PRIORITY_ARRAY); DEVSTAT_PRIORITY_ARRAY);
dsk = disk_create(drv->unit, &drv->disk, 0, drv->disk.d_strategy = idad_strategy;
&id_cdevsw, &idaddisk_cdevsw); drv->disk.d_name = "idad";
drv->disk.d_dump = idad_dump;
dsk->si_drv1 = drv; drv->disk.d_sectorsize = drv->secsize;
dsk->si_iosize_max = DFLTPHYS; /* XXX guess? */ drv->disk.d_mediasize = (off_t)drv->secperunit * drv->secsize;
drv->disk.d_fwsectors = drv->sectors;
drv->disk.d_fwheads = drv->heads;
drv->disk.d_drv1 = drv;
drv->disk.d_maxsize = DFLTPHYS; /* XXX guess? */
disk_create(drv->unit, &drv->disk, 0, NULL, NULL);
return (0); return (0);
} }

View File

@ -34,6 +34,7 @@
#include <sys/bio.h> #include <sys/bio.h>
#include <sys/devicestat.h> #include <sys/devicestat.h>
#include <sys/conf.h>
#include <sys/disk.h> #include <sys/disk.h>
#include <machine/bus_pio.h> #include <machine/bus_pio.h>

View File

@ -33,6 +33,7 @@
#include <sys/bio.h> #include <sys/bio.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <sys/devicestat.h> #include <sys/devicestat.h>
#include <sys/conf.h>
#include <sys/disk.h> #include <sys/disk.h>
#include <machine/bus_memio.h> #include <machine/bus_memio.h>