Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Convert twa(4) to device_t (CFATTACH_DECL_NEW).



details:   https://anonhg.NetBSD.org/src/rev/10c7fb8a00c2
branches:  trunk
changeset: 780495:10c7fb8a00c2
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Fri Jul 27 14:02:17 2012 +0000

description:
Convert twa(4) to device_t (CFATTACH_DECL_NEW).

diffstat:

 sys/dev/pci/twa.c    |  100 ++++++++++++++++++++++++++------------------------
 sys/dev/pci/twavar.h |    4 +-
 2 files changed, 54 insertions(+), 50 deletions(-)

diffs (truncated from 414 to 300 lines):

diff -r d4b15f0997da -r 10c7fb8a00c2 sys/dev/pci/twa.c
--- a/sys/dev/pci/twa.c Fri Jul 27 09:10:59 2012 +0000
+++ b/sys/dev/pci/twa.c Fri Jul 27 14:02:17 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: twa.c,v 1.40 2012/01/30 19:41:23 drochner Exp $ */
+/*     $NetBSD: twa.c,v 1.41 2012/07/27 14:02:17 jakllsch Exp $ */
 /*     $wasabi: twa.c,v 1.27 2006/07/28 18:17:21 wrstuden Exp $        */
 
 /*-
@@ -67,7 +67,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: twa.c,v 1.40 2012/01/30 19:41:23 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: twa.c,v 1.41 2012/07/27 14:02:17 jakllsch Exp $");
+
+#define TWA_DEBUG
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -140,7 +142,7 @@
 extern uint32_t twa_fw_img_size;
 extern uint8_t twa_fw_img[];
 
-CFATTACH_DECL(twa, sizeof(struct twa_softc),
+CFATTACH_DECL_NEW(twa, sizeof(struct twa_softc),
     twa_match, twa_attach, NULL, NULL);
 
 /* FreeBSD driver revision for sysctl expected by the 3ware cli */
@@ -728,7 +730,7 @@
 twa_print_inquiry_data(struct twa_softc *sc, struct scsipi_inquiry_data *scsipi)
 {
 
-    printf("%s: %s\n", device_xname(&sc->twa_dv), scsipi->vendor);
+    printf("%s: %s\n", device_xname(sc->twa_dv), scsipi->vendor);
 
     return (1);
 }
