Fri Nov 20 18:18:51 2020 UTC ()
malloc(9) -> kmem(9)


(thorpej)
diff -r1.23 -r1.24 src/sys/arch/arm/iomd/iomd_irqhandler.c
diff -r1.6 -r1.7 src/sys/arch/arm/iomd/iomdkbc.c

cvs diff -r1.23 -r1.24 src/sys/arch/arm/iomd/iomd_irqhandler.c (expand / switch to unified diff)

--- src/sys/arch/arm/iomd/iomd_irqhandler.c 2019/11/10 21:16:23 1.23
+++ src/sys/arch/arm/iomd/iomd_irqhandler.c 2020/11/20 18:18:51 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: iomd_irqhandler.c,v 1.23 2019/11/10 21:16:23 chs Exp $ */ 1/* $NetBSD: iomd_irqhandler.c,v 1.24 2020/11/20 18:18:51 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994-1998 Mark Brinicombe. 4 * Copyright (c) 1994-1998 Mark Brinicombe.
5 * Copyright (c) 1994 Brini. 5 * Copyright (c) 1994 Brini.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software written for Brini by Mark Brinicombe 8 * This code is derived from software written for Brini by Mark Brinicombe
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -30,34 +30,34 @@ @@ -30,34 +30,34 @@
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * 36 *
37 * IRQ/FIQ initialisation, claim, release and handler routines 37 * IRQ/FIQ initialisation, claim, release and handler routines
38 * 38 *
39 * from: irqhandler.c,v 1.14 1997/04/02 21:52:19 christos Exp $ 39 * from: irqhandler.c,v 1.14 1997/04/02 21:52:19 christos Exp $
40 */ 40 */
41 41
42#include <sys/cdefs.h> 42#include <sys/cdefs.h>
43__KERNEL_RCSID(0, "$NetBSD: iomd_irqhandler.c,v 1.23 2019/11/10 21:16:23 chs Exp $"); 43__KERNEL_RCSID(0, "$NetBSD: iomd_irqhandler.c,v 1.24 2020/11/20 18:18:51 thorpej Exp $");
44 44
45#include "opt_irqstats.h" 45#include "opt_irqstats.h"
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/systm.h> 48#include <sys/systm.h>
49#include <sys/syslog.h> 49#include <sys/syslog.h>
50#include <sys/malloc.h> 50#include <sys/kmem.h>
51 51
52#include <arm/cpufunc.h> 52#include <arm/cpufunc.h>
53#include <arm/iomd/iomdreg.h> 53#include <arm/iomd/iomdreg.h>
54#include <arm/iomd/iomdvar.h> 54#include <arm/iomd/iomdvar.h>
55 55
56#include <machine/intr.h> 56#include <machine/intr.h>
57#include <machine/cpu.h> 57#include <machine/cpu.h>
58 58
59irqhandler_t *irqhandlers[NIRQS]; 59irqhandler_t *irqhandlers[NIRQS];
60 60
61u_int current_mask; 61u_int current_mask;
62u_int actual_mask; 62u_int actual_mask;
63u_int disabled_mask; 63u_int disabled_mask;
@@ -336,48 +336,48 @@ irq_release(int irq, irqhandler_t *handl @@ -336,48 +336,48 @@ irq_release(int irq, irqhandler_t *handl
336 336
337 set_spl_masks(); 337 set_spl_masks();
338  338
339 return 0; 339 return 0;
340} 340}
341 341
342 342
343void * 343void *
344intr_claim(int irq, int level, const char *name, int (*ih_func)(void *), 344intr_claim(int irq, int level, const char *name, int (*ih_func)(void *),
345 void *ih_arg) 345 void *ih_arg)
346{ 346{
347 irqhandler_t *ih; 347 irqhandler_t *ih;
348 348
349 ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK); 349 ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
350 ih->ih_level = level; 350 ih->ih_level = level;
351 ih->ih_name = name; 351 ih->ih_name = name;
352 ih->ih_func = ih_func; 352 ih->ih_func = ih_func;
353 ih->ih_arg = ih_arg; 353 ih->ih_arg = ih_arg;
354 ih->ih_flags = 0; 354 ih->ih_flags = 0;
355 355
356 if (irq_claim(irq, ih) != 0) { 356 if (irq_claim(irq, ih) != 0) {
357 free(ih, M_DEVBUF); 357 kmem_free(ih, sizeof(*ih));
358 return NULL; 358 return NULL;
359 } 359 }
360 return ih; 360 return ih;
361} 361}
362 362
363 363
364int 364int
365intr_release(void *arg) 365intr_release(void *arg)
366{ 366{
367 irqhandler_t *ih = (irqhandler_t *)arg; 367 irqhandler_t *ih = (irqhandler_t *)arg;
368 368
369 if (irq_release(ih->ih_num, ih) == 0) { 369 if (irq_release(ih->ih_num, ih) == 0) {
370 free(ih, M_DEVBUF); 370 kmem_free(ih, sizeof(*ih));
371 return 0 ; 371 return 0 ;
372 } 372 }
373 return 1; 373 return 1;
374} 374}
375 375
376#if 0 376#if 0
377u_int 377u_int
378disable_interrupts(u_int mask) 378disable_interrupts(u_int mask)
379{ 379{
380 u_int cpsr; 380 u_int cpsr;
381 381
382 cpsr = SetCPSR(mask, mask); 382 cpsr = SetCPSR(mask, mask);
383 return cpsr; 383 return cpsr;

cvs diff -r1.6 -r1.7 src/sys/arch/arm/iomd/iomdkbc.c (expand / switch to unified diff)

--- src/sys/arch/arm/iomd/iomdkbc.c 2019/11/10 21:16:23 1.6
+++ src/sys/arch/arm/iomd/iomdkbc.c 2020/11/20 18:18:51 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: iomdkbc.c,v 1.6 2019/11/10 21:16:23 chs Exp $ */ 1/* $NetBSD: iomdkbc.c,v 1.7 2020/11/20 18:18:51 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2004 Ben Harris 4 * Copyright (c) 2004 Ben Harris
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -18,31 +18,31 @@ @@ -18,31 +18,31 @@
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: iomdkbc.c,v 1.6 2019/11/10 21:16:23 chs Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: iomdkbc.c,v 1.7 2020/11/20 18:18:51 thorpej Exp $");
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/device.h> 34#include <sys/device.h>
35#include <sys/malloc.h> 35#include <sys/kmem.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37 37
38#include <dev/pckbport/pckbportvar.h> 38#include <dev/pckbport/pckbportvar.h>
39 39
40#include <sys/bus.h> 40#include <sys/bus.h>
41#include <machine/intr.h> 41#include <machine/intr.h>
42 42
43#include <arch/arm/iomd/iomdreg.h> 43#include <arch/arm/iomd/iomdreg.h>
44#include <arch/arm/iomd/iomdvar.h> 44#include <arch/arm/iomd/iomdvar.h>
45#include <arch/arm/iomd/iomdkbcvar.h> 45#include <arch/arm/iomd/iomdkbcvar.h>
46 46
47/* XXX belongs in iomdreg.h */ 47/* XXX belongs in iomdreg.h */
48#define IOMDKBC_TXE 0x80 48#define IOMDKBC_TXE 0x80
@@ -123,46 +123,46 @@ iomdkbc_attach(device_t parent, device_t @@ -123,46 +123,46 @@ iomdkbc_attach(device_t parent, device_t
123 struct iomdkbc_softc *sc = device_private(self); 123 struct iomdkbc_softc *sc = device_private(self);
124 struct iomdkbc_internal *t; 124 struct iomdkbc_internal *t;
125 125
126 sc->sc_dev = self; 126 sc->sc_dev = self;
127 aprint_normal("\n"); 127 aprint_normal("\n");
128 128
129 t = NULL; 129 t = NULL;
130 if (strcmp(ka->ka_name, "kbd") == 0) { 130 if (strcmp(ka->ka_name, "kbd") == 0) {
131 /* XXX not really right, but good enough. */ 131 /* XXX not really right, but good enough. */
132 if (iomdkbc_cntag.t_haveport[PCKBPORT_KBD_SLOT]) { 132 if (iomdkbc_cntag.t_haveport[PCKBPORT_KBD_SLOT]) {
133 /* Have an iomdkbc as console. Assume it's this one.*/ 133 /* Have an iomdkbc as console. Assume it's this one.*/
134 t = &iomdkbc_cntag; 134 t = &iomdkbc_cntag;
135 } else { 135 } else {
136 t = malloc(sizeof(struct iomdkbc_internal), M_DEVBUF, 136 t = kmem_zalloc(sizeof(struct iomdkbc_internal),
137 M_WAITOK | M_ZERO); 137 KM_SLEEP);
138 t->t_haveport[PCKBPORT_KBD_SLOT] = 1; 138 t->t_haveport[PCKBPORT_KBD_SLOT] = 1;
139 t->t_iot = ka->ka_iot; 139 t->t_iot = ka->ka_iot;
140 t->t_ioh[PCKBPORT_KBD_SLOT] = ka->ka_ioh; 140 t->t_ioh[PCKBPORT_KBD_SLOT] = ka->ka_ioh;
141 } 141 }
142 t->t_rxih[PCKBPORT_KBD_SLOT] = intr_claim(ka->ka_rxirq, 142 t->t_rxih[PCKBPORT_KBD_SLOT] = intr_claim(ka->ka_rxirq,
143 IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t); 143 IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t);
144 t->t_rxirq[PCKBPORT_KBD_SLOT] = ka->ka_rxirq; 144 t->t_rxirq[PCKBPORT_KBD_SLOT] = ka->ka_rxirq;
145 disable_irq(t->t_rxirq[PCKBPORT_KBD_SLOT]); 145 disable_irq(t->t_rxirq[PCKBPORT_KBD_SLOT]);
146 sc->sc_id = t; 146 sc->sc_id = t;
147 t->t_sc = sc; 147 t->t_sc = sc;
148 t->t_pt = pckbport_attach(t, &iomdkbc_ops); 148 t->t_pt = pckbport_attach(t, &iomdkbc_ops);
149 pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_KBD_SLOT); 149 pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_KBD_SLOT);
150 } 150 }
151 151
152 if (strcmp(pa->pa_name, "opms") == 0) { 152 if (strcmp(pa->pa_name, "opms") == 0) {
153 if (t == NULL) { 153 if (t == NULL) {
154 t = malloc(sizeof(struct iomdkbc_internal), M_DEVBUF, 154 t = kmem_zalloc(sizeof(struct iomdkbc_internal),
155 M_WAITOK | M_ZERO); 155 KM_SLEEP);
156 } 156 }
157 t->t_haveport[PCKBPORT_AUX_SLOT] = 1; 157 t->t_haveport[PCKBPORT_AUX_SLOT] = 1;
158 t->t_iot = pa->pa_iot; 158 t->t_iot = pa->pa_iot;
159 t->t_ioh[PCKBPORT_AUX_SLOT] = pa->pa_ioh; 159 t->t_ioh[PCKBPORT_AUX_SLOT] = pa->pa_ioh;
160 t->t_rxih[PCKBPORT_AUX_SLOT] = intr_claim(pa->pa_irq, 160 t->t_rxih[PCKBPORT_AUX_SLOT] = intr_claim(pa->pa_irq,
161 IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t); 161 IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t);
162 t->t_rxirq[PCKBPORT_AUX_SLOT] = pa->pa_irq; 162 t->t_rxirq[PCKBPORT_AUX_SLOT] = pa->pa_irq;
163 disable_irq(t->t_rxirq[PCKBPORT_AUX_SLOT]); 163 disable_irq(t->t_rxirq[PCKBPORT_AUX_SLOT]);
164 sc->sc_id = t; 164 sc->sc_id = t;
165 t->t_sc = sc; 165 t->t_sc = sc;
166 if (t->t_pt == NULL) 166 if (t->t_pt == NULL)
167 t->t_pt = pckbport_attach(t, &iomdkbc_ops); 167 t->t_pt = pckbport_attach(t, &iomdkbc_ops);
168 pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_AUX_SLOT); 168 pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_AUX_SLOT);