Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Misc KNF and cosmetics, and remove unnecessary casts...



details:   https://anonhg.NetBSD.org/src/rev/bd4323e087c1
branches:  trunk
changeset: 747496:bd4323e087c1
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Thu Sep 17 18:14:41 2009 +0000

description:
Misc KNF and cosmetics, and remove unnecessary casts etc.

diffstat:

 sys/dev/ic/i82365.c            |  148 +++++++++++++++++++++-------------------
 sys/dev/ic/i82365var.h         |    6 +-
 sys/dev/isa/i82365_isa.c       |   24 +++---
 sys/dev/isa/i82365_isasubr.c   |   24 +++---
 sys/dev/isa/i82365_isavar.h    |    6 +-
 sys/dev/isapnp/i82365_isapnp.c |   13 +-
 sys/dev/pci/i82365_pci.c       |   20 ++---
 sys/dev/pci/i82365_pcivar.h    |   18 ++--
 8 files changed, 131 insertions(+), 128 deletions(-)

diffs (truncated from 871 to 300 lines):

diff -r f1daf6da67f6 -r bd4323e087c1 sys/dev/ic/i82365.c
--- a/sys/dev/ic/i82365.c       Thu Sep 17 18:09:51 2009 +0000
+++ b/sys/dev/ic/i82365.c       Thu Sep 17 18:14:41 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82365.c,v 1.110 2009/09/14 13:41:15 tsutsui Exp $     */
+/*     $NetBSD: i82365.c,v 1.111 2009/09/17 18:14:41 tsutsui Exp $     */
 
 /*
  * Copyright (c) 2004 Charles M. Hannum.  All rights reserved.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.110 2009/09/14 13:41:15 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.111 2009/09/17 18:14:41 tsutsui Exp $");
 
 #define        PCICDEBUG
 
@@ -114,23 +114,24 @@
 int
 pcic_ident_ok(int ident)
 {
+
        /* this is very empirical and heuristic */
 
        if ((ident == 0) || (ident == 0xff) || (ident & PCIC_IDENT_ZERO))
-               return (0);
+               return 0;
 
        if ((ident & PCIC_IDENT_REV_MASK) == 0)
-               return (0);
+               return 0;
 
        if ((ident & PCIC_IDENT_IFTYPE_MASK) != PCIC_IDENT_IFTYPE_MEM_AND_IO) {
 #ifdef DIAGNOSTIC
                printf("pcic: does not support memory and I/O cards, "
                    "ignored (ident=%0x)\n", ident);
 #endif
-               return (0);
+               return 0;
        }
 
-       return (1);
+       return 1;
 }
 
 int
@@ -142,12 +143,12 @@
        reg = pcic_read(h, PCIC_IDENT);
 
        if ((reg & PCIC_IDENT_REV_MASK) == 0)
