Module Name:    src
Committed By:   thorpej
Date:           Fri May  7 16:55:58 UTC 2021

Modified Files:
        src/sys/dev/tc: ioasic_subr.c ioasicvar.h tc.c tcvar.h

Log Message:
A small bit of const poisoning.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/tc/ioasic_subr.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/tc/ioasicvar.h
cvs rdiff -u -r1.57 -r1.58 src/sys/dev/tc/tc.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/tc/tcvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/tc/ioasic_subr.c
diff -u src/sys/dev/tc/ioasic_subr.c:1.14 src/sys/dev/tc/ioasic_subr.c:1.15
--- src/sys/dev/tc/ioasic_subr.c:1.14	Sat Apr 24 23:36:59 2021
+++ src/sys/dev/tc/ioasic_subr.c	Fri May  7 16:55:58 2021
@@ -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 @@ 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;

Index: src/sys/dev/tc/ioasicvar.h
diff -u src/sys/dev/tc/ioasicvar.h:1.22 src/sys/dev/tc/ioasicvar.h:1.23
--- src/sys/dev/tc/ioasicvar.h:1.22	Sat Jun  4 01:49:44 2011
+++ src/sys/dev/tc/ioasicvar.h	Fri May  7 16:55:58 2021
@@ -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, 
 	    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_ */

Index: src/sys/dev/tc/tc.c
diff -u src/sys/dev/tc/tc.c:1.57 src/sys/dev/tc/tc.c:1.58
--- src/sys/dev/tc/tc.c:1.57	Sat Apr 24 23:36:59 2021
+++ src/sys/dev/tc/tc.c	Fri May  7 16:55:58 2021
@@ -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 @@ tcattach(device_t parent, device_t self,
 	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,
 		/*
 		 * 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,
 		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,
 		/*
 		 * Mark the slot as used.
 		 */
-		slot->tcs_used = 1;
+		sc->sc_slots_used |= __BIT(i);
 
 		locs[TCCF_SLOT] = i;
 		locs[TCCF_OFFSET] = 0;

Index: src/sys/dev/tc/tcvar.h
diff -u src/sys/dev/tc/tcvar.h:1.27 src/sys/dev/tc/tcvar.h:1.28
--- src/sys/dev/tc/tcvar.h:1.27	Fri Jun  9 17:55:18 2017
+++ src/sys/dev/tc/tcvar.h	Fri May  7 16:55:58 2021
@@ -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;
 };
 
 /*

Reply via email to