diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-11-25 11:23:31 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-11-25 11:23:31 +0000 |
commit | 408427207106242072529d2ef747a148d7c4485c (patch) | |
tree | f5b3ec29245de0ac8e694da05165d91437357844 /sys/arch/sgi | |
parent | d7d279d64813668641d86a1ad7354fb1b16640ee (diff) |
Allow xbow_intr_establish() callers to provide optional storage for the
struct intrhand, instead of having it malloc()'ed.
Diffstat (limited to 'sys/arch/sgi')
-rw-r--r-- | sys/arch/sgi/dev/power.c | 4 | ||||
-rw-r--r-- | sys/arch/sgi/include/intr.h | 4 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/ip27_machdep.c | 21 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/xbow.c | 8 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/xbow.h | 7 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/xbridge.c | 4 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/xheart.c | 22 |
7 files changed, 44 insertions, 26 deletions
diff --git a/sys/arch/sgi/dev/power.c b/sys/arch/sgi/dev/power.c index 9468e9208d0..3696db748f5 100644 --- a/sys/arch/sgi/dev/power.c +++ b/sys/arch/sgi/dev/power.c @@ -1,4 +1,4 @@ -/* $OpenBSD: power.c,v 1.12 2009/10/26 20:14:42 miod Exp $ */ +/* $OpenBSD: power.c,v 1.13 2009/11/25 11:23:29 miod Exp $ */ /* * Copyright (c) 2007 Jasper Lievisse Adriaanse <jasper@openbsd.org> @@ -101,7 +101,7 @@ power_mainbus_attach(struct device *parent, struct device *self, void *aux) { /* Establish interrupt handler. */ if (xbow_intr_establish(power_mainbus_intr, self, HEART_ISR_POWER, - IPL_TTY, self->dv_xname) != 0) { + IPL_TTY, self->dv_xname, NULL) != 0) { printf(": unable to establish interrupt!\n"); return; } diff --git a/sys/arch/sgi/include/intr.h b/sys/arch/sgi/include/intr.h index d571bc1998c..5532cb13d8f 100644 --- a/sys/arch/sgi/include/intr.h +++ b/sys/arch/sgi/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.35 2009/10/26 20:14:14 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.36 2009/11/25 11:23:30 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -162,6 +162,8 @@ struct intrhand { int ih_level; int ih_irq; struct evcount ih_count; + int ih_flags; +#define IH_ALLOCATED 0x01 }; /* diff --git a/sys/arch/sgi/sgi/ip27_machdep.c b/sys/arch/sgi/sgi/ip27_machdep.c index a3edf183c38..85bb7a77ce7 100644 --- a/sys/arch/sgi/sgi/ip27_machdep.c +++ b/sys/arch/sgi/sgi/ip27_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip27_machdep.c,v 1.36 2009/11/18 19:05:51 miod Exp $ */ +/* $OpenBSD: ip27_machdep.c,v 1.37 2009/11/25 11:23:30 miod Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -67,7 +67,7 @@ static uint maxnodes; int ip27_hub_intr_register(int, int, int *); int ip27_hub_intr_establish(int (*)(void *), void *, int, int, - const char *); + const char *, struct intrhand *); void ip27_hub_intr_disestablish(int); void ip27_hub_intr_clear(int); void ip27_hub_intr_set(int); @@ -625,7 +625,7 @@ found: */ int ip27_hub_intr_establish(int (*func)(void *), void *arg, int intrbit, - int level, const char *name) + int level, const char *name, struct intrhand *ihstore) { struct intrhand *ih, **anchor; int s; @@ -650,9 +650,15 @@ ip27_hub_intr_establish(int (*func)(void *), void *arg, int intrbit, if (*anchor != NULL) return EEXIST; - ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT); - if (ih == NULL) - return ENOMEM; + if (ihstore == NULL) { + ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT); + if (ih == NULL) + return ENOMEM; + ih->ih_flags = IH_ALLOCATED; + } else { + ih = ihstore; + ih->ih_flags = 0; + } ih->ih_next = NULL; ih->ih_fun = func; @@ -712,7 +718,8 @@ ip27_hub_intr_disestablish(int intrbit) splx(s); - free(ih, M_DEVBUF); + if (ISSET(ih->ih_flags, IH_ALLOCATED)) + free(ih, M_DEVBUF); } void diff --git a/sys/arch/sgi/xbow/xbow.c b/sys/arch/sgi/xbow/xbow.c index 9be999d45be..43c5adc0f96 100644 --- a/sys/arch/sgi/xbow/xbow.c +++ b/sys/arch/sgi/xbow/xbow.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xbow.c,v 1.25 2009/11/18 19:05:53 miod Exp $ */ +/* $OpenBSD: xbow.c,v 1.26 2009/11/25 11:23:30 miod Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -665,7 +665,7 @@ int xbow_intr_widget = 0; paddr_t xbow_intr_widget_register; int (*xbow_intr_widget_intr_register)(int, int, int *) = NULL; int (*xbow_intr_widget_intr_establish)(int (*)(void *), void *, int, int, - const char *) = NULL; + const char *, struct intrhand *) = NULL; void (*xbow_intr_widget_intr_disestablish)(int) = NULL; void (*xbow_intr_widget_intr_set)(int) = NULL; void (*xbow_intr_widget_intr_clear)(int) = NULL; @@ -681,13 +681,13 @@ xbow_intr_register(int widget, int level, int *intrbit) int xbow_intr_establish(int (*func)(void *), void *arg, int intrbit, int level, - const char *name) + const char *name, struct intrhand *ihstore) { if (xbow_intr_widget_intr_establish == NULL) return EINVAL; return (*xbow_intr_widget_intr_establish)(func, arg, intrbit, level, - name); + name, ihstore); } void diff --git a/sys/arch/sgi/xbow/xbow.h b/sys/arch/sgi/xbow/xbow.h index 579cf7a6770..7775aba34ed 100644 --- a/sys/arch/sgi/xbow/xbow.h +++ b/sys/arch/sgi/xbow/xbow.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xbow.h,v 1.9 2009/11/18 19:05:53 miod Exp $ */ +/* $OpenBSD: xbow.h,v 1.10 2009/11/25 11:23:30 miod Exp $ */ /* * Copyright (c) 2008 Miodrag Vallat. @@ -50,7 +50,7 @@ extern paddr_t xbow_intr_widget_register; extern int (*xbow_intr_widget_intr_register)(int, int, int *); extern int (*xbow_intr_widget_intr_establish)(int (*)(void *), void *, - int, int, const char *); + int, int, const char *, struct intrhand *); extern void (*xbow_intr_widget_intr_disestablish)(int); extern void (*xbow_intr_widget_intr_set)(int); @@ -80,7 +80,8 @@ struct xbow_attach_args { void xbow_build_bus_space(struct mips_bus_space *, int, int); int xbow_intr_register(int, int, int *); -int xbow_intr_establish(int (*)(void *), void *, int, int, const char *); +int xbow_intr_establish(int (*)(void *), void *, int, int, const char *, + struct intrhand *); void xbow_intr_disestablish(int); void xbow_intr_clear(int); void xbow_intr_set(int); diff --git a/sys/arch/sgi/xbow/xbridge.c b/sys/arch/sgi/xbow/xbridge.c index deada09cff4..da82dc060aa 100644 --- a/sys/arch/sgi/xbow/xbridge.c +++ b/sys/arch/sgi/xbow/xbridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xbridge.c,v 1.63 2009/11/19 06:07:05 miod Exp $ */ +/* $OpenBSD: xbridge.c,v 1.64 2009/11/25 11:23:30 miod Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -984,7 +984,7 @@ xbridge_intr_establish(void *cookie, pci_intr_handle_t ih, int level, * XXX between devices of different levels. */ if (xbow_intr_establish(xbridge_intr_handler, xi, intrsrc, - IPL_BIO, NULL)) { + IPL_BIO, NULL, NULL)) { printf("%s: unable to register interrupt handler\n", DEVNAME(xb)); return NULL; diff --git a/sys/arch/sgi/xbow/xheart.c b/sys/arch/sgi/xbow/xheart.c index 100a2211df6..547456d716b 100644 --- a/sys/arch/sgi/xbow/xheart.c +++ b/sys/arch/sgi/xbow/xheart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xheart.c,v 1.16 2009/11/12 17:13:35 miod Exp $ */ +/* $OpenBSD: xheart.c,v 1.17 2009/11/25 11:23:30 miod Exp $ */ /* * Copyright (c) 2008 Miodrag Vallat. @@ -64,7 +64,8 @@ int xheart_ow_triplet(void *, int); int xheart_ow_pulse(struct xheart_softc *, int, int); int xheart_intr_register(int, int, int *); -int xheart_intr_establish(int (*)(void *), void *, int, int, const char *); +int xheart_intr_establish(int (*)(void *), void *, int, int, const char *, + struct intrhand *); void xheart_intr_disestablish(int); void xheart_intr_clear(int); void xheart_intr_set(int); @@ -291,7 +292,7 @@ found: */ int xheart_intr_establish(int (*func)(void *), void *arg, int intrbit, - int level, const char *name) + int level, const char *name, struct intrhand *ihstore) { struct intrhand *ih; int s; @@ -308,9 +309,15 @@ xheart_intr_establish(int (*func)(void *), void *arg, int intrbit, if (xheart_intrhand[intrbit] != NULL) return EEXIST; - ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT); - if (ih == NULL) - return ENOMEM; + if (ihstore == NULL) { + ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT); + if (ih == NULL) + return ENOMEM; + ih->ih_flags = IH_ALLOCATED; + } else { + ih = ihstore; + ih->ih_flags = 0; + } ih->ih_next = NULL; ih->ih_fun = func; @@ -358,7 +365,8 @@ xheart_intr_disestablish(int intrbit) splx(s); - free(ih, M_DEVBUF); + if (ISSET(ih->ih_flags, IH_ALLOCATED)) + free(ih, M_DEVBUF); } void |