summaryrefslogtreecommitdiffstats
path: root/sys/dev/pst/pst-raid.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-02-25 08:02:57 +0000
committerphk <phk@FreeBSD.org>2003-02-25 08:02:57 +0000
commit6c8603b2c20f0ddee5add9270b75d4847def8f3d (patch)
tree64264a8748fb2f34c68ea3fbec4ab08c85d4e3ba /sys/dev/pst/pst-raid.c
parent6a119a04ae59d3b4c5e6434f74c94ca18d21173b (diff)
downloadFreeBSD-src-6c8603b2c20f0ddee5add9270b75d4847def8f3d.zip
FreeBSD-src-6c8603b2c20f0ddee5add9270b75d4847def8f3d.tar.gz
NO_GEOM cleanup:
Move to "struct disk *" centric API. Add NULL check to a malloc(9) return value. Ok'ed by: sos
Diffstat (limited to 'sys/dev/pst/pst-raid.c')
-rw-r--r--sys/dev/pst/pst-raid.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/sys/dev/pst/pst-raid.c b/sys/dev/pst/pst-raid.c
index 6847177..1bd7a95 100644
--- a/sys/dev/pst/pst-raid.c
+++ b/sys/dev/pst/pst-raid.c
@@ -52,30 +52,10 @@
#include "dev/pst/pst-iop.h"
-/* device structures */
-static d_strategy_t pststrategy;
-static struct cdevsw pst_cdevsw = {
- /* open */ nullopen,
- /* close */ nullclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ noioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strat */ pststrategy,
- /* name */ "pst",
- /* maj */ 200,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
-};
-static struct cdevsw pstdisk_cdevsw;
-
struct pst_softc {
struct iop_softc *iop;
struct i2o_lct_entry *lct;
struct i2o_bsa_device *info;
- dev_t device;
struct devstat stats;
struct disk disk;
struct bio_queue_head queue;
@@ -91,6 +71,7 @@ struct pst_request {
};
/* prototypes */
+static disk_strategy_t pststrategy;
static int pst_probe(device_t);
static int pst_attach(device_t);
static int pst_shutdown(device_t);
@@ -111,7 +92,11 @@ pst_add_raid(struct iop_softc *sc, struct i2o_lct_entry *lct)
if (!child)
return ENOMEM;
- psc = malloc(sizeof(struct pst_softc), M_PSTRAID, M_NOWAIT | M_ZERO);
+ if (!(psc = malloc(sizeof(struct pst_softc),
+ M_PSTRAID, M_NOWAIT | M_ZERO))) {
+ device_delete_child(sc->dev, child);
+ return ENOMEM;
+ }
psc->iop = sc;
psc->lct = lct;
device_set_softc(child, psc);
@@ -168,9 +153,11 @@ pst_attach(device_t dev)
bioq_init(&psc->queue);
mtx_init(&psc->mtx, "pst lock", MTX_DEF, 0);
- psc->device = disk_create(lun, &psc->disk, 0, &pst_cdevsw, &pstdisk_cdevsw);
- psc->device->si_drv1 = psc;
- psc->device->si_iosize_max = 64 * 1024; /*I2O_SGL_MAX_SEGS * PAGE_SIZE;*/
+ psc->disk.d_name = "pst";
+ psc->disk.d_strategy = pststrategy;
+ psc->disk.d_maxsize = 64 * 1024; /*I2O_SGL_MAX_SEGS * PAGE_SIZE;*/
+ psc->disk.d_drv1 = psc;
+ disk_create(lun, &psc->disk, 0, NULL, NULL);
psc->disk.d_sectorsize = psc->info->block_size;
psc->disk.d_mediasize = psc->info->capacity;
@@ -217,7 +204,7 @@ pst_shutdown(device_t dev)
static void
pststrategy(struct bio *bp)
{
- struct pst_softc *psc = bp->bio_dev->si_drv1;
+ struct pst_softc *psc = bp->bio_disk->d_drv1;
mtx_lock(&psc->mtx);
bioqdisksort(&psc->queue, bp);
OpenPOWER on IntegriCloud