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 to device_t.



details:   https://anonhg.NetBSD.org/src/rev/1517da4d6de0
branches:  trunk
changeset: 777709:1517da4d6de0
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Fri Mar 02 11:41:36 2012 +0000

description:
convert to device_t.

diffstat:

 sys/dev/pci/gcscaudio.c |  73 ++++++++++++++++++++++++------------------------
 1 files changed, 37 insertions(+), 36 deletions(-)

diffs (262 lines):

diff -r 161a29509c72 -r 1517da4d6de0 sys/dev/pci/gcscaudio.c
--- a/sys/dev/pci/gcscaudio.c   Fri Mar 02 07:21:49 2012 +0000
+++ b/sys/dev/pci/gcscaudio.c   Fri Mar 02 11:41:36 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcscaudio.c,v 1.11 2011/11/25 12:50:32 jmcneill Exp $  */
+/*     $NetBSD: gcscaudio.c,v 1.12 2012/03/02 11:41:36 nonaka Exp $    */
 
 /*-
  * Copyright (c) 2008 SHIMIZU Ryo <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gcscaudio.c,v 1.11 2011/11/25 12:50:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gcscaudio.c,v 1.12 2012/03/02 11:41:36 nonaka Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -84,7 +84,7 @@
 };
 
 struct gcscaudio_softc {
-       struct device sc_dev;
+       device_t sc_dev;
        kmutex_t sc_lock;
        kmutex_t sc_intr_lock;
        pci_chipset_tag_t sc_pc;
@@ -174,7 +174,7 @@
                                   bus_dmamap_t *);
 
 
-CFATTACH_DECL(gcscaudio, sizeof (struct gcscaudio_softc),
+CFATTACH_DECL_NEW(gcscaudio, sizeof (struct gcscaudio_softc),
     gcscaudio_match, gcscaudio_attach, NULL, NULL);
 
 
@@ -248,7 +248,7 @@
                          const struct audio_format *format)
 {
        if (sc->sc_nformats >= GCSCAUDIO_MAXFORMATS) {
-               aprint_error_dev(&sc->sc_dev, "too many formats\n");
+               aprint_error_dev(sc->sc_dev, "too many formats\n");
                return EINVAL;
        }
        sc->sc_formats[sc->sc_nformats++] = *format;
@@ -266,6 +266,8 @@
 
        sc = device_private(self);
 
+       sc->sc_dev = self;
+
        aprint_naive(": Audio controller\n");
 
        pa = aux;
@@ -281,12 +283,12 @@
 
        if (pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_TYPE_IO, 0,
            &sc->sc_iot, &sc->sc_ioh, NULL, &sc->sc_ios)) {
-               aprint_error_dev(&sc->sc_dev, "can't map i/o space\n");
+               aprint_error_dev(sc->sc_dev, "can't map i/o space\n");
                return;
        }
 
        if (pci_intr_map(pa, &ih)) {
-               aprint_error_dev(&sc->sc_dev, "couldn't map interrupt\n");
+               aprint_error_dev(sc->sc_dev, "couldn't map interrupt\n");
                goto attach_failure_unmap;
        }
        intrstr = pci_intr_string(sc->sc_pc, ih);
@@ -294,14 +296,14 @@
        sc->sc_ih = pci_intr_establish(sc->sc_pc, ih, IPL_AUDIO,
            gcscaudio_intr, sc);
        if (sc->sc_ih == NULL) {
-               aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt");
+               aprint_error_dev(sc->sc_dev, "couldn't establish interrupt");
                if (intrstr != NULL)
                        aprint_error(" at %s", intrstr);
                aprint_error("\n");
                goto attach_failure_unmap;
        }
 
-       aprint_normal_dev(&sc->sc_dev, "interrupting at %s\n", intrstr);
+       aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr);
 
 
        if (gcscaudio_allocate_dma(sc, sizeof(*sc->sc_prd.p_prdtables),
@@ -317,7 +319,7 @@
        sc->host_if.spdif_event = gcscaudio_spdif_event_codec;
 
        if ((rc = ac97_attach(&sc->host_if, self, &sc->sc_lock)) != 0) {
-               aprint_error_dev(&sc->sc_dev,
+               aprint_error_dev(sc->sc_dev,
                    "can't attach codec (error=%d)\n", rc);
                goto attach_failure_intr;
        }
@@ -349,7 +351,7 @@
                goto attach_failure_codec;
        }
 
-       audio_attach_mi(&gcscaudio_hw_if, sc, &sc->sc_dev);
+       audio_attach_mi(&gcscaudio_hw_if, sc, sc->sc_dev);
        return;
 
 attach_failure_codec:
@@ -408,7 +410,7 @@
                delay(1);
 
        if (i < 0) {
-               aprint_error_dev(&sc->sc_dev, "%s", timeout_msg);
+               aprint_error_dev(sc->sc_dev, "%s", timeout_msg);
                return 1;
        }
 
@@ -432,7 +434,7 @@
                return 1;
 
 #ifdef GCSCAUDIO_CODEC_DEBUG
-       aprint_error_dev(&sc->sc_dev, "codec write: reg=0x%02x, val=0x%04x\n",
+       aprint_error_dev(sc->sc_dev, "codec write: reg=0x%02x, val=0x%04x\n",
            reg, val);
 #endif
 
@@ -465,12 +467,12 @@
        }
 
        if (i < 0) {
-               aprint_error_dev(&sc->sc_dev, "codec read timeout\n");
+               aprint_error_dev(sc->sc_dev, "codec read timeout\n");
                return 1;
        }
 
 #ifdef GCSCAUDIO_CODEC_DEBUG
-       aprint_error_dev(&sc->sc_dev, "codec read: reg=0x%02x, val=0x%04x\n",
+       aprint_error_dev(sc->sc_dev, "codec read: reg=0x%02x, val=0x%04x\n",
            reg, v & ACC_CODEC_STATUS_STS_DATA_MASK);
 #endif
 
@@ -778,8 +780,7 @@
                }
        }
        if (!paddr) {
-               aprint_error_dev(&sc->sc_dev,
-                   "bad addr %p\n", addr);
+               aprint_error_dev(sc->sc_dev, "bad addr %p\n", addr);
                return EINVAL;
        }
 
@@ -1222,9 +1223,9 @@
        if (intr & ACC_IRQ_STATUS_BM0_IRQ_STS) {
                bmstat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, ACC_BM0_STATUS);
                if (bmstat & ACC_BMx_STATUS_BM_EOP_ERR)
-                       aprint_normal_dev(&sc->sc_dev, "BM0: Bus Master Error\n");
+                       aprint_normal_dev(sc->sc_dev, "BM0: Bus Master Error\n");
                if (!(bmstat & ACC_BMx_STATUS_EOP))
-                       aprint_normal_dev(&sc->sc_dev, "BM0: NO End of Page?\n");
+                       aprint_normal_dev(sc->sc_dev, "BM0: NO End of Page?\n");
 
                if (sc->sc_play.ch_intr) {
                        sc->sc_play.ch_intr(sc->sc_play.ch_intr_arg);
@@ -1237,9 +1238,9 @@
        if (intr & ACC_IRQ_STATUS_BM4_IRQ_STS) {
                bmstat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, ACC_BM4_STATUS);
                if (bmstat & ACC_BMx_STATUS_BM_EOP_ERR)
-                       aprint_normal_dev(&sc->sc_dev, "BM4: Bus Master Error\n");
+                       aprint_normal_dev(sc->sc_dev, "BM4: Bus Master Error\n");
                if (!(bmstat & ACC_BMx_STATUS_EOP))
-                       aprint_normal_dev(&sc->sc_dev, "BM4: NO End of Page?\n");
+                       aprint_normal_dev(sc->sc_dev, "BM4: NO End of Page?\n");
 
                nintr++;
        }
@@ -1248,9 +1249,9 @@
        if (intr & ACC_IRQ_STATUS_BM6_IRQ_STS) {
                bmstat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, ACC_BM6_STATUS);
                if (bmstat & ACC_BMx_STATUS_BM_EOP_ERR)
-                       aprint_normal_dev(&sc->sc_dev, "BM6: Bus Master Error\n");
+                       aprint_normal_dev(sc->sc_dev, "BM6: Bus Master Error\n");
                if (!(bmstat & ACC_BMx_STATUS_EOP))
-                       aprint_normal_dev(&sc->sc_dev, "BM6: NO End of Page?\n");
+                       aprint_normal_dev(sc->sc_dev, "BM6: NO End of Page?\n");
 
                nintr++;
        }
@@ -1259,9 +1260,9 @@
        if (intr & ACC_IRQ_STATUS_BM7_IRQ_STS) {
                bmstat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, ACC_BM7_STATUS);
                if (bmstat & ACC_BMx_STATUS_BM_EOP_ERR)
-                       aprint_normal_dev(&sc->sc_dev, "BM7: Bus Master Error\n");
+                       aprint_normal_dev(sc->sc_dev, "BM7: Bus Master Error\n");
                if (!(bmstat & ACC_BMx_STATUS_EOP))
-                       aprint_normal_dev(&sc->sc_dev, "BM7: NO End of Page?\n");
+                       aprint_normal_dev(sc->sc_dev, "BM7: NO End of Page?\n");
 
                nintr++;
        }
@@ -1270,9 +1271,9 @@
        if (intr & ACC_IRQ_STATUS_BM1_IRQ_STS) {
                bmstat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, ACC_BM1_STATUS);
                if (bmstat & ACC_BMx_STATUS_BM_EOP_ERR)
-                       aprint_normal_dev(&sc->sc_dev, "BM1: Bus Master Error\n");
+                       aprint_normal_dev(sc->sc_dev, "BM1: Bus Master Error\n");
                if (!(bmstat & ACC_BMx_STATUS_EOP))
-                       aprint_normal_dev(&sc->sc_dev, "BM1: NO End of Page?\n");
+                       aprint_normal_dev(sc->sc_dev, "BM1: NO End of Page?\n");
 
                if (sc->sc_rec.ch_intr) {
                        sc->sc_rec.ch_intr(sc->sc_rec.ch_intr_arg);
@@ -1282,15 +1283,15 @@
 
 #ifdef GCSCAUDIO_DEBUG
        if (intr & ACC_IRQ_STATUS_IRQ_STS)
-               aprint_normal_dev(&sc->sc_dev, "Codec GPIO IRQ Status\n");
+               aprint_normal_dev(sc->sc_dev, "Codec GPIO IRQ Status\n");
        if (intr & ACC_IRQ_STATUS_WU_IRQ_STS)
-               aprint_normal_dev(&sc->sc_dev, "Codec GPIO Wakeup IRQ Status\n");
+               aprint_normal_dev(sc->sc_dev, "Codec GPIO Wakeup IRQ Status\n");
        if (intr & ACC_IRQ_STATUS_BM2_IRQ_STS)
-               aprint_normal_dev(&sc->sc_dev, "Audio Bus Master 2 IRQ Status\n");
+               aprint_normal_dev(sc->sc_dev, "Audio Bus Master 2 IRQ Status\n");
        if (intr & ACC_IRQ_STATUS_BM3_IRQ_STS)
-               aprint_normal_dev(&sc->sc_dev, "Audio Bus Master 3 IRQ Status\n");
+               aprint_normal_dev(sc->sc_dev, "Audio Bus Master 3 IRQ Status\n");
        if (intr & ACC_IRQ_STATUS_BM5_IRQ_STS)
-               aprint_normal_dev(&sc->sc_dev, "Audio Bus Master 5 IRQ Status\n");
+               aprint_normal_dev(sc->sc_dev, "Audio Bus Master 5 IRQ Status\n");
 #endif
 
 done:
@@ -1320,14 +1321,14 @@
 
        if ((error = bus_dmamem_alloc(sc->sc_dmat, size, PAGE_SIZE, 0, seglist,
            nseg, rsegp, BUS_DMA_WAITOK)) != 0) {
-               aprint_error_dev(&sc->sc_dev,
+               aprint_error_dev(sc->sc_dev,
                    "unable to allocate DMA buffer, error=%d\n", error);
                goto fail_alloc;
        }
 
        if ((error = bus_dmamem_map(sc->sc_dmat, seglist, nseg, size, addrp,
            BUS_DMA_WAITOK | BUS_DMA_COHERENT)) != 0) {
-               aprint_error_dev(&sc->sc_dev,
+               aprint_error_dev(sc->sc_dev,
                    "unable to map DMA buffer, error=%d\n",
                    error);
                goto fail_map;
@@ -1335,14 +1336,14 @@
 
        if ((error = bus_dmamap_create(sc->sc_dmat, size, nseg, size, 0,
            BUS_DMA_WAITOK, mapp)) != 0) {
-               aprint_error_dev(&sc->sc_dev,
+               aprint_error_dev(sc->sc_dev,
                    "unable to create DMA map, error=%d\n", error);
                goto fail_create;
        }
 
        if ((error = bus_dmamap_load(sc->sc_dmat, *mapp, *addrp, size, NULL,
            BUS_DMA_WAITOK)) != 0) {
-               aprint_error_dev(&sc->sc_dev,
+               aprint_error_dev(sc->sc_dev,
                    "unable to load DMA map, error=%d\n", error);
                goto fail_load;
        }



Home | Main Index | Thread Index | Old Index