Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x68k/dev KNF and cosmetics. No binary change.



details:   https://anonhg.NetBSD.org/src/rev/cf3eac0d3f67
branches:  trunk
changeset: 779241:cf3eac0d3f67
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun May 13 03:00:40 2012 +0000

description:
KNF and cosmetics.  No binary change.

diffstat:

 sys/arch/x68k/dev/fd.c |  267 +++++++++++++++++++++++++-----------------------
 1 files changed, 138 insertions(+), 129 deletions(-)

diffs (truncated from 739 to 300 lines):

diff -r fd67c6180823 -r cf3eac0d3f67 sys/arch/x68k/dev/fd.c
--- a/sys/arch/x68k/dev/fd.c    Sun May 13 01:03:13 2012 +0000
+++ b/sys/arch/x68k/dev/fd.c    Sun May 13 03:00:40 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $  */
+/*     $NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m68k_arch.h"
@@ -144,7 +144,7 @@
 
        bus_dma_tag_t sc_dmat;          /* intio DMA tag */
        bus_dmamap_t sc_dmamap;         /* DMA map */
-       u_int8_t *sc_addr;                      /* physical address */
+       uint8_t *sc_addr;               /* physical address */
        struct dmac_channel_stat *sc_dmachan; /* intio DMA channel */
        struct dmac_dma_xfer *sc_xfer;  /* DMA transfer */
        int sc_read;
@@ -153,7 +153,7 @@
        TAILQ_HEAD(drivehead, fd_softc) sc_drives;
        enum fdc_state sc_state;
        int sc_errors;                  /* number of retries so far */
-       u_char sc_status[7];            /* copy of registers */
+       uint8_t sc_status[7];           /* copy of registers */
 } fdc_softc;
 
 int fdcintr(void *);
@@ -233,8 +233,8 @@
        int sc_ops;             /* I/O ops since last switch */
        struct bufq_state *sc_q;/* pending I/O requests */
        int sc_active;          /* number of active I/O operations */
-       u_char *sc_copybuf;     /* for secsize >=3 */
-       u_char sc_part;         /* for secsize >=3 */
+       uint8_t *sc_copybuf;    /* for secsize >=3 */
+       uint8_t sc_part;        /* for secsize >=3 */
 #define        SEC_P10 0x02            /* first part */
 #define        SEC_P01 0x01            /* second part */
 #define        SEC_P11 0x03            /* both part */
@@ -275,7 +275,7 @@
 void fd_motor_on(void *);
 #endif
 int fdcresult(struct fdc_softc *);
-int out_fdc(bus_space_tag_t, bus_space_handle_t, u_char);
+int out_fdc(bus_space_tag_t, bus_space_handle_t, uint8_t);
 void fdcstart(struct fdc_softc *);
 void fdcstatus(device_t, int, const char *);
 void fdctimeout(void *);
@@ -300,16 +300,16 @@
        int error;
 
        DPRINTF(("fdc_dmastart: %s, addr = %p, count = %ld\n",
-                read ? "read" : "write", (void *) addr, count));
+           read ? "read" : "write", (void *)addr, count));
 
        error = bus_dmamap_load(fdc->sc_dmat, fdc->sc_dmamap, addr, count,
-                               0, BUS_DMA_NOWAIT);
+           0, BUS_DMA_NOWAIT);
        if (error) {
-               panic ("fdc_dmastart: cannot load dmamap");
+               panic("fdc_dmastart: cannot load dmamap");
        }
 
        bus_dmamap_sync(fdc->sc_dmat, fdc->sc_dmamap, 0, count,
-                       read?BUS_DMASYNC_PREREAD:BUS_DMASYNC_PREWRITE);
+           read ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
 
        /*
         * Note 1:
@@ -324,13 +324,10 @@
         * XXX: No proper API to get DMA address of FDC register for DMAC.
         */
        fdc->sc_xfer = dmac_prepare_xfer(fdc->sc_dmachan, fdc->sc_dmat,
-                                        fdc->sc_dmamap,
-                                        (read?
-                                         DMAC_OCR_DIR_DTM:DMAC_OCR_DIR_MTD),
-                                        (DMAC_SCR_MAC_COUNT_UP|
-                                         DMAC_SCR_DAC_NO_COUNT),
-                                        (u_int8_t*) (fdc->sc_addr +
-                                                     fddata * 2 + 1));
+           fdc->sc_dmamap,
+           read ? DMAC_OCR_DIR_DTM : DMAC_OCR_DIR_MTD,
+           DMAC_SCR_MAC_COUNT_UP | DMAC_SCR_DAC_NO_COUNT,
+           fdc->sc_addr + fddata * 2 + 1);
 
        fdc->sc_read = read;
        dmac_start_xfer(fdc->sc_dmachan->ch_softc, fdc->sc_xfer);