-               return (PCIC_VENDOR_NONE);
+               return PCIC_VENDOR_NONE;
 
        switch (reg) {
        case 0x00:
        case 0xff:
-               return (PCIC_VENDOR_NONE);
+               return PCIC_VENDOR_NONE;
        case PCIC_IDENT_ID_INTEL0:
                vendor = PCIC_VENDOR_I82365SLR0;
                break;
@@ -182,7 +183,7 @@
                    PCIC_CIRRUS_CHIP_INFO_CHIP_ID) {
                        reg = pcic_read(h, -1);
                        if ((reg & PCIC_CIRRUS_CHIP_INFO_CHIP_ID) == 0)
-                               return (PCIC_VENDOR_CIRRUS_PD67XX);
+                               return PCIC_VENDOR_CIRRUS_PD67XX;
                }
 
                /*
@@ -191,38 +192,39 @@
                reg = pcic_read(h, PCIC_RICOH_REG_CHIP_ID);
                switch (reg) {
                case PCIC_RICOH_CHIP_ID_5C296:
-                       return (PCIC_VENDOR_RICOH_5C296);
+                       return PCIC_VENDOR_RICOH_5C296;
                case PCIC_RICOH_CHIP_ID_5C396:
-                       return (PCIC_VENDOR_RICOH_5C396);
+                       return PCIC_VENDOR_RICOH_5C396;
                }
        }
 
-       return (vendor);
+       return vendor;
 }
 
 const char *
 pcic_vendor_to_string(int vendor)
 {
+
        switch (vendor) {
        case PCIC_VENDOR_I82365SLR0:
-               return ("Intel 82365SL Revision 0");
+               return "Intel 82365SL Revision 0";
        case PCIC_VENDOR_I82365SLR1:
-               return ("Intel 82365SL Revision 1");
+               return "Intel 82365SL Revision 1";
        case PCIC_VENDOR_CIRRUS_PD67XX:
-               return ("Cirrus PD6710/2X");
+               return "Cirrus PD6710/2X";
        case PCIC_VENDOR_I82365SL_DF:
-               return ("Intel 82365SL-DF");
+               return "Intel 82365SL-DF";
        case PCIC_VENDOR_RICOH_5C296:
-               return ("Ricoh RF5C296");
+               return "Ricoh RF5C296";
        case PCIC_VENDOR_RICOH_5C396:
-               return ("Ricoh RF5C396");
+               return "Ricoh RF5C396";
        case PCIC_VENDOR_IBM:
-               return ("IBM PCIC");
+               return "IBM PCIC";
        case PCIC_VENDOR_IBM_KING:
-               return ("IBM KING");
+               return "IBM KING";
        }
 
-       return ("Unknown controller");
+       return "Unknown controller";
 }
 
 void
@@ -259,7 +261,7 @@
                if (socket == 0) {
                        h->vendor = pcic_vendor(h);
                        if (i < __arraycount(sc->handle) - 1)
-                               (h+1)->vendor = h->vendor;
+                               (h + 1)->vendor = h->vendor;
                }
 
                switch (h->vendor) {
@@ -321,11 +323,11 @@
                    chip, pcic_vendor_to_string(sc->handle[i].vendor));
 
                if ((h->flags & PCIC_FLAG_SOCKETP) &&
-                   ((h+1)->flags & PCIC_FLAG_SOCKETP))
+                   ((h + 1)->flags & PCIC_FLAG_SOCKETP))
                        aprint_normal("sockets A and B\n");
                else if (h->flags & PCIC_FLAG_SOCKETP)
                        aprint_normal("socket A only\n");
-               else if ((h+1)->flags & PCIC_FLAG_SOCKETP)
+               else if ((h + 1)->flags & PCIC_FLAG_SOCKETP)
                        aprint_normal("socket B only\n");
                else
                        aprint_normal("no sockets\n");
@@ -348,7 +350,7 @@
 void
 pcic_power(int why, void *arg)
 {
-       struct pcic_handle *h = (struct pcic_handle *)arg;
+       struct pcic_handle *h = arg;
        struct pcic_softc *sc = device_private(h->ph_parent);
        int reg;
 
@@ -475,8 +477,8 @@
        /* clear possible card detect interrupt */
        (void) pcic_read(h, PCIC_CSC);
 
-       DPRINTF(("%s: attach finish vendor 0x%02x\n", device_xname(h->ph_parent),
-           h->vendor));
+       DPRINTF(("%s: attach finish vendor 0x%02x\n",
+           device_xname(h->ph_parent), h->vendor));
 
        /* unsleep the cirrus controller */
        if (h->vendor == PCIC_VENDOR_CIRRUS_PD67XX) {
@@ -511,7 +513,8 @@
 
        if (kthread_create(PRI_NONE, 0, NULL, pcic_event_thread, h,
            &h->event_thread, "%s,%s", device_xname(h->ph_parent), cs)) {
-               aprint_error_dev(h->ph_parent, "unable to create event thread for sock 0x%02x\n", h->sock);
+               aprint_error_dev(h->ph_parent,
+                   "unable to create event thread for sock 0x%02x\n", h->sock);
                panic("pcic_attach_socket");
        }
 }
@@ -548,7 +551,7 @@
                        splx(s);
                        /* sleep .25s to be enqueued chatterling interrupts */
                        (void) tsleep((void *)pcic_event_thread, PWAIT,
-                           "pcicss", hz/4);
+                           "pcicss", hz / 4);
                }
                s = splhigh();
                SIMPLEQ_REMOVE_HEAD(&h->events, pe_q);
