From e2840100a9f8db331ecaacca6cde0f402f177b33 Mon Sep 17 00:00:00 2001 From: thorpej Date: Fri, 7 May 2021 16:55:58 +0000 Subject: [PATCH] A small bit of const poisoning. --- 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(-) diff --git a/sys/dev/tc/ioasic_subr.c b/sys/dev/tc/ioasic_subr.c index cb4b0faf224b..1bf4e0300dc6 100644 --- a/sys/dev/tc/ioasic_subr.c +++ b/sys/dev/tc/ioasic_subr.c @@ -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 -__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 #include @@ -53,8 +53,8 @@ ioasicprint(void *aux, const char *pnp) } 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 --git a/sys/dev/tc/ioasicvar.h b/sys/dev/tc/ioasicvar.h index ae8a39b2aae9..4504a696ac37 100644 --- a/sys/dev/tc/ioasicvar.h +++ b/sys/dev/tc/ioasicvar.h @@ -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 @@ void ioasic_intr_establish(device_t, void *, 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 --git a/sys/dev/tc/tc.c b/sys/dev/tc/tc.c index c46204f1448e..355393cccb86 100644 --- a/sys/dev/tc/tc.c +++ b/sys/dev/tc/tc.c @@ -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 -__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 @@ tcattach(device_t parent, device_t self, void *aux) 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 @@ tcattach(device_t parent, device_t self, void *aux) /* * 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 @@ tcattach(device_t parent, device_t self, void *aux) 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 @@ tcattach(device_t parent, device_t self, void *aux) /* * Mark the slot as used. */ - slot->tcs_used = 1; + sc->sc_slots_used |= __BIT(i); locs[TCCF_SLOT] = i; locs[TCCF_OFFSET] = 0; diff --git a/sys/dev/tc/tcvar.h b/sys/dev/tc/tcvar.h index 323f8c93c65f..0a5d4ec58b87 100644 --- a/sys/dev/tc/tcvar.h +++ b/sys/dev/tc/tcvar.h @@ -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 @@ struct tc_softc { 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 @@ struct tcbus_attach_args { /* 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_attach_args { struct tc_slotdesc { tc_addr_t tcs_addr; void *tcs_cookie; - int tcs_used; }; /*