@@ -353,6 +350,7 @@
 static int
 fdcdmaerrintr(void *dummy)
 {
+
        DPRINTF(("fdcdmaerrintr\n"));
 
        return 0;
@@ -380,7 +378,7 @@
                return 0;
 
        ia->ia_size = 0x2000;
-       if (intio_map_allocate_region (parent, ia, INTIO_MAP_TESTONLY))
+       if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
                return 0;
 
        /* builtin device; always there */
@@ -407,7 +405,7 @@
 {
        struct fdc_attach_args *fa = aux;
 
-       if (!fdc)
+       if (fdc == NULL)
                aprint_normal(" drive %d", fa->fa_drive);
        return QUIET;
 }
@@ -441,18 +439,16 @@
 
        /* Initialize DMAC channel */
        fdc->sc_dmachan = dmac_alloc_channel(parent, ia->ia_dma, "fdc",
-                                            ia->ia_dmaintr, fdcdmaintr, fdc,
-                                            ia->ia_dmaintr+1, fdcdmaerrintr,
-                                            fdc);
+           ia->ia_dmaintr, fdcdmaintr, fdc,
+           ia->ia_dmaintr + 1, fdcdmaerrintr, fdc);
        if (bus_dmamap_create(fdc->sc_dmat, FDC_MAXIOSIZE, 1, DMAC_MAXSEGSZ,
-                             0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW,
-                             &fdc->sc_dmamap)) {
+           0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &fdc->sc_dmamap)) {
                aprint_error_dev(self, "can't set up intio DMA map\n");
                return;
        }
 
-       if (intio_intr_establish(ia->ia_intr, "fdc", fdcintr, fdc))
-               panic ("Could not establish interrupt (duplicated vector?).");
+       if (intio_intr_establish(ia->ia_intr, "fdc", fdcintr, fdc) != 0)
+               panic("Could not establish interrupt (duplicated vector?).");
        intio_set_ivec(ia->ia_intr);
 
        /* reset */
@@ -462,7 +458,7 @@
        fdcreset(fdc);
 
        aprint_normal_dev(self, "uPD72065 FDC\n");
-       out_fdc(iot, ioh, NE7CMD_SPECIFY);/* specify command */
+       out_fdc(iot, ioh, NE7CMD_SPECIFY);      /* specify command */
        out_fdc(iot, ioh, 0xd0);
        out_fdc(iot, ioh, 0x10);
 
@@ -477,6 +473,7 @@
 void
 fdcreset(struct fdc_softc *fdc)
 {
+
        bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdsts, NE7CMD_RESET);
 }
 
@@ -484,8 +481,9 @@
 fdcpoll(struct fdc_softc *fdc)
 {
        int i = 25000, n;
+
        while (--i > 0) {
-               if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC)) {
+               if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC) != 0) {
                        out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);
                        n = fdcresult(fdc);
                        break;
@@ -521,13 +519,13 @@
        fdc_force_ready(FDCRDY);
        fdcpoll(fdc);
 
-retry:
+ retry:
        out_fdc(iot, ioh, NE7CMD_RECAL);
        out_fdc(iot, ioh, drive);
 
        i = 25000;
        while (--i > 0) {
-               if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC)) {
+               if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC) != 0) {
                        out_fdc(iot, ioh, NE7CMD_SENSEI);
                        n = fdcresult(fdc);
                        break;
@@ -554,7 +552,7 @@
 
        /* turn off motor */
        bus_space_write_1(fdc->sc_iot, fdc->sc_ioh,
-                         fdctl, (type->rate << 4)| drive);
+           fdctl, (type->rate << 4) | drive);
        fdc_force_ready(FDCSTBY);
        if (!found) {
                intio_enable_intr(SICILIAN_INTR_FDC);
@@ -586,7 +584,7 @@
 
        if (type)
                aprint_normal(": %s, %d cyl, %d head, %d sec\n", type->name,
-                      type->cyls, type->heads, type->sectrac);
+                   type->cyls, type->heads, type->sectrac);
        else
                aprint_normal(": density unknown\n");
 
