Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/tc A small bit of const poisoning.



details:   https://anonhg.NetBSD.org/src/rev/e208757baea8
branches:  trunk
changeset: 1021087:e208757baea8
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri May 07 16:55:58 2021 +0000

description:
A small bit of const poisoning.

diffstat:

 sys/dev/tc/ioasic_subr.c |   8 ++++----
 sys/dev/tc/ioasicvar.h   |   4 ++--
 sys/dev/tc/tc.c          |  13 +++++++------
 sys/dev/tc/tcvar.h       |   8 ++++----
 4 files changed, 17 insertions(+), 16 deletions(-)

diffs (137 lines):

diff -r 000b7a1684a6 -r e208757baea8 sys/dev/tc/ioasic_subr.c
--- a/sys/dev/tc/ioasic_subr.c  Fri May 07 16:29:24 2021 +0000
+++ b/sys/dev/tc/ioasic_subr.c  Fri May 07 16:55:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ioasic_subr.c,v 1.14 2021/04/24 23:36:59 thorpej Exp $ */
+/*     $NetBSD: ioasic_subr.c,v 1.15 2021/05/07 16:55:58 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ioasic_subr.c,v 1.14 2021/04/24 23:36:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ioasic_subr.c,v 1.15 2021/05/07 16:55:58 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,8 +53,8 @@
 }
 
 void
-ioasic_attach_devs(struct ioasic_softc *sc, struct ioasic_dev *ioasic_devs,
-    int ioasic_ndevs)
+ioasic_attach_devs(struct ioasic_softc *sc,
+    const struct ioasic_dev *ioasic_devs, int ioasic_ndevs)
 {
        struct ioasicdev_attach_args idev;
        int i;
diff -r 000b7a1684a6 -r e208757baea8 sys/dev/tc/ioasicvar.h
--- a/sys/dev/tc/ioasicvar.h    Fri May 07 16:29:24 2021 +0000
+++ b/sys/dev/tc/ioasicvar.h    Fri May 07 16:55:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ioasicvar.h,v 1.22 2011/06/04 01:49:44 tsutsui Exp $   */
+/*     $NetBSD: ioasicvar.h,v 1.23 2021/05/07 16:55:58 thorpej Exp $   */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -67,6 +67,6 @@
            int, int (*)(void *), void *);
 void    ioasic_intr_disestablish(device_t, void *);
 void   ioasic_attach_devs(struct ioasic_softc *,
-           struct ioasic_dev *, int);
+           const struct ioasic_dev *, int);
 
 #endif /* _DEV_TC_IOASICVAR_ */
diff -r 000b7a1684a6 -r e208757baea8 sys/dev/tc/tc.c
--- a/sys/dev/tc/tc.c   Fri May 07 16:29:24 2021 +0000
+++ b/sys/dev/tc/tc.c   Fri May 07 16:55:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tc.c,v 1.57 2021/04/24 23:36:59 thorpej Exp $  */
+/*     $NetBSD: tc.c,v 1.58 2021/05/07 16:55:58 thorpej Exp $  */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tc.c,v 1.57 2021/04/24 23:36:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tc.c,v 1.58 2021/05/07 16:55:58 thorpej Exp $");
 
 #include "opt_tcverbose.h"
 
@@ -73,7 +73,7 @@
        struct tcbus_attach_args *tba = aux;
        struct tc_attach_args ta;
        const struct tc_builtin *builtin;
-       struct tc_slotdesc *slot;
+       const struct tc_slotdesc *slot;
        tc_addr_t tcaddr;
        int i;
        int locs[TCCF_NLOCS];
@@ -129,7 +129,8 @@
                /*
                 * Mark the slot as used, so we don't check it later.
                 */
-               sc->sc_slots[builtin->tcb_slot].tcs_used = 1;
+               KASSERT(builtin->tcb_slot >=0 && builtin->tcb_slot <= 31);
+               sc->sc_slots_used |= __BIT(builtin->tcb_slot);
 
                locs[TCCF_SLOT] = builtin->tcb_slot;
                locs[TCCF_OFFSET] = builtin->tcb_offset;
@@ -149,7 +150,7 @@
                slot = &sc->sc_slots[i];
 
                /* If already checked above, don't look again now. */
-               if (slot->tcs_used)
+               if (sc->sc_slots_used & __BIT(i))
                        continue;
 
                /*
@@ -175,7 +176,7 @@
                /*
                 * Mark the slot as used.
                 */
-               slot->tcs_used = 1;
+               sc->sc_slots_used |= __BIT(i);
 
                locs[TCCF_SLOT] = i;
                locs[TCCF_OFFSET] = 0;
diff -r 000b7a1684a6 -r e208757baea8 sys/dev/tc/tcvar.h
--- a/sys/dev/tc/tcvar.h        Fri May 07 16:29:24 2021 +0000
+++ b/sys/dev/tc/tcvar.h        Fri May 07 16:55:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcvar.h,v 1.27 2017/06/09 17:55:18 flxd Exp $ */
+/* $NetBSD: tcvar.h,v 1.28 2021/05/07 16:55:58 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -68,7 +68,8 @@
 
        int     sc_speed;
        int     sc_nslots;
-       struct tc_slotdesc *sc_slots;
+       const struct tc_slotdesc *sc_slots;
+       uint32_t sc_slots_used;
 
        const struct evcnt *(*sc_intr_evcnt)(device_t, void *);
        void    (*sc_intr_establish)(device_t, void *,
@@ -87,7 +88,7 @@
        /* Bus information */
        u_int           tba_speed;              /* see TC_SPEED_* below */
        u_int           tba_nslots;
-       struct tc_slotdesc *tba_slots;
+       const struct tc_slotdesc *tba_slots;
        u_int           tba_nbuiltins;
        const struct tc_builtin *tba_builtins;
 
@@ -122,7 +123,6 @@
 struct tc_slotdesc {
        tc_addr_t       tcs_addr;
        void            *tcs_cookie;
-       int             tcs_used;
 };
 
 /*



Home | Main Index | Thread Index | Old Index