Complete device_t/softc split for the ld(4) attachments. This should

prevent crashes while attaching a drive.

Patch supplied by Juan RP in PR kern/39468.
This commit is contained in:
tron 2008-09-09 12:45:39 +00:00
parent 5f566e7cf3
commit 362b2f2b14
12 changed files with 210 additions and 227 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_ataraid.c,v 1.28 2008/08/24 09:19:03 hannken Exp $ */
/* $NetBSD: ld_ataraid.c,v 1.29 2008/09/09 12:45:39 tron Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.28 2008/08/24 09:19:03 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.29 2008/09/09 12:45:39 tron Exp $");
#include "rnd.h"
@ -130,6 +130,8 @@ ld_ataraid_attach(device_t parent, device_t self, void *aux)
char unklev[32];
u_int i;
ld->sc_dv = self;
if (ld_ataraid_initialized == 0) {
ld_ataraid_initialized = 1;
pool_init(&ld_ataraid_cbufpl, sizeof(struct cbuf), 0,
@ -180,7 +182,7 @@ ld_ataraid_attach(device_t parent, device_t self, void *aux)
ata_raid_type_name(aai->aai_type), level);
if (ld->sc_start == NULL) {
aprint_error_dev(&ld->sc_dv, "unsupported array type\n");
aprint_error_dev(ld->sc_dv, "unsupported array type\n");
return;
}
@ -472,7 +474,7 @@ ld_ataraid_iodone_raid0(struct buf *vbp)
adi->adi_status &= ~ADI_S_ONLINE;
printf("%s: error %d on component %d (%s)\n",
device_xname(&sc->sc_ld.sc_dv), bp->b_error, cbp->cb_comp,
device_xname(sc->sc_ld.sc_dv), bp->b_error, cbp->cb_comp,
device_xname(adi->adi_dev));
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_iop.c,v 1.31 2008/09/08 23:36:54 gmcgarry Exp $ */
/* $NetBSD: ld_iop.c,v 1.32 2008/09/09 12:45:39 tron Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_iop.c,v 1.31 2008/09/08 23:36:54 gmcgarry Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_iop.c,v 1.32 2008/09/09 12:45:39 tron Exp $");
#include "rnd.h"
@ -74,18 +74,18 @@ struct ld_iop_softc {
int sc_flags;
};
static void ld_iop_adjqparam(struct device *, int);
static void ld_iop_attach(struct device *, struct device *, void *);
static int ld_iop_detach(struct device *, int);
static void ld_iop_adjqparam(device_t, int);
static void ld_iop_attach(device_t, device_t, void *);
static int ld_iop_detach(device_t, int);
static int ld_iop_dump(struct ld_softc *, void *, int, int);
static int ld_iop_flush(struct ld_softc *, int);
static void ld_iop_intr(struct device *, struct iop_msg *, void *);
static void ld_iop_intr_event(struct device *, struct iop_msg *, void *);
static int ld_iop_match(struct device *, struct cfdata *, void *);
static void ld_iop_intr(device_t, struct iop_msg *, void *);
static void ld_iop_intr_event(device_t, struct iop_msg *, void *);
static int ld_iop_match(device_t, cfdata_t, void *);
static int ld_iop_start(struct ld_softc *, struct buf *);
static void ld_iop_unconfig(struct ld_iop_softc *, int);
CFATTACH_DECL(ld_iop, sizeof(struct ld_iop_softc),
CFATTACH_DECL_NEW(ld_iop, sizeof(struct ld_iop_softc),
ld_iop_match, ld_iop_attach, ld_iop_detach, NULL);
static const char * const ld_iop_errors[] = {
@ -107,8 +107,7 @@ static const char * const ld_iop_errors[] = {
};
static int
ld_iop_match(struct device *parent, struct cfdata *match,
void *aux)
ld_iop_match(device_t parent, cfdata_t match, void *aux)
{
struct iop_attach_args *ia;
@ -118,12 +117,12 @@ ld_iop_match(struct device *parent, struct cfdata *match,
}
static void
ld_iop_attach(struct device *parent, struct device *self, void *aux)
ld_iop_attach(device_t parent, device_t self, void *aux)
{
struct iop_attach_args *ia;
struct ld_softc *ld;
struct ld_iop_softc *sc;
struct iop_softc *iop;
struct iop_attach_args *ia = aux;
struct ld_iop_softc *sc = device_private(self);
struct iop_softc *iop = device_private(parent);
struct ld_softc *ld = &sc->sc_ld;
int rv, evreg, enable;
const char *typestr, *fixedstr;
u_int cachesz;
@ -137,10 +136,7 @@ ld_iop_attach(struct device *parent, struct device *self, void *aux)
} p;
} __packed param;
sc = device_private(self);
ld = &sc->sc_ld;
iop = device_private(parent);
ia = (struct iop_attach_args *)aux;
ld->sc_dv = self;
evreg = 0;
/* Register us as an initiator. */
@ -287,7 +283,7 @@ ld_iop_unconfig(struct ld_iop_softc *sc, int evreg)
{
struct iop_softc *iop;
iop = (struct iop_softc *)device_parent(&sc->sc_ld.sc_dv);
iop = device_private(device_parent(sc->sc_ld.sc_dv));
if ((sc->sc_flags & LD_IOP_CLAIMED) != 0)
iop_util_claim(iop, &sc->sc_ii, 1,
@ -318,7 +314,7 @@ ld_iop_unconfig(struct ld_iop_softc *sc, int evreg)
}
static int
ld_iop_detach(struct device *self, int flags)
ld_iop_detach(device_t self, int flags)
{
struct ld_iop_softc *sc;
struct iop_softc *iop;
@ -359,7 +355,7 @@ ld_iop_start(struct ld_softc *ld, struct buf *bp)
u_int32_t mb[IOP_MAX_MSG_SIZE / sizeof(u_int32_t)];
sc = (struct ld_iop_softc *)ld;
iop = (struct iop_softc *)device_parent(&ld->sc_dv);
iop = device_private(device_parent(ld->sc_dv));
im = iop_msg_alloc(iop, 0);
im->im_dvcontext = bp;
@ -419,7 +415,7 @@ ld_iop_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt)
u_int32_t mb[IOP_MAX_MSG_SIZE / sizeof(u_int32_t)];
sc = (struct ld_iop_softc *)ld;
iop = (struct iop_softc *)device_parent(&ld->sc_dv);
iop = device_private(device_parent(ld->sc_dv));
bcount = blkcnt * ld->sc_secsize;
ba = (u_int64_t)blkno * ld->sc_secsize;
im = iop_msg_alloc(iop, IM_POLL);
@ -455,7 +451,7 @@ ld_iop_flush(struct ld_softc *ld, int flags)
int rv;
sc = (struct ld_iop_softc *)ld;
iop = (struct iop_softc *)device_parent(&ld->sc_dv);
iop = device_private(device_parent(ld->sc_dv));
im = iop_msg_alloc(iop, IM_WAIT);
mf.msgflags = I2O_MSGFLAGS(i2o_rbs_cache_flush);
@ -471,7 +467,7 @@ ld_iop_flush(struct ld_softc *ld, int flags)
}
void
ld_iop_intr(struct device *dv, struct iop_msg *im, void *reply)
ld_iop_intr(device_t dv, struct iop_msg *im, void *reply)
{
struct i2o_rbs_reply *rb;
struct buf *bp;
@ -483,7 +479,7 @@ ld_iop_intr(struct device *dv, struct iop_msg *im, void *reply)
rb = reply;
bp = im->im_dvcontext;
sc = (struct ld_iop_softc *)dv;
iop = (struct iop_softc *)device_parent(dv);
iop = device_private(device_parent(dv));
err = ((rb->msgflags & I2O_MSGFLAGS_FAIL) != 0);
@ -509,7 +505,7 @@ ld_iop_intr(struct device *dv, struct iop_msg *im, void *reply)
}
static void
ld_iop_intr_event(struct device *dv, struct iop_msg *im, void *reply)
ld_iop_intr_event(device_t dv, struct iop_msg *im, void *reply)
{
struct i2o_util_event_register_reply *rb;
struct ld_iop_softc *sc;
@ -537,17 +533,18 @@ ld_iop_intr_event(struct device *dv, struct iop_msg *im, void *reply)
}
static void
ld_iop_adjqparam(struct device *dv, int mpi)
ld_iop_adjqparam(device_t dv, int mpi)
{
struct iop_softc *iop;
struct ld_iop_softc *sc = device_private(dv);
struct iop_softc *iop = device_private(device_parent(dv));
struct ld_softc *ld = &sc->sc_ld;
/*
* AMI controllers seem to loose the plot if you hand off lots of
* queued commands.
*/
iop = (struct iop_softc *)device_parent(dv);
if (le16toh(I2O_ORG_AMI) == iop->sc_status.orgid && mpi > 64)
mpi = 64;
ldadjqparam((struct ld_softc *)dv, mpi);
ldadjqparam(ld, mpi);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_aac.c,v 1.20 2008/04/30 14:07:13 ad Exp $ */
/* $NetBSD: ld_aac.c,v 1.21 2008/09/09 12:45:39 tron Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_aac.c,v 1.20 2008/04/30 14:07:13 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_aac.c,v 1.21 2008/09/09 12:45:39 tron Exp $");
#include "rnd.h"
@ -61,46 +61,42 @@ struct ld_aac_softc {
int sc_hwunit;
};
static void ld_aac_attach(struct device *, struct device *, void *);
static void ld_aac_attach(device_t, device_t, void *);
static void ld_aac_intr(struct aac_ccb *);
static int ld_aac_dobio(struct ld_aac_softc *, void *, int, int, int,
struct buf *);
static int ld_aac_dump(struct ld_softc *, void *, int, int);
static int ld_aac_match(struct device *, struct cfdata *, void *);
static int ld_aac_match(device_t, cfdata_t, void *);
static int ld_aac_start(struct ld_softc *, struct buf *);
CFATTACH_DECL(ld_aac, sizeof(struct ld_aac_softc),
CFATTACH_DECL_NEW(ld_aac, sizeof(struct ld_aac_softc),
ld_aac_match, ld_aac_attach, NULL, NULL);
static int
ld_aac_match(struct device *parent, struct cfdata *match,
void *aux)
ld_aac_match(device_t parent, cfdata_t match, void *aux)
{
return (1);
}
static void
ld_aac_attach(struct device *parent, struct device *self, void *aux)
ld_aac_attach(device_t parent, device_t self, void *aux)
{
struct aac_attach_args *aaca;
struct aac_drive *hdr;
struct ld_aac_softc *sc;
struct ld_softc *ld;
struct aac_softc *aac;
struct aac_attach_args *aaca = aux;
struct ld_aac_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
struct aac_softc *aac = device_private(parent);
struct aac_drive *hdr = &aac->sc_hdr[aaca->aaca_unit];
aaca = aux;
aac = (struct aac_softc *)parent;
sc = (struct ld_aac_softc *)self;
ld = &sc->sc_ld;
hdr = &aac->sc_hdr[aaca->aaca_unit];
ld->sc_dv = self;
sc->sc_hwunit = aaca->aaca_unit;
ld->sc_flags = LDF_ENABLED;
ld->sc_maxxfer = AAC_MAX_XFER(aac);
ld->sc_secperunit = hdr->hd_size;
ld->sc_secsize = AAC_SECTOR_SIZE;
ld->sc_maxqueuecnt = (aac->sc_max_fibs - AAC_NCCBS_RESERVE) / aac->sc_nunits;
ld->sc_maxqueuecnt =
(aac->sc_max_fibs - AAC_NCCBS_RESERVE) / aac->sc_nunits;
ld->sc_start = ld_aac_start;
ld->sc_dump = ld_aac_dump;
@ -123,7 +119,7 @@ ld_aac_dobio(struct ld_aac_softc *sc, void *data, int datasize, int blkno,
u_int16_t size;
int s, rv, i;
aac = (struct aac_softc *)device_parent(&sc->sc_ld.sc_dv);
aac = device_private(device_parent(sc->sc_ld.sc_dv));
/*
* Allocate a command control block and map the data transfer.
@ -271,7 +267,8 @@ ld_aac_dobio(struct ld_aac_softc *sc, void *data, int datasize, int blkno,
}
if (status != ST_OK) {
aprint_error_dev(&sc->sc_ld.sc_dv, "I/O error: %s\n",
aprint_error_dev(sc->sc_ld.sc_dv,
"I/O error: %s\n",
aac_describe_code(aac_command_status_table,
status));
rv = EIO;
@ -308,7 +305,7 @@ ld_aac_intr(struct aac_ccb *ac)
bp = ac->ac_context;
sc = (struct ld_aac_softc *)ac->ac_device;
aac = (struct aac_softc *)device_parent(&sc->sc_ld.sc_dv);
aac = device_private(device_parent(sc->sc_ld.sc_dv));
if ((bp->b_flags & B_READ) != 0) {
brr = (struct aac_blockread_response *)&ac->ac_fib->data[0];
@ -325,7 +322,7 @@ ld_aac_intr(struct aac_ccb *ac)
bp->b_error = EIO;
bp->b_resid = bp->b_bcount;
aprint_error_dev(&sc->sc_ld.sc_dv, "I/O error: %s\n",
aprint_error_dev(sc->sc_ld.sc_dv, "I/O error: %s\n",
aac_describe_code(aac_command_status_table, status));
} else
bp->b_resid = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_cac.c,v 1.21 2008/04/28 20:23:50 martin Exp $ */
/* $NetBSD: ld_cac.c,v 1.22 2008/09/09 12:45:39 tron Exp $ */
/*-
* Copyright (c) 2000, 2006 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_cac.c,v 1.21 2008/04/28 20:23:50 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_cac.c,v 1.22 2008/09/09 12:45:39 tron Exp $");
#include "rnd.h"
@ -66,40 +66,36 @@ struct ld_cac_softc {
struct timeval sc_serrtm;
};
void ld_cac_attach(struct device *, struct device *, void *);
void ld_cac_done(struct device *, void *, int);
void ld_cac_attach(device_t, device_t, void *);
void ld_cac_done(device_t, void *, int);
int ld_cac_dump(struct ld_softc *, void *, int, int);
int ld_cac_match(struct device *, struct cfdata *, void *);
int ld_cac_match(device_t, cfdata_t, void *);
int ld_cac_start(struct ld_softc *, struct buf *);
static const struct timeval ld_cac_serrintvl = { 60, 0 };
CFATTACH_DECL(ld_cac, sizeof(struct ld_cac_softc),
CFATTACH_DECL_NEW(ld_cac, sizeof(struct ld_cac_softc),
ld_cac_match, ld_cac_attach, NULL, NULL);
int
ld_cac_match(struct device *parent, struct cfdata *match,
void *aux)
ld_cac_match(device_t parent, cfdata_t match, void *aux)
{
return (1);
}
void
ld_cac_attach(struct device *parent, struct device *self, void *aux)
ld_cac_attach(device_t parent, device_t self, void *aux)
{
struct cac_drive_info dinfo;
struct cac_attach_args *caca;
struct ld_softc *ld;
struct ld_cac_softc *sc;
struct cac_softc *cac;
struct ld_cac_softc *sc = device_private(self);
struct cac_softc *cac = device_private(parent);
struct ld_softc *ld = &sc->sc_ld;
const char *type;
sc = (struct ld_cac_softc *)self;
ld = &sc->sc_ld;
caca = (struct cac_attach_args *)aux;
sc->sc_hwunit = caca->caca_unit;
cac = (struct cac_softc *)parent;
caca = aux;
ld->sc_dv = self;
sc->sc_mutex = &cac->sc_mutex;
if (cac_cmd(cac, CAC_CMD_GET_LOG_DRV_INFO, &dinfo, sizeof(dinfo),
@ -150,11 +146,11 @@ ld_cac_start(struct ld_softc *ld, struct buf *bp)
struct cac_context cc;
sc = (struct ld_cac_softc *)ld;
cac = (struct cac_softc *)device_parent(&ld->sc_dv);
cac = device_private(device_parent(ld->sc_dv));
cc.cc_handler = ld_cac_done;
cc.cc_context = bp;
cc.cc_dv = &ld->sc_dv;
cc.cc_dv = ld->sc_dv;
if ((bp->b_flags & B_READ) == 0) {
cmd = CAC_CMD_WRITE;
@ -175,7 +171,7 @@ ld_cac_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt)
sc = (struct ld_cac_softc *)ld;
return (cac_cmd((struct cac_softc *)device_parent(&ld->sc_dv),
return (cac_cmd(device_private(device_parent(ld->sc_dv)),
CAC_CMD_WRITE_MEDIA, data, blkcnt * ld->sc_secsize,
sc->sc_hwunit, blkno, CAC_CCB_DATA_OUT, NULL));
}
@ -207,7 +203,8 @@ ld_cac_done(struct device *dv, void *context, int error)
sc->sc_serrcnt++;
if (ratecheck(&sc->sc_serrtm, &ld_cac_serrintvl)) {
sc->sc_serrcnt = 0;
aprint_error_dev(dv, "%d soft errors; array may be degraded\n",
aprint_error_dev(dv,
"%d soft errors; array may be degraded\n",
sc->sc_serrcnt);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_icp.c,v 1.21 2008/08/11 06:43:38 simonb Exp $ */
/* $NetBSD: ld_icp.c,v 1.22 2008/09/09 12:45:39 tron Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_icp.c,v 1.21 2008/08/11 06:43:38 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_icp.c,v 1.22 2008/09/09 12:45:39 tron Exp $");
#include "rnd.h"
@ -65,19 +65,19 @@ struct ld_icp_softc {
int sc_hwunit;
};
void ld_icp_attach(struct device *, struct device *, void *);
int ld_icp_detach(struct device *, int);
void ld_icp_attach(device_t, device_t, void *);
int ld_icp_detach(device_t, int);
int ld_icp_dobio(struct ld_icp_softc *, void *, int, int, int,
struct buf *);
int ld_icp_dump(struct ld_softc *, void *, int, int);
int ld_icp_flush(struct ld_softc *, int);
void ld_icp_intr(struct icp_ccb *);
int ld_icp_match(struct device *, struct cfdata *, void *);
int ld_icp_match(device_t, cfdata_t, void *);
int ld_icp_start(struct ld_softc *, struct buf *);
void ld_icp_adjqparam(struct device *, int);
void ld_icp_adjqparam(device_t, int);
CFATTACH_DECL(ld_icp, sizeof(struct ld_icp_softc),
CFATTACH_DECL_NEW(ld_icp, sizeof(struct ld_icp_softc),
ld_icp_match, ld_icp_attach, ld_icp_detach, NULL);
static const struct icp_servicecb ld_icp_servicecb = {
@ -85,8 +85,7 @@ static const struct icp_servicecb ld_icp_servicecb = {
};
int
ld_icp_match(struct device *parent, struct cfdata *match,
void *aux)
ld_icp_match(device_t parent, cfdata_t match, void *aux)
{
struct icp_attach_args *icpa;
@ -96,22 +95,18 @@ ld_icp_match(struct device *parent, struct cfdata *match,
}
void
ld_icp_attach(struct device *parent, struct device *self, void *aux)
ld_icp_attach(device_t parent, device_t self, void *aux)
{
struct icp_attach_args *icpa;
struct ld_icp_softc *sc;
struct ld_softc *ld;
struct icp_softc *icp;
struct icp_cachedrv *cd;
struct icp_attach_args *icpa = aux;
struct ld_icp_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
struct icp_softc *icp = device_private(parent);
struct icp_cachedrv *cd = &icp->icp_cdr[icpa->icpa_unit];
struct icp_cdevinfo *cdi;
const char *str;
int t;
sc = (struct ld_icp_softc *)self;
ld = &sc->sc_ld;
icp = (struct icp_softc *)parent;
icpa = aux;
cd = &icp->icp_cdr[icpa->icpa_unit];
ld->sc_dv = self;
icp_register_servicecb(icp, icpa->icpa_unit, &ld_icp_servicecb);
@ -174,7 +169,7 @@ ld_icp_attach(struct device *parent, struct device *self, void *aux)
}
int
ld_icp_detach(struct device *dv, int flags)
ld_icp_detach(device_t dv, int flags)
{
int rv;
@ -194,7 +189,7 @@ ld_icp_dobio(struct ld_icp_softc *sc, void *data, int datasize, int blkno,
struct icp_softc *icp;
int s, rv;
icp = (struct icp_softc *)device_parent(&sc->sc_ld.sc_dv);
icp = device_private(device_parent(sc->sc_ld.sc_dv));
/*
* Allocate a command control block.
@ -241,7 +236,7 @@ ld_icp_dobio(struct ld_icp_softc *sc, void *data, int datasize, int blkno,
} else {
ic->ic_intr = ld_icp_intr;
ic->ic_context = bp;
ic->ic_dv = &sc->sc_ld.sc_dv;
ic->ic_dv = sc->sc_ld.sc_dv;
icp_ccb_enqueue(icp, ic);
}
@ -274,7 +269,7 @@ ld_icp_flush(struct ld_softc *ld, int flags)
int rv;
sc = (struct ld_icp_softc *)ld;
icp = (struct icp_softc *)device_parent(&ld->sc_dv);
icp = device_private(device_parent(ld->sc_dv));
ic = icp_ccb_alloc_wait(icp);
ic->ic_cmd.cmd_opcode = htole16(ICP_FLUSH);
@ -304,7 +299,7 @@ ld_icp_intr(struct icp_ccb *ic)
bp = ic->ic_context;
sc = (struct ld_icp_softc *)ic->ic_dv;
icp = (struct icp_softc *)device_parent(&sc->sc_ld.sc_dv);
icp = device_private(device_parent(sc->sc_ld.sc_dv));
if (ic->ic_status != ICP_S_OK) {
aprint_error_dev(ic->ic_dv, "request failed; status=0x%04x\n",
@ -332,7 +327,7 @@ ld_icp_intr(struct icp_ccb *ic)
}
void
ld_icp_adjqparam(struct device *dv, int openings)
ld_icp_adjqparam(device_t dv, int openings)
{
ldadjqparam((struct ld_softc *) dv, openings);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_mlx.c,v 1.17 2008/04/28 20:23:50 martin Exp $ */
/* $NetBSD: ld_mlx.c,v 1.18 2008/09/09 12:45:40 tron Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_mlx.c,v 1.17 2008/04/28 20:23:50 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_mlx.c,v 1.18 2008/09/09 12:45:40 tron Exp $");
#include "rnd.h"
@ -65,41 +65,36 @@ struct ld_mlx_softc {
int sc_hwunit;
};
static void ld_mlx_attach(struct device *, struct device *, void *);
static int ld_mlx_detach(struct device *, int);
static void ld_mlx_attach(device_t, device_t, void *);
static int ld_mlx_detach(device_t, int);
static int ld_mlx_dobio(struct ld_mlx_softc *, void *, int, int, int,
struct buf *);
static int ld_mlx_dump(struct ld_softc *, void *, int, int);
static void ld_mlx_handler(struct mlx_ccb *);
static int ld_mlx_match(struct device *, struct cfdata *, void *);
static int ld_mlx_match(device_t, cfdata_t, void *);
static int ld_mlx_start(struct ld_softc *, struct buf *);
CFATTACH_DECL(ld_mlx, sizeof(struct ld_mlx_softc),
CFATTACH_DECL_NEW(ld_mlx, sizeof(struct ld_mlx_softc),
ld_mlx_match, ld_mlx_attach, ld_mlx_detach, NULL);
static int
ld_mlx_match(struct device *parent, struct cfdata *match,
void *aux)
ld_mlx_match(device_t parent, cfdata_t match, void *aux)
{
return (1);
}
static void
ld_mlx_attach(struct device *parent, struct device *self, void *aux)
ld_mlx_attach(device_t parent, device_t self, void *aux)
{
struct mlx_attach_args *mlxa;
struct ld_mlx_softc *sc;
struct ld_softc *ld;
struct mlx_softc *mlx;
struct mlx_sysdrive *ms;
struct mlx_attach_args *mlxa = aux;
struct ld_mlx_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
struct mlx_softc *mlx = device_private(parent);
struct mlx_sysdrive *ms = &mlx->mlx_sysdrive[mlxa->mlxa_unit];
const char *statestr;
sc = (struct ld_mlx_softc *)self;
ld = &sc->sc_ld;
mlx = (struct mlx_softc *)parent;
mlxa = aux;
ms = &mlx->mlx_sysdrive[mlxa->mlxa_unit];
ld->sc_dv = self;
sc->sc_hwunit = mlxa->mlxa_unit;
ld->sc_maxxfer = MLX_MAX_XFER;
@ -141,14 +136,17 @@ ld_mlx_attach(struct device *parent, struct device *self, void *aux)
}
static int
ld_mlx_detach(struct device *dv, int flags)
ld_mlx_detach(device_t dv, int flags)
{
struct ld_mlx_softc *sc = device_private(dv);
struct ld_softc *ld = &sc->sc_ld;
struct mlx_softc *mlx = device_private(device_parent(dv));
int rv;
if ((rv = ldbegindetach((struct ld_softc *)dv, flags)) != 0)
if ((rv = ldbegindetach(ld, flags)) != 0)
return (rv);
ldenddetach((struct ld_softc *)dv);
mlx_flush((struct mlx_softc *)device_parent(dv), 1);
ldenddetach(ld);
mlx_flush(mlx, 1);
return (0);
}
@ -162,7 +160,7 @@ ld_mlx_dobio(struct ld_mlx_softc *sc, void *data, int datasize, int blkno,
int s, rv;
bus_addr_t sgphys;
mlx = (struct mlx_softc *)device_parent(&sc->sc_ld.sc_dv);
mlx = device_private(device_parent(sc->sc_ld.sc_dv));
if ((rv = mlx_ccb_alloc(mlx, &mc, bp == NULL)) != 0)
return (rv);
@ -200,7 +198,7 @@ ld_mlx_dobio(struct ld_mlx_softc *sc, void *data, int datasize, int blkno,
} else {
mc->mc_mx.mx_handler = ld_mlx_handler;
mc->mc_mx.mx_context = bp;
mc->mc_mx.mx_dv = &sc->sc_ld.sc_dv;
mc->mc_mx.mx_dv = sc->sc_ld.sc_dv;
mlx_ccb_enqueue(mlx, mc);
rv = 0;
}
@ -227,7 +225,7 @@ ld_mlx_handler(struct mlx_ccb *mc)
mx = &mc->mc_mx;
bp = mx->mx_context;
sc = (struct ld_mlx_softc *)mx->mx_dv;
mlx = (struct mlx_softc *)device_parent(&sc->sc_ld.sc_dv);
mlx = device_private(device_parent(sc->sc_ld.sc_dv));
if (mc->mc_status != MLX_STATUS_OK) {
bp->b_error = EIO;
@ -235,10 +233,10 @@ ld_mlx_handler(struct mlx_ccb *mc)
if (mc->mc_status == MLX_STATUS_RDWROFFLINE)
printf("%s: drive offline\n",
device_xname(&sc->sc_ld.sc_dv));
device_xname(sc->sc_ld.sc_dv));
else
printf("%s: I/O error - %s\n",
device_xname(&sc->sc_ld.sc_dv),
device_xname(sc->sc_ld.sc_dv),
mlx_ccb_diagnose(mc));
} else
bp->b_resid = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mlx.c,v 1.56 2008/06/08 12:43:51 tsutsui Exp $ */
/* $NetBSD: mlx.c,v 1.57 2008/09/09 12:45:40 tron Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.56 2008/06/08 12:43:51 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.57 2008/09/09 12:45:40 tron Exp $");
#include "ld.h"
@ -669,7 +669,7 @@ mlx_adjqparam(struct mlx_softc *mlx, int mpu, int slop)
for (i = 0; i < ld_cd.cd_ndevs; i++) {
if ((ld = device_lookup_private(&ld_cd, i)) == NULL)
continue;
if (device_parent(&ld->sc_dv) != &mlx->mlx_dv)
if (device_parent(ld->sc_dv) != &mlx->mlx_dv)
continue;
ldadjqparam(ld, mpu + (slop-- > 0));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld.c,v 1.62 2008/08/11 06:43:37 simonb Exp $ */
/* $NetBSD: ld.c,v 1.63 2008/09/09 12:45:39 tron Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.62 2008/08/11 06:43:37 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.63 2008/09/09 12:45:39 tron Exp $");
#include "rnd.h"
@ -102,12 +102,12 @@ ldattach(struct ld_softc *sc)
mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_VM);
if ((sc->sc_flags & LDF_ENABLED) == 0) {
aprint_normal_dev(&sc->sc_dv, "disabled\n");
aprint_normal_dev(sc->sc_dv, "disabled\n");
return;
}
/* Initialise and attach the disk structure. */
disk_init(&sc->sc_dk, device_xname(&sc->sc_dv), &lddkdriver);
disk_init(&sc->sc_dk, device_xname(sc->sc_dv), &lddkdriver);
disk_attach(&sc->sc_dk);
if (sc->sc_maxxfer > MAXPHYS)
@ -139,7 +139,8 @@ ldattach(struct ld_softc *sc)
format_bytes(tbuf, sizeof(tbuf), sc->sc_secperunit *
sc->sc_secsize);
aprint_normal_dev(&sc->sc_dv, "%s, %d cyl, %d head, %d sec, %d bytes/sect x %"PRIu64" sectors\n",
aprint_normal_dev(sc->sc_dv, "%s, %d cyl, %d head, %d sec, "
"%d bytes/sect x %"PRIu64" sectors\n",
tbuf, sc->sc_ncylinders, sc->sc_nheads,
sc->sc_nsectors, sc->sc_secsize, sc->sc_secperunit);
@ -147,19 +148,19 @@ ldattach(struct ld_softc *sc)
#if NRND > 0
/* Attach the device into the rnd source list. */
rnd_attach_source(&sc->sc_rnd_source, device_xname(&sc->sc_dv),
rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dv),
RND_TYPE_DISK, 0);
#endif
/* Register with PMF */
if (!pmf_device_register1(&sc->sc_dv, NULL, NULL, ld_shutdown))
aprint_error_dev(&sc->sc_dv,
if (!pmf_device_register1(sc->sc_dv, NULL, NULL, ld_shutdown))
aprint_error_dev(sc->sc_dv,
"couldn't establish power handler\n");
bufq_alloc(&sc->sc_bufq, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK);
/* Discover wedges on this disk. */
config_interrupts(&sc->sc_dv, ld_config_interrupts);
config_interrupts(sc->sc_dv, ld_config_interrupts);
}
int
@ -210,7 +211,7 @@ ldenddetach(struct ld_softc *sc)
/* Wait for commands queued with the hardware to complete. */
if (sc->sc_queuecnt != 0)
if (tsleep(&sc->sc_queuecnt, PRIBIO, "lddtch", 30 * hz))
printf("%s: not drained\n", device_xname(&sc->sc_dv));
printf("%s: not drained\n", device_xname(sc->sc_dv));
/* Locate the major numbers. */
bmaj = bdevsw_lookup_major(&ld_bdevsw);
@ -225,7 +226,7 @@ ldenddetach(struct ld_softc *sc)
/* Nuke the vnodes for any open instances. */
for (i = 0; i < MAXPARTITIONS; i++) {
mn = DISKMINOR(device_unit(&sc->sc_dv), i);
mn = DISKMINOR(device_unit(sc->sc_dv), i);
vdevgone(bmaj, mn, mn, VBLK);
vdevgone(cmaj, mn, mn, VCHR);
}
@ -243,7 +244,7 @@ ldenddetach(struct ld_softc *sc)
#endif
/* Deregister with PMF */
pmf_device_deregister(&sc->sc_dv);
pmf_device_deregister(sc->sc_dv);
/*
* XXX We can't really flush the cache here, beceause the
@ -346,7 +347,7 @@ ldclose(dev_t dev, int flags, int fmt, struct lwp *l)
if (sc->sc_dk.dk_openmask == 0) {
if (sc->sc_flush != NULL && (*sc->sc_flush)(sc, 0) != 0)
aprint_error_dev(&sc->sc_dv, "unable to flush cache\n");
aprint_error_dev(sc->sc_dv, "unable to flush cache\n");
if ((sc->sc_flags & LDF_KLABEL) == 0)
sc->sc_flags &= ~LDF_VLABEL;
}
@ -500,7 +501,7 @@ ldioctl(dev_t dev, u_long cmd, void *addr, int32_t flag, struct lwp *l)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(&sc->sc_dv),
strlcpy(dkw->dkw_parent, device_xname(sc->sc_dv),
sizeof(dkw->dkw_parent));
return (dkwedge_add(dkw));
}
@ -513,7 +514,7 @@ ldioctl(dev_t dev, u_long cmd, void *addr, int32_t flag, struct lwp *l)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(&sc->sc_dv),
strlcpy(dkw->dkw_parent, device_xname(sc->sc_dv),
sizeof(dkw->dkw_parent));
return (dkwedge_del(dkw));
}
@ -755,10 +756,10 @@ ldgetdisklabel(struct ld_softc *sc)
ldgetdefaultlabel(sc, sc->sc_dk.dk_label);
/* Call the generic disklabel extraction routine. */
errstring = readdisklabel(MAKEDISKDEV(0, device_unit(&sc->sc_dv),
errstring = readdisklabel(MAKEDISKDEV(0, device_unit(sc->sc_dv),
RAW_PART), ldstrategy, sc->sc_dk.dk_label, sc->sc_dk.dk_cpulabel);
if (errstring != NULL)
printf("%s: %s\n", device_xname(&sc->sc_dv), errstring);
printf("%s: %s\n", device_xname(sc->sc_dv), errstring);
/* In-core label now valid. */
sc->sc_flags |= LDF_VLABEL;
@ -899,7 +900,7 @@ ld_set_properties(struct ld_softc *ld)
prop_dictionary_set(disk_info, "geometry", geom);
prop_object_release(geom);
prop_dictionary_set(device_properties(&ld->sc_dv),
prop_dictionary_set(device_properties(ld->sc_dv),
"disk-info", disk_info);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldvar.h,v 1.14 2008/08/11 06:43:37 simonb Exp $ */
/* $NetBSD: ldvar.h,v 1.15 2008/09/09 12:45:39 tron Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
#include <sys/mutex.h>
struct ld_softc {
struct device sc_dv;
struct device *sc_dv;
struct disk sc_dk;
struct bufq_state *sc_bufq;
kmutex_t sc_mutex;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_amr.c,v 1.16 2008/04/28 20:23:55 martin Exp $ */
/* $NetBSD: ld_amr.c,v 1.17 2008/09/09 12:45:40 tron Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_amr.c,v 1.16 2008/04/28 20:23:55 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_amr.c,v 1.17 2008/09/09 12:45:40 tron Exp $");
#include "rnd.h"
@ -74,27 +74,23 @@ static void ld_amr_handler(struct amr_ccb *);
static int ld_amr_start(struct ld_softc *, struct buf *);
static int
ld_amr_match(struct device *parent, struct cfdata *match,
void *aux)
ld_amr_match(device_t parent, cfdata_t match, void *aux)
{
return (1);
}
static void
ld_amr_attach(struct device *parent, struct device *self, void *aux)
ld_amr_attach(device_t parent, device_t self, void *aux)
{
struct amr_attach_args *amra;
struct ld_amr_softc *sc;
struct ld_softc *ld;
struct amr_softc *amr;
struct amr_attach_args *amra = aux;
struct ld_amr_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
struct amr_softc *amr = device_private(parent);
const char *statestr;
int happy;
sc = (struct ld_amr_softc *)self;
ld = &sc->sc_ld;
amr = (struct amr_softc *)parent;
amra = aux;
ld->sc_dv = self;
sc->sc_hwunit = amra->amra_unit;
ld->sc_maxxfer = amr_max_xfer;
@ -122,7 +118,7 @@ ld_amr_attach(struct device *parent, struct device *self, void *aux)
ldattach(ld);
}
CFATTACH_DECL(ld_amr, sizeof(struct ld_amr_softc),
CFATTACH_DECL_NEW(ld_amr, sizeof(struct ld_amr_softc),
ld_amr_match, ld_amr_attach, NULL, NULL);
static int
@ -134,7 +130,7 @@ ld_amr_dobio(struct ld_amr_softc *sc, void *data, int datasize,
struct amr_mailbox_cmd *mb;
int s, rv;
amr = (struct amr_softc *)device_parent(&sc->sc_ld.sc_dv);
amr = device_private(device_parent(sc->sc_ld.sc_dv));
if ((rv = amr_ccb_alloc(amr, &ac)) != 0)
return (rv);
@ -190,10 +186,10 @@ ld_amr_handler(struct amr_ccb *ac)
bp = ac->ac_context;
sc = (struct ld_amr_softc *)ac->ac_dv;
amr = (struct amr_softc *)device_parent(&sc->sc_ld.sc_dv);
amr = device_private(device_parent(sc->sc_ld.sc_dv));
if (ac->ac_status != AMR_STATUS_SUCCESS) {
printf("%s: cmd status 0x%02x\n", device_xname(&sc->sc_ld.sc_dv),
printf("%s: cmd status 0x%02x\n", device_xname(sc->sc_ld.sc_dv),
ac->ac_status);
bp->b_error = EIO;

View File

@ -1,5 +1,5 @@
/* $wasabi: ld_twa.c,v 1.9 2006/02/14 18:44:37 jordanr Exp $ */
/* $NetBSD: ld_twa.c,v 1.12 2008/08/11 06:43:38 simonb Exp $ */
/* $NetBSD: ld_twa.c,v 1.13 2008/09/09 12:45:40 tron Exp $ */
/*-
* Copyright (c) 2000, 2001, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_twa.c,v 1.12 2008/08/11 06:43:38 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_twa.c,v 1.13 2008/09/09 12:45:40 tron Exp $");
#include "rnd.h"
@ -76,22 +76,22 @@ struct ld_twa_softc {
int sc_hwunit;
};
static void ld_twa_attach(struct device *, struct device *, void *);
static int ld_twa_detach(struct device *, int);
static void ld_twa_attach(device_t, device_t, void *);
static int ld_twa_detach(device_t, int);
static int ld_twa_dobio(struct ld_twa_softc *, void *, size_t, daddr_t,
struct buf *);
static int ld_twa_dump(struct ld_softc *, void *, int, int);
static int ld_twa_flush(struct ld_softc *, int);
static void ld_twa_handler(struct twa_request *);
static int ld_twa_match(struct device *, struct cfdata *, void *);
static int ld_twa_match(device_t, cfdata_t, void *);
static int ld_twa_start(struct ld_softc *, struct buf *);
static void ld_twa_adjqparam(struct device *, int);
static void ld_twa_adjqparam(device_t, int);
static int ld_twa_scsicmd(struct ld_twa_softc *,
struct twa_request *, struct buf *);
CFATTACH_DECL(ld_twa, sizeof(struct ld_twa_softc),
CFATTACH_DECL_NEW(ld_twa, sizeof(struct ld_twa_softc),
ld_twa_match, ld_twa_attach, ld_twa_detach, NULL);
static const struct twa_callbacks ld_twa_callbacks = {
@ -99,24 +99,21 @@ static const struct twa_callbacks ld_twa_callbacks = {
};
static int
ld_twa_match(struct device *parent, struct cfdata *match, void *aux)
ld_twa_match(device_t parent, cfdata_t match, void *aux)
{
return (1);
}
static void
ld_twa_attach(struct device *parent, struct device *self, void *aux)
ld_twa_attach(device_t parent, device_t self, void *aux)
{
struct twa_attach_args *twa_args;
struct ld_twa_softc *sc;
struct ld_softc *ld;
struct twa_softc *twa;
struct twa_attach_args *twa_args = aux;
struct ld_twa_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
struct twa_softc *twa = device_private(parent);
sc = (struct ld_twa_softc *)self;
ld = &sc->sc_ld;
twa = (struct twa_softc *)parent;
twa_args = aux;
ld->sc_dv = self;
twa_register_callbacks(twa, twa_args->twaa_unit, &ld_twa_callbacks);
@ -133,13 +130,15 @@ ld_twa_attach(struct device *parent, struct device *self, void *aux)
}
static int
ld_twa_detach(struct device *self, int flags)
ld_twa_detach(device_t self, int flags)
{
struct ld_twa_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
int error;
if ((error = ldbegindetach((struct ld_softc *)self, flags)) != 0)
if ((error = ldbegindetach(ld, flags)) != 0)
return (error);
ldenddetach((struct ld_softc *)self);
ldenddetach(ld);
return (0);
}
@ -152,7 +151,7 @@ ld_twa_dobio(struct ld_twa_softc *sc, void *data, size_t datasize,
struct twa_request *tr;
struct twa_softc *twa;
twa = (struct twa_softc *)sc->sc_ld.sc_dv.dv_parent;
twa = device_private(device_parent(sc->sc_ld.sc_dv));
if ((tr = twa_get_request(twa, 0)) == NULL) {
return (EAGAIN);
@ -211,7 +210,7 @@ ld_twa_handler(struct twa_request *tr)
bp = tr->bp;
sc = (struct ld_twa_softc *)tr->tr_ld_sc;
twa = (struct twa_softc *)sc->sc_ld.sc_dv.dv_parent;
twa = device_private(device_parent(sc->sc_ld.sc_dv));
status = tr->tr_command->command.cmd_pkt_9k.status;
@ -247,7 +246,7 @@ ld_twa_flush(struct ld_softc *ld, int flags)
{
int s, rv = 0;
struct twa_request *tr;
struct twa_softc *twa = (void *)ld->sc_dv.dv_parent;
struct twa_softc *twa = device_private(device_parent(ld->sc_dv));
struct ld_twa_softc *sc = (void *)ld;
struct twa_command_generic *generic_cmd;
@ -285,10 +284,12 @@ ld_twa_flush(struct ld_softc *ld, int flags)
}
static void
ld_twa_adjqparam(struct device *self, int openings)
ld_twa_adjqparam(device_t self, int openings)
{
struct ld_twa_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
ldadjqparam((struct ld_softc *)self, openings);
ldadjqparam(ld, openings);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_twe.c,v 1.31 2008/08/11 06:46:10 simonb Exp $ */
/* $NetBSD: ld_twe.c,v 1.32 2008/09/09 12:45:40 tron Exp $ */
/*-
* Copyright (c) 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_twe.c,v 1.31 2008/08/11 06:46:10 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_twe.c,v 1.32 2008/09/09 12:45:40 tron Exp $");
#include "rnd.h"
@ -66,19 +66,19 @@ struct ld_twe_softc {
int sc_hwunit;
};
static void ld_twe_attach(struct device *, struct device *, void *);
static int ld_twe_detach(struct device *, int);
static void ld_twe_attach(device_t, device_t, void *);
static int ld_twe_detach(device_t, int);
static int ld_twe_dobio(struct ld_twe_softc *, void *, int, int, int,
struct buf *);
static int ld_twe_dump(struct ld_softc *, void *, int, int);
static int ld_twe_flush(struct ld_softc *, int);
static void ld_twe_handler(struct twe_ccb *, int);
static int ld_twe_match(struct device *, struct cfdata *, void *);
static int ld_twe_match(device_t, cfdata_t, void *);
static int ld_twe_start(struct ld_softc *, struct buf *);
static void ld_twe_adjqparam(struct device *, int);
static void ld_twe_adjqparam(device_t, int);
CFATTACH_DECL(ld_twe, sizeof(struct ld_twe_softc),
CFATTACH_DECL_NEW(ld_twe, sizeof(struct ld_twe_softc),
ld_twe_match, ld_twe_attach, ld_twe_detach, NULL);
static const struct twe_callbacks ld_twe_callbacks = {
@ -86,31 +86,26 @@ static const struct twe_callbacks ld_twe_callbacks = {
};
static int
ld_twe_match(struct device *parent, struct cfdata *match,
void *aux)
ld_twe_match(device_t parent, cfdata_t match, void *aux)
{
return (1);
}
static void
ld_twe_attach(struct device *parent, struct device *self, void *aux)
ld_twe_attach(device_t parent, device_t self, void *aux)
{
struct twe_attach_args *twea;
struct ld_twe_softc *sc;
struct ld_softc *ld;
struct twe_softc *twe;
struct twe_drive *td;
struct twe_attach_args *twea = aux;
struct ld_twe_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
struct twe_softc *twe = device_private(parent);
struct twe_drive *td = &twe->sc_units[twea->twea_unit];
const char *typestr, *stripestr, *statstr;
char unktype[16], stripebuf[32], unkstat[32];
int error;
uint8_t status;
sc = (struct ld_twe_softc *)self;
ld = &sc->sc_ld;
twe = (struct twe_softc *)parent;
twea = aux;
td = &twe->sc_units[twea->twea_unit];
ld->sc_dv = self;
twe_register_callbacks(twe, twea->twea_unit, &ld_twe_callbacks);
@ -164,13 +159,15 @@ ld_twe_attach(struct device *parent, struct device *self, void *aux)
}
static int
ld_twe_detach(struct device *self, int flags)
ld_twe_detach(device_t self, int flags)
{
struct ld_twe_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
int rv;
if ((rv = ldbegindetach((struct ld_softc *)self, flags)) != 0)
if ((rv = ldbegindetach(ld, flags)) != 0)
return (rv);
ldenddetach((struct ld_softc *)self);
ldenddetach(ld);
return (0);
}
@ -184,7 +181,7 @@ ld_twe_dobio(struct ld_twe_softc *sc, void *data, int datasize, int blkno,
struct twe_softc *twe;
int s, rv, flags;
twe = (struct twe_softc *)device_parent(&sc->sc_ld.sc_dv);
twe = device_private(device_parent(sc->sc_ld.sc_dv));
flags = (dowrite ? TWE_CCB_DATA_OUT : TWE_CCB_DATA_IN);
if ((ccb = twe_ccb_alloc(twe, flags)) == NULL)
@ -251,7 +248,7 @@ ld_twe_handler(struct twe_ccb *ccb, int error)
tx = &ccb->ccb_tx;
bp = tx->tx_context;
sc = (struct ld_twe_softc *)tx->tx_dv;
twe = (struct twe_softc *)device_parent(&sc->sc_ld.sc_dv);
twe = device_private(device_parent(sc->sc_ld.sc_dv));
twe_ccb_unmap(twe, ccb);
twe_ccb_free(twe, ccb);
@ -277,7 +274,7 @@ static int
ld_twe_flush(struct ld_softc *ld, int flags)
{
struct ld_twe_softc *sc = (void *) ld;
struct twe_softc *twe = (void *) device_parent(&ld->sc_dv);
struct twe_softc *twe = device_private(device_parent(ld->sc_dv));
struct twe_ccb *ccb;
struct twe_cmd *tc;
int s, rv;
@ -307,7 +304,7 @@ ld_twe_flush(struct ld_softc *ld, int flags)
} else {
ccb->ccb_tx.tx_handler = twe_ccb_wait_handler;
ccb->ccb_tx.tx_context = NULL;
ccb->ccb_tx.tx_dv = &ld->sc_dv;
ccb->ccb_tx.tx_dv = ld->sc_dv;
twe_ccb_enqueue(twe, ccb);
rv = 0;
@ -326,6 +323,8 @@ ld_twe_flush(struct ld_softc *ld, int flags)
static void
ld_twe_adjqparam(struct device *self, int openings)
{
struct ld_twe_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
ldadjqparam((struct ld_softc *)self, openings);
ldadjqparam(ld, openings);
}