Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic -make it compile with ATPPC_DEBUG



details:   https://anonhg.NetBSD.org/src/rev/52aa8c6456c5
branches:  trunk
changeset: 558083:52aa8c6456c5
user:      drochner <drochner%NetBSD.org@localhost>
date:      Wed Jan 28 14:26:24 2004 +0000

description:
-make it compile with ATPPC_DEBUG
-minor cleanup (whitespace, avoid a typecast)

diffstat:

 sys/dev/ic/atppc.c |  877 +++++++++++++++++++++++++---------------------------
 1 files changed, 425 insertions(+), 452 deletions(-)

diffs (truncated from 2244 to 300 lines):

diff -r 2a2b419d9d2f -r 52aa8c6456c5 sys/dev/ic/atppc.c
--- a/sys/dev/ic/atppc.c        Wed Jan 28 13:51:16 2004 +0000
+++ b/sys/dev/ic/atppc.c        Wed Jan 28 14:26:24 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atppc.c,v 1.8 2004/01/25 11:41:17 jdolecek Exp $ */
+/* $NetBSD: atppc.c,v 1.9 2004/01/28 14:26:24 drochner Exp $ */
 
 /*
  * Copyright (c) 2001 Alcove - Nicolas Souchu
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atppc.c,v 1.8 2004/01/25 11:41:17 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atppc.c,v 1.9 2004/01/28 14:26:24 drochner Exp $");
 
 #include "opt_atppc.h"
 
@@ -67,7 +67,7 @@
 
 /* List of supported chipsets detection routines */
 static int (*chipset_detect[])(struct atppc_softc *) = {
-/* XXX Add these LATER: maybe as seperate devices? 
+/* XXX Add these LATER: maybe as seperate devices?
                atppc_pc873xx_detect,
                atppc_smc37c66xgt_detect,
                atppc_w83877f_detect,
@@ -76,7 +76,7 @@
                NULL
 };
 
- 
+
 /* Prototypes for functions. */
 
 /* Soft configuration attach */
@@ -87,7 +87,7 @@
 int atppcintr(void *);
 
 /* Print function for config_found_sm() */
-static int atppc_print(void * aux, const char * name);
+static int atppc_print(void *, const char *);
        
 /* Detection routines */
 static int atppc_detect_fifo(struct atppc_softc *);
@@ -107,7 +107,7 @@
 static int atppc_read_ivar(struct device *, int, unsigned int *);
 static int atppc_write_ivar(struct device *, int, unsigned int *);
 static int atppc_add_handler(struct device *, void (*)(void *), void *);
-static int atppc_remove_handler(struct device *, void (*)(void *)); 
+static int atppc_remove_handler(struct device *, void (*)(void *));
 
 /* Utility functions */
 
@@ -116,9 +116,9 @@
 static void atppc_byte_read(struct atppc_softc * const);
 static void atppc_epp_read(struct atppc_softc * const);
 static void atppc_ecp_read(struct atppc_softc * const);
-static void atppc_ecp_read_dma(struct atppc_softc *, unsigned int *, 
+static void atppc_ecp_read_dma(struct atppc_softc *, unsigned int *,
        unsigned char);
-static void atppc_ecp_read_pio(struct atppc_softc *, unsigned int *, 
+static void atppc_ecp_read_pio(struct atppc_softc *, unsigned int *,
        unsigned char);
 static void atppc_ecp_read_error(struct atppc_softc *, const unsigned int);
 
@@ -127,61 +127,61 @@
 static void atppc_std_write(struct atppc_softc * const);
 static void atppc_epp_write(struct atppc_softc * const);
 static void atppc_fifo_write(struct atppc_softc * const);
-static void atppc_fifo_write_dma(struct atppc_softc * const, unsigned char, 
+static void atppc_fifo_write_dma(struct atppc_softc * const, unsigned char,
        unsigned char);
 static void atppc_fifo_write_pio(struct atppc_softc * const, unsigned char,
        unsigned char);
-static void atppc_fifo_write_error(struct atppc_softc * const, 
+static void atppc_fifo_write_error(struct atppc_softc * const,
        const unsigned int);
 
 /* Miscellaneous */
-static int atppc_poll_str(const struct atppc_softc * const, const u_int8_t, 
+static int atppc_poll_str(const struct atppc_softc * const, const u_int8_t,
        const u_int8_t);
-static int atppc_wait_interrupt(struct atppc_softc * const, const caddr_t, 
+static int atppc_wait_interrupt(struct atppc_softc * const, const caddr_t,
        const u_int8_t);
 
 
 /*
- * Generic attach and detach functions for atppc device. If sc_dev_ok in soft 
+ * Generic attach and detach functions for atppc device. If sc_dev_ok in soft
  * configuration data is not ATPPC_ATTACHED, these should be skipped altogether.
  */
 
 /* Soft configuration attach for atppc */
 void
-atppc_sc_attach(struct atppc_softc * lsc)
+atppc_sc_attach(struct atppc_softc *lsc)
 {
        /* Adapter used to configure ppbus device */
        struct parport_adapter sc_parport_adapter;
        char buf[64];
 
        /* Probe and set up chipset */
-       if(atppc_detect_chipset(lsc) != 0) {
-               if(atppc_detect_generic(lsc) != 0) {
-                       ATPPC_DPRINTF(("%s: Error detecting chipset\n", 
-                               dev->dv_xname)); 
+       if (atppc_detect_chipset(lsc) != 0) {
+               if (atppc_detect_generic(lsc) != 0) {
+                       ATPPC_DPRINTF(("%s: Error detecting chipset\n",
+                               lsc->sc_dev.dv_xname));
                }
        }
 
        /* Probe and setup FIFO queue */
        if (atppc_detect_fifo(lsc) == 0) {
-               printf("%s: FIFO <depth,wthr,rthr>=<%d,%d,%d>\n", 
-                       lsc->sc_dev.dv_xname, lsc->sc_fifo, lsc->sc_wthr, 
+               printf("%s: FIFO <depth,wthr,rthr>=<%d,%d,%d>\n",
+                       lsc->sc_dev.dv_xname, lsc->sc_fifo, lsc->sc_wthr,
                        lsc->sc_rthr);
        }
 
         /* Print out chipset capabilities */
        bitmask_snprintf(lsc->sc_has, "\20\1INTR\2DMA\3FIFO\4PS2\5ECP\6EPP",
-               buf, sizeof(buf)); 
-       printf("%s: capabilities=%s\n", lsc->sc_dev.dv_xname, buf); 
+               buf, sizeof(buf));
+       printf("%s: capabilities=%s\n", lsc->sc_dev.dv_xname, buf);
 
        /* Initialize device's buffer pointers */
-       lsc->sc_outb = lsc->sc_outbstart = lsc->sc_inb = lsc->sc_inbstart 
+       lsc->sc_outb = lsc->sc_outbstart = lsc->sc_inb = lsc->sc_inbstart
                = NULL;
        lsc->sc_inb_nbytes = lsc->sc_outb_nbytes = 0;
 
        /* Last configuration step: set mode to standard mode */
-       if(atppc_setmode(&(lsc->sc_dev), PPBUS_COMPATIBLE) != 0) {
-               ATPPC_DPRINTF(("%s: unable to initialize mode.\n", 
+       if (atppc_setmode(&(lsc->sc_dev), PPBUS_COMPATIBLE) != 0) {
+               ATPPC_DPRINTF(("%s: unable to initialize mode.\n",
                        lsc->sc_dev.dv_xname));
        }
 
@@ -194,29 +194,29 @@
        
        /* Set capabilites */
        sc_parport_adapter.capabilities = 0;
-       if(lsc->sc_has & ATPPC_HAS_INTR) {
+       if (lsc->sc_has & ATPPC_HAS_INTR) {
                sc_parport_adapter.capabilities |= PPBUS_HAS_INTR;
        }
-       if(lsc->sc_has & ATPPC_HAS_DMA) {
+       if (lsc->sc_has & ATPPC_HAS_DMA) {
                sc_parport_adapter.capabilities |= PPBUS_HAS_DMA;
        }
-       if(lsc->sc_has & ATPPC_HAS_FIFO) {
+       if (lsc->sc_has & ATPPC_HAS_FIFO) {
                sc_parport_adapter.capabilities |= PPBUS_HAS_FIFO;
        }
-       if(lsc->sc_has & ATPPC_HAS_PS2) {
+       if (lsc->sc_has & ATPPC_HAS_PS2) {
                sc_parport_adapter.capabilities |= PPBUS_HAS_PS2;
        }
-       if(lsc->sc_has & ATPPC_HAS_EPP) {
+       if (lsc->sc_has & ATPPC_HAS_EPP) {
                sc_parport_adapter.capabilities |= PPBUS_HAS_EPP;
        }
-       if(lsc->sc_has & ATPPC_HAS_ECP) {
+       if (lsc->sc_has & ATPPC_HAS_ECP) {
                sc_parport_adapter.capabilities |= PPBUS_HAS_ECP;
        }
 
        /* Set function pointers */
        sc_parport_adapter.parport_io = atppc_io;
        sc_parport_adapter.parport_exec_microseq = atppc_exec_microseq;
-       sc_parport_adapter.parport_reset_epp_timeout = 
+       sc_parport_adapter.parport_reset_epp_timeout =
                atppc_reset_epp_timeout;
        sc_parport_adapter.parport_setmode = atppc_setmode;
        sc_parport_adapter.parport_getmode = atppc_getmode;
@@ -240,43 +240,42 @@
        /* Disable DMA/interrupts (each ppbus driver selects usage itself) */
        lsc->sc_use = 0;
 
-       /* Configure child of the device. */ 
-       lsc->child = config_found_sm(&(lsc->sc_dev), &(sc_parport_adapter), 
+       /* Configure child of the device. */
+       lsc->child = config_found_sm(&(lsc->sc_dev), &(sc_parport_adapter),
                atppc_print, NULL);
 
        return;
 }
 
 /* Soft configuration detach */
-int atppc_sc_detach(struct atppc_softc * lsc, int flag)
+int atppc_sc_detach(struct atppc_softc *lsc, int flag)
 {
-       struct device * dev = (struct device *) lsc;
+       struct device *dev = (struct device *)lsc;
 
        /* Detach children devices */
-       if(config_detach(lsc->child, flag) && !(flag & DETACH_QUIET)) {
+       if (config_detach(lsc->child, flag) && !(flag & DETACH_QUIET)) {
                printf("%s not able to detach child device, ", dev->dv_xname);
 
-               if(!(flag & DETACH_FORCE)) {
+               if (!(flag & DETACH_FORCE)) {
                        printf("cannot detach\n");
                        return 1;
-               }
-               else {
+               } else {
                        printf("continuing (DETACH_FORCE)\n");
                }
        }
 
-       if(!(flag & DETACH_QUIET)) 
+       if (!(flag & DETACH_QUIET))
                printf("%s detached", dev->dv_xname);
        
        return 0;
 }
 
 /* Used by config_found_sm() to print out device information */
-static int  
-atppc_print(void * aux, const char * name)
+static int
+atppc_print(void *aux, const char *name)
 {
        /* Print out something on failure. */
-       if(name != NULL) {
+       if (name != NULL) {
                printf("%s: child devices", name);
                return UNCONF;
        }
@@ -292,14 +291,15 @@
 int
 atppc_detect_port(bus_space_tag_t iot, bus_space_handle_t ioh)
 {
-        /* 
-        * Much shorter than scheme used by lpt_isa_probe() and lpt_port_test()          * in original lpt driver.
-        * Write to data register common to all controllers and read back the 
+        /*
+        * Much shorter than scheme used by lpt_isa_probe() and lpt_port_test()
+        * in original lpt driver.
+        * Write to data register common to all controllers and read back the
         * values. Also tests control and status registers.
         */
 
        /*
-        * Cannot use convenient macros because the device's config structure 
+        * Cannot use convenient macros because the device's config structure
         * may not have been created yet: major change from FreeBSD code.
         */
 
@@ -310,44 +310,41 @@
        str_sav = bus_space_read_1(iot, ioh, ATPPC_SPP_STR);
        ctr_sav = bus_space_read_1(iot, ioh, ATPPC_SPP_CTR);
        dtr_sav = bus_space_read_1(iot, ioh, ATPPC_SPP_DTR);
-       bus_space_barrier(iot, ioh, 0, IO_LPTSIZE, 
-               BUS_SPACE_BARRIER_READ); 
+       bus_space_barrier(iot, ioh, 0, IO_LPTSIZE,
+               BUS_SPACE_BARRIER_READ);
 
-        /* 
-        * Ensure PS2 ports in output mode, also read back value of control 
-        * register. 
+        /*
+        * Ensure PS2 ports in output mode, also read back value of control
+        * register.
         */
        bus_space_write_1(iot, ioh, ATPPC_SPP_CTR, 0x0c);
-       bus_space_barrier(iot, ioh, 0, IO_LPTSIZE, 
-               BUS_SPACE_BARRIER_WRITE); 
+       bus_space_barrier(iot, ioh, 0, IO_LPTSIZE,
+               BUS_SPACE_BARRIER_WRITE);
        
-       if(bus_space_read_1(iot, ioh, ATPPC_SPP_CTR) != 0x0c) {
+       if (bus_space_read_1(iot, ioh, ATPPC_SPP_CTR) != 0x0c) {
                rval = 0;
-       }
-       else {
-               /* 
-                * Test if two values can be written and read from the data 
-                * register. 
+       } else {
+               /*
+                * Test if two values can be written and read from the data
+                * register.
                 */
-               bus_space_barrier(iot, ioh, 0, IO_LPTSIZE, 
-                       BUS_SPACE_BARRIER_READ); 
+               bus_space_barrier(iot, ioh, 0, IO_LPTSIZE,
+                       BUS_SPACE_BARRIER_READ);
                bus_space_write_1(iot, ioh, ATPPC_SPP_DTR, 0xaa);
-               bus_space_barrier(iot, ioh, 0, IO_LPTSIZE, 
-                       BUS_SPACE_BARRIER_WRITE); 
+               bus_space_barrier(iot, ioh, 0, IO_LPTSIZE,



Home | Main Index | Thread Index | Old Index