@@ -839,7 +841,7 @@
        if ((rv = bus_dmamem_alloc(sc->twa_dma_tag,
                size, PAGE_SIZE, 0, &seg,
                1, &rseg, BUS_DMA_NOWAIT)) != 0){
-                       aprint_error_dev(&sc->twa_dv, "unable to allocate "
+                       aprint_error_dev(sc->twa_dv, "unable to allocate "
                                "command packets, rv = %d\n", rv);
                        return (ENOMEM);
        }
@@ -847,14 +849,14 @@
        if ((rv = bus_dmamem_map(sc->twa_dma_tag,
                &seg, rseg, size, (void **)&sc->twa_cmds,
                BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
-                       aprint_error_dev(&sc->twa_dv, "unable to map commands, rv = %d\n", rv);
+                       aprint_error_dev(sc->twa_dv, "unable to map commands, rv = %d\n", rv);
                        return (1);
        }
 
        if ((rv = bus_dmamap_create(sc->twa_dma_tag,
                size, num_reqs, size,
                0, BUS_DMA_NOWAIT, &sc->twa_cmd_map)) != 0) {
-                       aprint_error_dev(&sc->twa_dv, "unable to create command DMA map, "
+                       aprint_error_dev(sc->twa_dv, "unable to create command DMA map, "
                                "rv = %d\n", rv);
                        return (ENOMEM);
        }
@@ -862,13 +864,13 @@
        if ((rv = bus_dmamap_load(sc->twa_dma_tag, sc->twa_cmd_map,
                sc->twa_cmds, size, NULL,
                BUS_DMA_NOWAIT)) != 0) {
-                       aprint_error_dev(&sc->twa_dv, "unable to load command DMA map, "
+                       aprint_error_dev(sc->twa_dv, "unable to load command DMA map, "
                                "rv = %d\n", rv);
                        return (1);
        }
 
        if ((uintptr_t)sc->twa_cmds % TWA_ALIGNMENT) {
-               aprint_error_dev(&sc->twa_dv, "DMA map memory not aligned on %d boundary\n", TWA_ALIGNMENT);
+               aprint_error_dev(sc->twa_dv, "DMA map memory not aligned on %d boundary\n", TWA_ALIGNMENT);
 
                return (1);
        }
@@ -901,7 +903,7 @@
                if ((rv = bus_dmamap_create(sc->twa_dma_tag,
                        max_xfer, max_segs, 1, 0, BUS_DMA_NOWAIT,
                        &tr->tr_dma_map)) != 0) {
-                               aprint_error_dev(&sc->twa_dv, "unable to create command "
+                               aprint_error_dev(sc->twa_dv, "unable to create command "
                                        "DMA map, rv = %d\n", rv);
                                return (ENOMEM);
                }
@@ -947,7 +949,7 @@
 
 #ifdef TWA_DEBUG
                printf("%s: unit %d openings %d\n",
-                               device_xname(&sc->twa_dv), unit, openings);
+                               device_xname(sc->twa_dv), unit, openings);
 #endif
                if (td->td_dev != NULL)
                        (*td->td_callbacks->tcb_openings)(td->td_dev, td->td_openings);
@@ -997,7 +999,7 @@
                                locs[TWACF_UNIT] = unit;
 
                                sc->sc_units[unit].td_dev =
-                                   config_found_sm_loc(&sc->twa_dv, "twa",
+                                   config_found_sm_loc(sc->twa_dv, "twa",
                                    locs, &twaa, twa_print, config_stdsubmatch);
                        }
                } else {
@@ -1465,7 +1467,7 @@
                /* Soft reset the controller, and try one more time. */
 
                printf("%s: controller initialization failed. "
-                   "Retrying initialization\n", device_xname(&sc->twa_dv));
+                   "Retrying initialization\n", device_xname(sc->twa_dv));
 
                if ((error = twa_soft_reset(sc)) == 0)
                        error = twa_init_ctlr(sc);
@@ -1500,6 +1502,8 @@
 
        sc = device_private(self);
 
+       sc->twa_dv = self;
+
        pa = aux;
        pc = pa->pa_pc;
        sc->pc = pa->pa_pc;
@@ -1514,7 +1518,7 @@
                use_64bit = false;
                if (pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_TYPE_IO, 0,
                    &sc->twa_bus_iot, &sc->twa_bus_ioh, NULL, NULL)) {
-                       aprint_error_dev(&sc->twa_dv, "can't map i/o space\n");
+                       aprint_error_dev(sc->twa_dv, "can't map i/o space\n");
                        return;
                }
        } else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_3WARE_9550) {
@@ -1523,7 +1527,7 @@
                if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x08, 
                    PCI_MAPREG_MEM_TYPE_64BIT, 0, &sc->twa_bus_iot, 
                    &sc->twa_bus_ioh, NULL, NULL)) {
-                       aprint_error_dev(&sc->twa_dv, "can't map mem space\n");
+                       aprint_error_dev(sc->twa_dv, "can't map mem space\n");
                        return;
                }
        } else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_3WARE_9650) {
@@ -1532,7 +1536,7 @@
                if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x08, 
                    PCI_MAPREG_MEM_TYPE_64BIT, 0, &sc->twa_bus_iot, 
                    &sc->twa_bus_ioh, NULL, NULL)) {
-                       aprint_error_dev(&sc->twa_dv, "can't map mem space\n");
+                       aprint_error_dev(sc->twa_dv, "can't map mem space\n");
                        return;
                }
                sc->sc_quirks |= TWA_QUIRK_QUEUEFULL_BUG;