@@ -557,7 +560,7 @@
                switch (pe->pe_type) {
                case PCIC_EVENT_INSERTION:
                        s = splhigh();
-                       while (1) {
+                       for (;;) {
                                struct pcic_event *pe1, *pe2;
 
                                if ((pe1 = SIMPLEQ_FIRST(&h->events)) == NULL)
@@ -582,7 +585,7 @@
 
                case PCIC_EVENT_REMOVAL:
                        s = splhigh();
-                       while (1) {
+                       for (;;) {
                                struct pcic_event *pe1, *pe2;
 
                                if ((pe1 = SIMPLEQ_FIRST(&h->events)) == NULL)
@@ -634,7 +637,7 @@
 
        aprint_normal(" controller %d socket %d", h->chip, h->socket);
 
-       return (UNCONF);
+       return UNCONF;
 }
 
 void
@@ -664,7 +667,7 @@
                if (sc->handle[i].flags & PCIC_FLAG_SOCKETP)
                        ret += pcic_intr_socket(&sc->handle[i]);
 
-       return (ret ? 1 : 0);
+       return ret ? 1 : 0;
 }
 
 int
@@ -681,21 +684,22 @@
                   PCIC_CSC_BATTDEAD);
 
        if (cscreg & PCIC_CSC_GPI) {
-               DPRINTF(("%s: %02x GPI\n", device_xname(h->ph_parent), h->sock));
+               DPRINTF(("%s: %02x GPI\n",
+                   device_xname(h->ph_parent), h->sock));
        }
        if (cscreg & PCIC_CSC_CD) {
                int statreg;
 
                statreg = pcic_read(h, PCIC_IF_STATUS);
 
-               DPRINTF(("%s: %02x CD %x\n", device_xname(h->ph_parent), h->sock,
-                   statreg));
+               DPRINTF(("%s: %02x CD %x\n", device_xname(h->ph_parent),
+                   h->sock, statreg));
 
                if ((statreg & PCIC_IF_STATUS_CARDDETECT_MASK) ==
                    PCIC_IF_STATUS_CARDDETECT_PRESENT) {
                        if (h->laststate != PCIC_LASTSTATE_PRESENT) {
                                DPRINTF(("%s: enqueing INSERTION event\n",
-                                        device_xname(h->ph_parent)));
+                                   device_xname(h->ph_parent)));
                                pcic_queue_event(h, PCIC_EVENT_INSERTION);
                        }
                        h->laststate = PCIC_LASTSTATE_PRESENT;
@@ -703,18 +707,19 @@
                        if (h->laststate == PCIC_LASTSTATE_PRESENT) {
                                /* Deactivate the card now. */
                                DPRINTF(("%s: deactivating card\n",
-                                        device_xname(h->ph_parent)));
+                                   device_xname(h->ph_parent)));
                                pcic_deactivate_card(h);
 
                                DPRINTF(("%s: enqueing REMOVAL event\n",
-                                        device_xname(h->ph_parent)));
+                                   device_xname(h->ph_parent)));
                                pcic_queue_event(h, PCIC_EVENT_REMOVAL);
                        }
                        h->laststate = PCIC_LASTSTATE_EMPTY;
                }
        }
        if (cscreg & PCIC_CSC_READY) {
-               DPRINTF(("%s: %02x READY\n", device_xname(h->ph_parent), h->sock));
+               DPRINTF(("%s: %02x READY\n", device_xname(h->ph_parent),
+                    h->sock));
                /* shouldn't happen */
        }
        if (cscreg & PCIC_CSC_BATTWARN) {
@@ -725,7 +730,7 @@
                DPRINTF(("%s: %02x BATTDEAD\n", device_xname(h->ph_parent),
                    h->sock));
        }
-       return (cscreg ? 1 : 0);
+       return cscreg ? 1 : 0;
 }
 
 void
@@ -749,7 +754,7 @@
 pcic_attach_card(struct pcic_handle *h)
 {
 
-       if (!(h->flags & PCIC_FLAG_CARDP)) {
+       if ((h->flags & PCIC_FLAG_CARDP) == 0) {
                /* call the MI attach function */
                pcmcia_card_attach(h->pcmcia);
 
@@ -792,7 +797,8 @@
 }
 
 int
-pcic_chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size, struct pcmcia_mem_handle *pcmhp)
+pcic_chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size,
+    struct pcmcia_mem_handle *pcmhp)
 {
        struct pcic_handle *h = (struct pcic_handle *) pch;
        bus_space_handle_t memh;
@@ -806,7 +812,7 @@



Home | Main Index | Thread Index | Old Index