Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Simplify the code a bit.



details:   https://anonhg.NetBSD.org/src/rev/e20ad53332ec
branches:  trunk
changeset: 483626:e20ad53332ec
user:      enami <enami%NetBSD.org@localhost>
date:      Tue Mar 14 10:26:10 2000 +0000

description:
Simplify the code a bit.

diffstat:

 sys/dev/pci/pccbb.c |  53 +++++++++++++++++++++--------------------------------
 1 files changed, 21 insertions(+), 32 deletions(-)

diffs (93 lines):

diff -r 7604023c7706 -r e20ad53332ec sys/dev/pci/pccbb.c
--- a/sys/dev/pci/pccbb.c       Tue Mar 14 10:23:16 2000 +0000
+++ b/sys/dev/pci/pccbb.c       Tue Mar 14 10:26:10 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pccbb.c,v 1.34 2000/03/14 10:23:16 enami Exp $ */
+/*     $NetBSD: pccbb.c,v 1.35 2000/03/14 10:26:10 enami Exp $ */
 
 /*
  * Copyright (c) 1998, 1999 and 2000
@@ -351,23 +351,18 @@
        u_int32_t pci_id;
        int *flagp;
 {
-       int loopend = sizeof(yc_chipsets) / sizeof(yc_chipsets[0]);
-       struct yenta_chipinfo *ycp, *ycend;
-
-       ycend = yc_chipsets + loopend;
-
-       for (ycp = yc_chipsets; ycp < ycend && pci_id != ycp->yc_id; ++ycp);
-
-       if (ycp == ycend) {
-               /* not found -- point at sentinel */
-               ycp = yc_chipsets + loopend - 1;
-       }
-
-       if (flagp != NULL) {
-               *flagp = ycp->yc_flags;
-       }
-
-       return ycp->yc_chiptype;
+       struct yenta_chipinfo *yc;
+
+       /* Loop over except the last default entry. */
+       for (yc = yc_chipsets; yc < yc_chipsets +
+           sizeof(yc_chipsets) / sizeof(yc_chipsets[0]) - 1; yc++)
+               if (pci_id != yc->yc_id)
+                       break;
+
+       if (flagp != NULL)
+               *flagp = yc->yc_flags;
+
+       return (yc->yc_chiptype);
 }
 
 static void
@@ -2906,28 +2901,23 @@
 
        if ((elem = malloc(sizeof(struct pccbb_win_chain), M_DEVBUF,
            M_NOWAIT)) == NULL)
-               return 1;               /* fail */
+               return (1);             /* fail */
 
        elem->wc_start = start;
        elem->wc_end = start + (size - 1);
        elem->wc_handle = bsh;
        elem->wc_flags = flags;
 
-       if ((chainp = TAILQ_FIRST(head)) == NULL) {
-               TAILQ_INSERT_HEAD(head, elem, wc_list);
-               return 0;
-       }
-
-       for (; chainp != NULL; chainp = TAILQ_NEXT(chainp, wc_list)) {
+       for (chainp = TAILQ_FIRST(head); chainp != NULL;
+           chainp = TAILQ_NEXT(chainp, wc_list)) {
                if (chainp->wc_end < start)
                        continue;
                TAILQ_INSERT_AFTER(head, chainp, elem, wc_list);
-               return 0;
+               return (0);
        }
 
        TAILQ_INSERT_TAIL(head, elem, wc_list);
-
-       return 0;
+       return (0);
 }
 
 static int
@@ -3113,10 +3103,9 @@
 
                /*
                 * check for card insertion or removal during suspend period.
-                * XXX: the code can't cope with card swap (remove then insert).
-                * how can we detect such situation?
+                * XXX: the code can't cope with card swap (remove then
+                * insert).  how can we detect such situation?
                 */
-               if (why == PWR_RESUME)
-                       (void)pccbbintr(sc);
+               (void)pccbbintr(sc);
        }
 }



Home | Main Index | Thread Index | Old Index