1 /* $NetBSD: rf_shutdown.c,v 1.19 2005/12/11 12:23:37 christos Exp $ */
6 * Copyright (c) 1996 Carnegie-Mellon University.
11 * Permission to use, copy, modify and distribute this software and
12 * its documentation is hereby granted, provided that both the copyright
13 * notice and this permission notice appear in all copies of the
14 * software, derivative works or modified versions, and any portions
15 * thereof, and that both notices appear in supporting documentation.
17 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
18 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
19 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21 * Carnegie Mellon requests users of this software to return to
23 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
24 * School of Computer Science
25 * Carnegie Mellon University
26 * Pittsburgh PA 15213-3890
28 * any improvements or extensions that they make and grant Carnegie the
29 * rights to redistribute these changes.
32 * Maintain lists of cleanup functions. Also, mechanisms for coordinating
33 * thread startup and shutdown.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: rf_shutdown.c,v 1.19 2005/12/11 12:23:37 christos Exp $");
39 #include <dev/raidframe/raidframevar.h>
42 #include "rf_shutdown.h"
43 #include "rf_debugMem.h"
46 #ifndef RF_DEBUG_SHUTDOWN
47 #define RF_DEBUG_SHUTDOWN 0
50 static void rf_FreeShutdownEnt(RF_ShutdownList_t
*);
53 rf_FreeShutdownEnt(RF_ShutdownList_t
*ent
)
55 free(ent
, M_RAIDFRAME
);
60 _rf_ShutdownCreate(RF_ShutdownList_t
**listp
, void (*cleanup
)(void *arg
),
61 void *arg
, char *file
, int line
)
64 _rf_ShutdownCreate(RF_ShutdownList_t
**listp
, void (*cleanup
)(void *arg
),
68 RF_ShutdownList_t
*ent
;
71 * Have to directly allocate memory here, since we start up before
72 * and shutdown after RAIDframe internal allocation system.
74 /* ent = (RF_ShutdownList_t *) malloc(sizeof(RF_ShutdownList_t),
75 M_RAIDFRAME, M_WAITOK); */
76 ent
= (RF_ShutdownList_t
*) malloc(sizeof(RF_ShutdownList_t
),
77 M_RAIDFRAME
, M_WAITOK
);
78 ent
->cleanup
= cleanup
;
89 rf_ShutdownList(RF_ShutdownList_t
**list
)
91 RF_ShutdownList_t
*r
, *next
;
97 for (r
= *list
; r
; r
= next
) {
103 if (rf_shutdownDebug
) {
104 printf("call shutdown, created %s:%d\n", file
, line
);
108 #if RF_DEBUG_SHUTDOWN
109 if (rf_shutdownDebug
) {
110 printf("completed shutdown, created %s:%d\n", file
, line
);
113 rf_FreeShutdownEnt(r
);