Module Name: src Committed By: martin Date: Sun Mar 18 21:05:21 UTC 2012
Modified Files: src/sys/dev/ic: mpt.c mpt_netbsd.c mpt_netbsd.h src/sys/dev/pci: mpt_pci.c Log Message: Split device_t To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/mpt.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/mpt_netbsd.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/mpt_netbsd.h cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/mpt_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ic/mpt.c diff -u src/sys/dev/ic/mpt.c:1.15 src/sys/dev/ic/mpt.c:1.16 --- src/sys/dev/ic/mpt.c:1.15 Tue May 24 10:08:03 2011 +++ src/sys/dev/ic/mpt.c Sun Mar 18 21:05:21 2012 @@ -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 @@ mpt_init(mpt_softc_t *mpt, u_int32_t who 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++) { /* Index: src/sys/dev/ic/mpt_netbsd.c diff -u src/sys/dev/ic/mpt_netbsd.c:1.17 src/sys/dev/ic/mpt_netbsd.c:1.18 --- src/sys/dev/ic/mpt_netbsd.c:1.17 Mon Jan 30 17:45:14 2012 +++ src/sys/dev/ic/mpt_netbsd.c Sun Mar 18 21:05:21 2012 @@ -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 @@ static void mpt_scsipi_request(struct sc 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 @@ mpt_scsipi_attach(mpt_softc_t *mpt) /* 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 @@ mpt_scsipi_attach(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) 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 @@ mpt_prt(mpt_softc_t *mpt, const char *fm { 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 @@ mpt_timeout(void *arg) 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_event_notify_reply(mpt_softc_t *mpt, 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 @@ mpt_scsipi_request(struct scsipi_channel 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: Index: src/sys/dev/ic/mpt_netbsd.h diff -u src/sys/dev/ic/mpt_netbsd.h:1.9 src/sys/dev/ic/mpt_netbsd.h:1.10 --- src/sys/dev/ic/mpt_netbsd.h:1.9 Sat Nov 13 13:52:01 2010 +++ src/sys/dev/ic/mpt_netbsd.h Sun Mar 18 21:05:21 2012 @@ -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 @@ typedef struct req_entry { } 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; Index: src/sys/dev/pci/mpt_pci.c diff -u src/sys/dev/pci/mpt_pci.c:1.21 src/sys/dev/pci/mpt_pci.c:1.22 --- src/sys/dev/pci/mpt_pci.c:1.21 Mon Jan 30 19:41:22 2012 +++ src/sys/dev/pci/mpt_pci.c Sun Mar 18 21:05:21 2012 @@ -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 @@ mpt_pci_attach(device_t parent, device_t 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_pci_attach(device_t parent, device_t 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 @@ mpt_pci_attach(device_t parent, device_t */ 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 @@ mpt_pci_attach(device_t parent, device_t * 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 @@ mpt_pci_attach(device_t parent, device_t /* 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 @@ mpt_pci_attach(device_t parent, device_t mpt_scsipi_attach(mpt); } -CFATTACH_DECL(mpt_pci, sizeof(struct mpt_pci_softc), +CFATTACH_DECL_NEW(mpt_pci, sizeof(struct mpt_pci_softc), mpt_pci_match, mpt_pci_attach, NULL, NULL);