summaryrefslogtreecommitdiffstats
path: root/sys/dev/twe
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-02-25 07:41:51 +0000
committerphk <phk@FreeBSD.org>2003-02-25 07:41:51 +0000
commit6a119a04ae59d3b4c5e6434f74c94ca18d21173b (patch)
treeabb5d7d16b8508978876b9ee52da8c8e1027db79 /sys/dev/twe
parentd5d524487ff396c03df98188b4b16283acc1b2fb (diff)
downloadFreeBSD-src-6a119a04ae59d3b4c5e6434f74c94ca18d21173b.zip
FreeBSD-src-6a119a04ae59d3b4c5e6434f74c94ca18d21173b.tar.gz
NO_GEOM cleanup:
Move to new "struct disk *" centric API. Retire major #147 (twed)
Diffstat (limited to 'sys/dev/twe')
-rw-r--r--sys/dev/twe/twe_compat.h4
-rw-r--r--sys/dev/twe/twe_freebsd.c53
2 files changed, 18 insertions, 39 deletions
diff --git a/sys/dev/twe/twe_compat.h b/sys/dev/twe/twe_compat.h
index 2dc17b5..3d10434 100644
--- a/sys/dev/twe/twe_compat.h
+++ b/sys/dev/twe/twe_compat.h
@@ -165,8 +165,8 @@ typedef struct bio_queue_head twe_bioq;
# define TWE_BIO_DATA(bp) (bp)->bio_data
# define TWE_BIO_LENGTH(bp) (bp)->bio_bcount
# define TWE_BIO_LBA(bp) (bp)->bio_pblkno
-# define TWE_BIO_SOFTC(bp) (bp)->bio_dev->si_drv1
-# define TWE_BIO_UNIT(bp) *(int *)((bp)->bio_dev->si_drv2)
+# define TWE_BIO_SOFTC(bp) (bp)->bio_disk->d_drv1
+# define TWE_BIO_UNIT(bp) (bp)->bio_disk->d_unit
# define TWE_BIO_SET_ERROR(bp, err) do { (bp)->bio_error = err; (bp)->bio_flags |= BIO_ERROR;} while(0)
# define TWE_BIO_HAS_ERROR(bp) ((bp)->bio_flags & BIO_ERROR)
# define TWE_BIO_RESID(bp) (bp)->bio_resid
diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c
index cc6efca..7acdbad 100644
--- a/sys/dev/twe/twe_freebsd.c
+++ b/sys/dev/twe/twe_freebsd.c
@@ -544,7 +544,6 @@ twe_clear_pci_abort(struct twe_softc *sc)
struct twed_softc
{
device_t twed_dev;
- dev_t twed_dev_t;
struct twe_softc *twed_controller; /* parent device softc */
struct twe_drive *twed_drive; /* drive data in parent softc */
struct disk twed_disk; /* generic disk handle */
@@ -581,29 +580,7 @@ DRIVER_MODULE(twed, twe, twed_driver, twed_devclass, 0, 0);
/*
* Disk device control interface.
*/
-static d_open_t twed_open;
-static d_strategy_t twed_strategy;
-static dumper_t twed_dump;
-
-#define TWED_CDEV_MAJOR 147
-
-static struct cdevsw twed_cdevsw = {
- twed_open,
- nullclose,
- physread,
- physwrite,
- noioctl,
- nopoll,
- nommap,
- twed_strategy,
- "twed",
- TWED_CDEV_MAJOR,
- twed_dump,
- nopsize,
- D_DISK
-};
-static struct cdevsw tweddisk_cdevsw;
#ifdef FREEBSD_4
static int disks_registered = 0;
#endif
@@ -615,9 +592,9 @@ static int disks_registered = 0;
* for opens on subdevices (eg. slices, partitions).
*/
static int
-twed_open(dev_t dev, int flags, int fmt, d_thread_t *td)
+twed_open(struct disk *dp)
{
- struct twed_softc *sc = (struct twed_softc *)dev->si_drv1;
+ struct twed_softc *sc = (struct twed_softc *)dp->d_drv1;
debug_called(4);
@@ -628,11 +605,6 @@ twed_open(dev_t dev, int flags, int fmt, d_thread_t *td)
if (sc->twed_controller->twe_state & TWE_STATE_SHUTDOWN)
return(ENXIO);
- sc->twed_disk.d_sectorsize = TWE_BLOCK_SIZE;
- sc->twed_disk.d_mediasize = TWE_BLOCK_SIZE * (off_t)sc->twed_drive->td_size;
- sc->twed_disk.d_fwsectors = sc->twed_drive->td_sectors;
- sc->twed_disk.d_fwheads = sc->twed_drive->td_heads;
-
return (0);
}
@@ -680,7 +652,7 @@ twed_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t l
struct disk *dp;
dp = arg;
- twed_sc = (struct twed_softc *)dp->d_dev->si_drv1;
+ twed_sc = (struct twed_softc *)dp->d_drv1;
twe_sc = (struct twe_softc *)twed_sc->twed_controller;
if (!twed_sc || !twe_sc)
return(ENXIO);
@@ -726,7 +698,6 @@ twed_attach(device_t dev)
{
struct twed_softc *sc;
device_t parent;
- dev_t dsk;
debug_called(4);
@@ -748,16 +719,24 @@ twed_attach(device_t dev)
DEVSTAT_PRIORITY_ARRAY);
/* attach a generic disk device to ourselves */
- dsk = disk_create(device_get_unit(dev), &sc->twed_disk, 0, &twed_cdevsw, &tweddisk_cdevsw);
- dsk->si_drv1 = sc;
- dsk->si_drv2 = &sc->twed_drive->td_unit;
- sc->twed_dev_t = dsk;
+
+ sc->twed_disk.d_open = twed_open;
+ sc->twed_disk.d_strategy = twed_strategy;
+ sc->twed_disk.d_dump = (dumper_t *)twed_dump;
+ sc->twed_disk.d_name = "twed";
+ sc->twed_disk.d_drv1 = sc;
+ sc->twed_disk.d_maxsize = (TWE_MAX_SGL_LENGTH - 1) * PAGE_SIZE;
+ sc->twed_disk.d_sectorsize = TWE_BLOCK_SIZE;
+ sc->twed_disk.d_mediasize = TWE_BLOCK_SIZE * (off_t)sc->twed_drive->td_size;
+ sc->twed_disk.d_fwsectors = sc->twed_drive->td_sectors;
+ sc->twed_disk.d_fwheads = sc->twed_drive->td_heads;
+
+ disk_create(device_get_unit(dev), &sc->twed_disk, 0, NULL, NULL);
#ifdef FREEBSD_4
disks_registered++;
#endif
/* set the maximum I/O size to the theoretical maximum allowed by the S/G list size */
- dsk->si_iosize_max = (TWE_MAX_SGL_LENGTH - 1) * PAGE_SIZE;
return (0);
}
OpenPOWER on IntegriCloud