@@ -596,7 +594,7 @@
        fd->sc_deftype = type;
        fdc->sc_fd[drive] = fd;
 
-       fd->sc_copybuf = (u_char *)malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
+       fd->sc_copybuf = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
        if (fd->sc_copybuf == 0)
                aprint_error("%s: WARNING!! malloc() failed.\n", __func__);
        fd->sc_flags |= FD_ALIVE;
@@ -614,7 +612,7 @@
        mountroothook_establish(fd_mountroot_hook, fd->sc_dev);
 
        rnd_attach_source(&fd->rnd_source, device_xname(fd->sc_dev),
-                         RND_TYPE_DISK, 0);
+           RND_TYPE_DISK, 0);
 }
 
 inline struct fd_type *
@@ -645,8 +643,8 @@
        if (bp->b_blkno < 0 ||
            (bp->b_bcount % FDC_BSIZE) != 0) {
                DPRINTF(("fdstrategy: unit=%d, blkno=%" PRId64 ", "
-                        "bcount=%d\n", unit,
-                        bp->b_blkno, bp->b_bcount));
+                   "bcount=%d\n", unit,
+                   bp->b_blkno, bp->b_bcount));
                bp->b_error = EINVAL;
                goto done;
        }
@@ -676,11 +674,11 @@
        }
 
        bp->b_rawblkno = bp->b_blkno;
-       bp->b_cylinder = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE)
-               / (fd->sc_type->seccyl * (1 << (fd->sc_type->secsize - 2)));
+       bp->b_cylinder = (bp->b_blkno / (FDC_BSIZE / DEV_BSIZE)) /
+           (fd->sc_type->seccyl * (1 << (fd->sc_type->secsize - 2)));
 
        DPRINTF(("fdstrategy: %s b_blkno %" PRId64 " b_bcount %d cylin %d\n",
-                bp->b_flags & B_READ ? "read" : "write",
+           bp->b_flags & B_READ ? "read" : "write",
                 bp->b_blkno, bp->b_bcount, bp->b_cylinder));
        /* Queue transfer on drive, activate drive and controller if idle. */
        s = splbio();
@@ -690,7 +688,9 @@
                fdstart(fd);
 #ifdef DIAGNOSTIC
        else {
-               struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
+               struct fdc_softc *fdc;
+
+               fdc = device_private(device_parent(fd->sc_dev));
                if (fdc->sc_state == DEVIDLE) {
                        printf("fdstrategy: controller inactive\n");
                        fdcstart(fdc);
@@ -700,7 +700,7 @@
        splx(s);
        return;
 
-done:
+ done:
        /* Toss transfer; we're done early. */
        biodone(bp);
 }
@@ -735,9 +735,9 @@
        if (TAILQ_NEXT(fd, sc_drivechain) && ++fd->sc_ops >= 8) {
                fd->sc_ops = 0;
                TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
-               if (bufq_peek(fd->sc_q) != NULL) {
+               if (bufq_peek(fd->sc_q) != NULL)
                        TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
-               } else
+               else
                        fd->sc_active = 0;
        }
        bp->b_resid = fd->sc_bcount;
@@ -755,14 +755,14 @@
 fdread(dev_t dev, struct uio *uio, int flags)
 {
 
-       return (physio(fdstrategy, NULL, dev, B_READ, minphys, uio));
+       return physio(fdstrategy, NULL, dev, B_READ, minphys, uio);
 }
 
 int
 fdwrite(dev_t dev, struct uio *uio, int flags)
 {
 
-       return (physio(fdstrategy, NULL, dev, B_WRITE, minphys, uio));
+       return physio(fdstrategy, NULL, dev, B_WRITE, minphys, uio);
 }
 
 void



Home | Main Index | Thread Index | Old Index