Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Split device_t
details: https://anonhg.NetBSD.org/src/rev/f626e816ef36
branches: trunk
changeset: 778194:f626e816ef36
user: martin <martin%NetBSD.org@localhost>
date: Sun Mar 18 21:05:21 2012 +0000
description:
Split device_t
diffstat:
sys/dev/ic/mpt.c | 6 +++---
sys/dev/ic/mpt_netbsd.c | 45 ++++++++++++++++++++++++++-------------------
sys/dev/ic/mpt_netbsd.h | 4 ++--
sys/dev/pci/mpt_pci.c | 19 ++++++++++---------
4 files changed, 41 insertions(+), 33 deletions(-)
diffs (truncated from 307 to 300 lines):
diff -r 378221c45a96 -r f626e816ef36 sys/dev/ic/mpt.c
--- a/sys/dev/ic/mpt.c Sun Mar 18 19:21:53 2012 +0000
+++ b/sys/dev/ic/mpt.c Sun Mar 18 21:05:21 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt.c,v 1.15 2011/05/24 10:08:03 mrg Exp $ */
+/* $NetBSD: mpt.c,v 1.16 2012/03/18 21:05:21 martin Exp $ */
/*
* Copyright (c) 2000, 2001 by Greg Ansley
@@ -110,7 +110,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.15 2011/05/24 10:08:03 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.16 2012/03/18 21:05:21 martin Exp $");
#include <dev/ic/mpt.h>
@@ -1153,7 +1153,7 @@
if (mpt_hw_init(mpt) != 0)
return (EIO);
- dict = device_properties(&mpt->sc_dev);
+ dict = device_properties(mpt->sc_dev);
for (try = 0; try < MPT_MAX_TRYS; try++) {
/*
diff -r 378221c45a96 -r f626e816ef36 sys/dev/ic/mpt_netbsd.c
--- a/sys/dev/ic/mpt_netbsd.c Sun Mar 18 19:21:53 2012 +0000
+++ b/sys/dev/ic/mpt_netbsd.c Sun Mar 18 21:05:21 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt_netbsd.c,v 1.17 2012/01/30 17:45:14 mhitch Exp $ */
+/* $NetBSD: mpt_netbsd.c,v 1.18 2012/03/18 21:05:21 martin Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.17 2012/01/30 17:45:14 mhitch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.18 2012/03/18 21:05:21 martin Exp $");
#include <dev/ic/mpt.h> /* pulls in all headers */
@@ -94,6 +94,13 @@
scsipi_adapter_req_t, void *);
static void mpt_minphys(struct buf *);
+/*
+ * XXX - this assumes the device_private() of the attachement starts with
+ * a struct mpt_softc, so we can use the return value of device_private()
+ * straight without any offset.
+ */
+#define DEV_TO_MPT(DEV) device_private(DEV)
+
void
mpt_scsipi_attach(mpt_softc_t *mpt)
{
@@ -108,7 +115,7 @@
/* Fill in the scsipi_adapter. */
memset(adapt, 0, sizeof(*adapt));
- adapt->adapt_dev = &mpt->sc_dev;
+ adapt->adapt_dev = mpt->sc_dev;
adapt->adapt_nchannels = 1;
adapt->adapt_openings = maxq - 2; /* Reserve 2 for driver use*/
adapt->adapt_max_periph = maxq - 2;
@@ -125,7 +132,7 @@
chan->chan_ntargets = mpt->mpt_max_devices;
chan->chan_id = mpt->mpt_ini_id;
- (void) config_found(&mpt->sc_dev, &mpt->sc_channel, scsiprint);
+ (void) config_found(mpt->sc_dev, &mpt->sc_channel, scsiprint);
}
int
@@ -149,7 +156,7 @@
len = sizeof(request_t) * MPT_MAX_REQUESTS(mpt);
mpt->request_pool = malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
if (mpt->request_pool == NULL) {
- aprint_error_dev(&mpt->sc_dev, "unable to allocate request pool\n");
+ aprint_error_dev(mpt->sc_dev, "unable to allocate request pool\n");
return (ENOMEM);
}
@@ -159,7 +166,7 @@
error = bus_dmamem_alloc(mpt->sc_dmat, PAGE_SIZE, PAGE_SIZE, 0,
&reply_seg, 1, &reply_rseg, 0);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to allocate reply area, error = %d\n",
+ aprint_error_dev(mpt->sc_dev, "unable to allocate reply area, error = %d\n",
error);
goto fail_0;
}
@@ -167,7 +174,7 @@
error = bus_dmamem_map(mpt->sc_dmat, &reply_seg, reply_rseg, PAGE_SIZE,
(void **) &mpt->reply, BUS_DMA_COHERENT/*XXX*/);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to map reply area, error = %d\n",
+ aprint_error_dev(mpt->sc_dev, "unable to map reply area, error = %d\n",
error);
goto fail_1;
}
@@ -175,7 +182,7 @@
error = bus_dmamap_create(mpt->sc_dmat, PAGE_SIZE, 1, PAGE_SIZE,
0, 0, &mpt->reply_dmap);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to create reply DMA map, error = %d\n",
+ aprint_error_dev(mpt->sc_dev, "unable to create reply DMA map, error = %d\n",
error);
goto fail_2;
}
@@ -183,7 +190,7 @@
error = bus_dmamap_load(mpt->sc_dmat, mpt->reply_dmap, mpt->reply,
PAGE_SIZE, NULL, 0);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to load reply DMA map, error = %d\n",
+ aprint_error_dev(mpt->sc_dev, "unable to load reply DMA map, error = %d\n",
error);
goto fail_3;
}
@@ -195,7 +202,7 @@
error = bus_dmamem_alloc(mpt->sc_dmat, MPT_REQ_MEM_SIZE(mpt),
PAGE_SIZE, 0, &request_seg, 1, &request_rseg, 0);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to allocate request area, "
+ aprint_error_dev(mpt->sc_dev, "unable to allocate request area, "
"error = %d\n", error);
goto fail_4;
}
@@ -203,7 +210,7 @@
error = bus_dmamem_map(mpt->sc_dmat, &request_seg, request_rseg,
MPT_REQ_MEM_SIZE(mpt), (void **) &mpt->request, 0);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to map request area, error = %d\n",
+ aprint_error_dev(mpt->sc_dev, "unable to map request area, error = %d\n",
error);
goto fail_5;
}
@@ -211,7 +218,7 @@
error = bus_dmamap_create(mpt->sc_dmat, MPT_REQ_MEM_SIZE(mpt), 1,
MPT_REQ_MEM_SIZE(mpt), 0, 0, &mpt->request_dmap);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to create request DMA map, "
+ aprint_error_dev(mpt->sc_dev, "unable to create request DMA map, "
"error = %d\n", error);
goto fail_6;
}
@@ -219,7 +226,7 @@
error = bus_dmamap_load(mpt->sc_dmat, mpt->request_dmap, mpt->request,
MPT_REQ_MEM_SIZE(mpt), NULL, 0);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to load request DMA map, error = %d\n",
+ aprint_error_dev(mpt->sc_dev, "unable to load request DMA map, error = %d\n",
error);
goto fail_7;
}
@@ -246,7 +253,7 @@
error = bus_dmamap_create(mpt->sc_dmat, MAXPHYS,
MPT_SGL_MAX, MAXPHYS, 0, 0, &req->dmap);
if (error) {
- aprint_error_dev(&mpt->sc_dev, "unable to create req %d DMA map, "
+ aprint_error_dev(mpt->sc_dev, "unable to create req %d DMA map, "
"error = %d\n", i, error);
goto fail_8;
}
@@ -318,7 +325,7 @@
{
va_list ap;
- printf("%s: ", device_xname(&mpt->sc_dev));
+ printf("%s: ", device_xname(mpt->sc_dev));
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
@@ -346,8 +353,8 @@
request_t *req = arg;
struct scsipi_xfer *xs = req->xfer;
struct scsipi_periph *periph = xs->xs_periph;
- mpt_softc_t *mpt =
- (void *) periph->periph_channel->chan_adapter->adapt_dev;
+ mpt_softc_t *mpt = DEV_TO_MPT(
+ periph->periph_channel->chan_adapter->adapt_dev);
uint32_t oseq;
int s;
@@ -1135,7 +1142,7 @@
mpt_prt(mpt, "EvtLogData: Event Data:");
for (i = 0; i < msg->EventDataLength; i++) {
if ((i % 4) == 0)
- printf("%s:\t", device_xname(&mpt->sc_dev));
+ printf("%s:\t", device_xname(mpt->sc_dev));
printf("0x%08x%c", msg->Data[i],
((i % 4) == 3) ? '\n' : ' ');
}
@@ -1338,7 +1345,7 @@
void *arg)
{
struct scsipi_adapter *adapt = chan->chan_adapter;
- mpt_softc_t *mpt = (void *) adapt->adapt_dev;
+ mpt_softc_t *mpt = DEV_TO_MPT(adapt->adapt_dev);
switch (req) {
case ADAPTER_REQ_RUN_XFER:
diff -r 378221c45a96 -r f626e816ef36 sys/dev/ic/mpt_netbsd.h
--- a/sys/dev/ic/mpt_netbsd.h Sun Mar 18 19:21:53 2012 +0000
+++ b/sys/dev/ic/mpt_netbsd.h Sun Mar 18 21:05:21 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt_netbsd.h,v 1.9 2010/11/13 13:52:01 uebayasi Exp $ */
+/* $NetBSD: mpt_netbsd.h,v 1.10 2012/03/18 21:05:21 martin Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -160,7 +160,7 @@
} request_t;
typedef struct mpt_softc {
- struct device sc_dev; /* base device glue */
+ device_t sc_dev; /* base device glue */
/* Locking context */
int mpt_splsaved;
diff -r 378221c45a96 -r f626e816ef36 sys/dev/pci/mpt_pci.c
--- a/sys/dev/pci/mpt_pci.c Sun Mar 18 19:21:53 2012 +0000
+++ b/sys/dev/pci/mpt_pci.c Sun Mar 18 21:05:21 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt_pci.c,v 1.21 2012/01/30 19:41:22 drochner Exp $ */
+/* $NetBSD: mpt_pci.c,v 1.22 2012/03/18 21:05:21 martin Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt_pci.c,v 1.21 2012/01/30 19:41:22 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_pci.c,v 1.22 2012/03/18 21:05:21 martin Exp $");
#include <dev/ic/mpt.h> /* pulls in all headers */
@@ -140,6 +140,7 @@
psc->sc_pc = pa->pa_pc;
psc->sc_tag = pa->pa_tag;
+ mpt->sc_dev = self;
mpt->sc_dmat = pa->pa_dmat;
/*
@@ -161,7 +162,7 @@
mpt->sc_st = memt;
mpt->sc_sh = memh;
} else {
- aprint_error_dev(&mpt->sc_dev, "unable to map device registers\n");
+ aprint_error_dev(mpt->sc_dev, "unable to map device registers\n");
return;
}
@@ -181,7 +182,7 @@
*/
if ((PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SYMBIOS_1030) &&
(PCI_REVISION(pa->pa_class) < 0x08)) {
- aprint_normal_dev(&mpt->sc_dev, "applying 1030 quirk\n");
+ aprint_normal_dev(mpt->sc_dev, "applying 1030 quirk\n");
reg = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x68);
reg &= 0x8fffff;
pci_conf_write(pa->pa_pc, pa->pa_tag, 0x68, reg);
@@ -198,19 +199,19 @@
* Map and establish our interrupt.
*/
if (pci_intr_map(pa, &ih) != 0) {
- aprint_error_dev(&mpt->sc_dev, "unable to map interrupt\n");
+ aprint_error_dev(mpt->sc_dev, "unable to map interrupt\n");
return;
}
intrstr = pci_intr_string(pa->pa_pc, ih);
psc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, mpt_intr, mpt);
if (psc->sc_ih == NULL) {
- aprint_error_dev(&mpt->sc_dev, "unable to establish interrupt");
+ aprint_error_dev(mpt->sc_dev, "unable to establish interrupt");
if (intrstr != NULL)
aprint_error(" at %s", intrstr);
aprint_error("\n");
return;
}
- aprint_normal_dev(&mpt->sc_dev, "interrupting at %s\n",
+ aprint_normal_dev(mpt->sc_dev, "interrupting at %s\n",
intrstr);
/* Disable interrupts on the part. */
@@ -218,7 +219,7 @@
/* Allocate DMA memory. */
if (mpt_dma_mem_alloc(mpt) != 0) {
- aprint_error_dev(&mpt->sc_dev, "unable to allocate DMA memory\n");
+ aprint_error_dev(mpt->sc_dev, "unable to allocate DMA memory\n");
return;
}
@@ -232,6 +233,6 @@
Home |
Main Index |
Thread Index |
Old Index