diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-07-16 21:50:59 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-07-16 21:50:59 +0000 |
commit | ef7e3122b69b9fabf373452523dfdfcb49cd9f72 (patch) | |
tree | 33317504bb81c4fded51a4a251de68bb012c1ccf /sys/dev/ic/ibm561.c | |
parent | 4323463cc9ee7772047d6fe389dbe4113061d09d (diff) |
Use a global variable for the console ibm561 state, and use it when the
real device attach, instead of using malloc (we can not use malloc at
console initialization time).
This gets rid of the following stack offense:
/usr/src/sys/dev/ic/ibm561.c: In function `ibm561_cninit':
/usr/src/sys/dev/ic/ibm561.c:193: warning: stack usage is 4768 bytes
Diffstat (limited to 'sys/dev/ic/ibm561.c')
-rw-r--r-- | sys/dev/ic/ibm561.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/dev/ic/ibm561.c b/sys/dev/ic/ibm561.c index 4b27812b80c..f8892d4bd55 100644 --- a/sys/dev/ic/ibm561.c +++ b/sys/dev/ic/ibm561.c @@ -1,5 +1,5 @@ /* $NetBSD: ibm561.c,v 1.1 2001/12/12 07:46:48 elric Exp $ */ -/* $OpenBSD: ibm561.c,v 1.3 2002/11/09 22:51:48 miod Exp $ */ +/* $OpenBSD: ibm561.c,v 1.4 2006/07/16 21:50:58 miod Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -147,6 +147,8 @@ ibm561_funcs(void) return &ibm561_funcsstruct; } +struct ibm561data ibm561_console_data; + struct ramdac_cookie * ibm561_register(v, sched_update, wr, rd) void *v; @@ -156,7 +158,11 @@ ibm561_register(v, sched_update, wr, rd) { struct ibm561data *data; - data = malloc(sizeof *data, M_DEVBUF, M_WAITOK); // XXX |M_ZERO); + if (ibm561_console_data.cookie == NULL) { + data = malloc(sizeof *data, M_DEVBUF, M_WAITOK); + bzero(data, sizeof *data); + } else + data = &ibm561_console_data; data->cookie = v; data->ramdac_sched_update = sched_update; data->ramdac_wr = wr; @@ -170,8 +176,6 @@ ibm561_register(v, sched_update, wr, rd) * initializing the console early on. */ -struct ibm561data *saved_console_data; - void ibm561_cninit(v, sched_update, wr, rd, dotclock) void *v; @@ -180,16 +184,13 @@ ibm561_cninit(v, sched_update, wr, rd, dotclock) u_int8_t (*rd)(void *, u_int); u_int dotclock; { - struct ibm561data tmp, *data = &tmp; - memset(data, 0x0, sizeof *data); + struct ibm561data *data = &ibm561_console_data; data->cookie = v; data->ramdac_sched_update = sched_update; data->ramdac_wr = wr; data->ramdac_rd = rd; ibm561_set_dotclock((struct ramdac_cookie *)data, dotclock); - saved_console_data = data; ibm561_init((struct ramdac_cookie *)data); - saved_console_data = NULL; } void @@ -426,7 +427,7 @@ ibm561_update(vp) /* XXX see comment above ibm561_cninit() */ if (!data) - data = saved_console_data; + data = &ibm561_console_data; if (data->changed & CHANGED_WTYPE) { ibm561_regbegin(data, IBM561_FB_WINTYPE); |