2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
9 #include <linux/config.h>
10 #include <linux/types.h>
11 #include <linux/slab.h>
12 #include <asm/sn/sgi.h>
13 #include <asm/sn/io.h>
14 #include <asm/sn/iograph.h>
15 #include <asm/sn/sn_private.h>
16 #include <asm/sn/invent.h>
17 #include <asm/sn/hcl.h>
18 #include <asm/sn/labelcl.h>
20 struct hubdev_callout {
21 int (*attach_method)(vertex_hdl_t);
22 struct hubdev_callout *fp;
25 typedef struct hubdev_callout hubdev_callout_t;
27 mutex_t hubdev_callout_mutex;
28 static hubdev_callout_t *hubdev_callout_list;
33 mutex_init(&hubdev_callout_mutex);
34 hubdev_callout_list = NULL;
38 hubdev_register(int (*attach_method)(vertex_hdl_t))
40 hubdev_callout_t *callout;
42 ASSERT(attach_method);
44 callout = (hubdev_callout_t *)snia_kmem_zalloc(sizeof(hubdev_callout_t), KM_SLEEP);
47 mutex_lock(&hubdev_callout_mutex);
49 * Insert at the end of the list
51 callout->fp = hubdev_callout_list;
52 hubdev_callout_list = callout;
53 callout->attach_method = attach_method;
54 mutex_unlock(&hubdev_callout_mutex);
58 hubdev_unregister(int (*attach_method)(vertex_hdl_t))
62 ASSERT(attach_method);
64 mutex_lock(&hubdev_callout_mutex);
66 * Remove registry element containing attach_method
68 for (p = &hubdev_callout_list; *p != NULL; p = &(*p)->fp) {
69 if ((*p)->attach_method == attach_method) {
70 hubdev_callout_t* victim = *p;
73 mutex_unlock(&hubdev_callout_mutex);
77 mutex_unlock(&hubdev_callout_mutex);
83 hubdev_docallouts(vertex_hdl_t hub)
88 mutex_lock(&hubdev_callout_mutex);
90 for (p = hubdev_callout_list; p != NULL; p = p->fp) {
91 ASSERT(p->attach_method);
92 errcode = (*p->attach_method)(hub);
94 mutex_unlock(&hubdev_callout_mutex);
98 mutex_unlock(&hubdev_callout_mutex);