@@ -1542,20 +1546,20 @@
                if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x08, 
                    PCI_MAPREG_MEM_TYPE_64BIT, 0, &sc->twa_bus_iot, 
                    &sc->twa_bus_ioh, NULL, NULL)) {
-                       aprint_error_dev(&sc->twa_dv, "can't map mem space\n");
+                       aprint_error_dev(sc->twa_dv, "can't map mem space\n");
                        return;
                }
                sc->sc_quirks |= TWA_QUIRK_QUEUEFULL_BUG;
        } else {
                sc->sc_nunits = 0;
                use_64bit = false;
-               aprint_error_dev(&sc->twa_dv, "product id 0x%02x not recognized\n", 
+               aprint_error_dev(sc->twa_dv, "product id 0x%02x not recognized\n", 
                    PCI_PRODUCT(pa->pa_id));
                return;
        }
 
        if (pci_dma64_available(pa) && use_64bit) {
-               aprint_verbose_dev(self, "64bit DMA addressing active");
+               aprint_verbose_dev(self, "64-bit DMA addressing active\n");
                sc->twa_dma_tag = pa->pa_dmat64;
        } else {
                sc->twa_dma_tag = pa->pa_dmat;
@@ -1570,21 +1574,21 @@
 
        /* Map and establish the interrupt. */
        if (pci_intr_map(pa, &ih)) {
-               aprint_error_dev(&sc->twa_dv, "can't map interrupt\n");
+               aprint_error_dev(sc->twa_dv, "can't map interrupt\n");
                return;
        }
        intrstr = pci_intr_string(pc, ih);
 
        sc->twa_ih = pci_intr_establish(pc, ih, IPL_BIO, twa_intr, sc);
        if (sc->twa_ih == NULL) {
-               aprint_error_dev(&sc->twa_dv, "can't establish interrupt%s%s\n",
+               aprint_error_dev(sc->twa_dv, "can't establish interrupt%s%s\n",
                        (intrstr) ? " at " : "",
                        (intrstr) ? intrstr : "");
                return;
        }
 
        if (intrstr != NULL)
-               aprint_normal_dev(&sc->twa_dv, "interrupting at %s\n",
+               aprint_normal_dev(sc->twa_dv, "interrupting at %s\n",
                        intrstr);
 
        twa_setup(sc);
@@ -1597,18 +1601,18 @@
                                CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw",
                                NULL, NULL, 0, NULL, 0,
                                CTL_HW, CTL_EOL) != 0) {
-               aprint_error_dev(&sc->twa_dv, "could not create %s sysctl node\n",
+               aprint_error_dev(sc->twa_dv, "could not create %s sysctl node\n",
                        "hw");
                return;
        }
        if (sysctl_createv(NULL, 0, NULL, &node,
-                               0, CTLTYPE_NODE, device_xname(&sc->twa_dv),
+                               0, CTLTYPE_NODE, device_xname(sc->twa_dv),
                                SYSCTL_DESCR("twa driver information"),
                                NULL, 0, NULL, 0,
                                CTL_HW, CTL_CREATE, CTL_EOL) != 0) {
-               aprint_error_dev(&sc->twa_dv, "could not create %s.%s sysctl node\n",
+               aprint_error_dev(sc->twa_dv, "could not create %s.%s sysctl node\n",
                        "hw",
-                       device_xname(&sc->twa_dv));
+                       device_xname(sc->twa_dv));
                return;
        }
        if ((i = sysctl_createv(NULL, 0, NULL, NULL,
@@ -1617,9 +1621,9 @@
                                NULL, 0, __UNCONST(&twaver), 0,
                                CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
                                != 0) {
-               aprint_error_dev(&sc->twa_dv, "could not create %s.%s.driver_version sysctl\n",
+               aprint_error_dev(sc->twa_dv, "could not create %s.%s.driver_version sysctl\n",
                        "hw",
-                       device_xname(&sc->twa_dv));
+                       device_xname(sc->twa_dv));
                return;
        }
 
@@ -1887,7 +1891,7 @@
 #ifdef DIAGNOSTIC
                if (rv != 0)
                        printf("%s: unable to retrieve AEN (%d)\n",
-                               device_xname(&sc->twa_dv), rv);
+                               device_xname(sc->twa_dv), rv);
 #endif
                caught = 1;
        }
@@ -2178,7 +2182,7 @@
                }
                if ((error = copyout(sc->twa_aen_queue [event_index],
                    user_buf->pdata, sizeof(struct tw_cl_event_packet))) != 0)
-                       aprint_error_dev(&sc->twa_dv, "get_previous: Could not copyout to "
+                       aprint_error_dev(sc->twa_dv, "get_previous: Could not copyout to "
                            "event_buf. error = %x\n",
                            error);
                (sc->twa_aen_queue[event_index])->retrieved = TWA_AEN_RETRIEVED;
@@ -2613,34 +2617,34 @@
                        TWA_CONTROL_DISABLE_INTERRUPTS);
 
        if (twa_drain_response_queue_large(sc, 30) != 0) {
-               aprint_error_dev(&sc->twa_dv,
+               aprint_error_dev(sc->twa_dv,
                    "response queue not empty after reset.\n");
                return(1);
        }
        if (twa_wait_status(sc, TWA_STATUS_MICROCONTROLLER_READY |
                                TWA_STATUS_ATTENTION_INTERRUPT, 30)) {
-               aprint_error_dev(&sc->twa_dv, "no attention interrupt after reset.\n");
+               aprint_error_dev(sc->twa_dv, "no attention interrupt after reset.\n");
                return(1);
        }
        twa_outl(sc, TWA_CONTROL_REGISTER_OFFSET,
                TWA_CONTROL_CLEAR_ATTENTION_INTERRUPT);
 
        if (twa_drain_response_queue(sc)) {
-               aprint_error_dev(&sc->twa_dv, "cannot drain response queue.\n");
+               aprint_error_dev(sc->twa_dv, "cannot drain response queue.\n");
                return(1);
        }
        if (twa_drain_aen_queue(sc)) {
-               aprint_error_dev(&sc->twa_dv, "cannot drain AEN queue.\n");
+               aprint_error_dev(sc->twa_dv, "cannot drain AEN queue.\n");
                return(1);
        }
        if (twa_find_aen(sc, TWA_AEN_SOFT_RESET)) {
-               aprint_error_dev(&sc->twa_dv, "reset not reported by controller.\n");
+               aprint_error_dev(sc->twa_dv, "reset not reported by controller.\n");
                return(1);
        }
        status_reg = twa_inl(sc, TWA_STATUS_REGISTER_OFFSET);
        if (TWA_STATUS_ERRORS(status_reg) ||
            twa_check_ctlr_state(sc, status_reg)) {
-               aprint_error_dev(&sc->twa_dv, "controller errors detected.\n");
+               aprint_error_dev(sc->twa_dv, "controller errors detected.\n");
                return(1);
        }
        return(0);
@@ -2770,7 +2774,7 @@
                                &sync_time, twa_aen_callback);
 #ifdef DIAGNOSTIC
                if (rv != 0)
-                       aprint_error_dev(&sc->twa_dv, "unable to sync time with ctlr\n");



Home | Main Index | Thread Index | Old Index