x86, mce: use a call vector to call the 64bit mce handler
[linux-2.6/mini2440.git] / drivers / staging / meilhaus / medlist.c
blobb6a4065d2da1d6d1316c0d8368444c0ee7ec8aba
1 /**
2 * @file me_dlist.c
4 * @brief Implements the device list class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
9 /*
10 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
12 * This file is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "meerror.h"
28 #include "medefines.h"
30 #include "medlist.h"
31 #include "medebug.h"
33 int me_dlist_query_number_devices(struct me_dlist *dlist, int *number)
35 PDEBUG_LOCKS("called.\n");
36 *number = dlist->n;
37 return ME_ERRNO_SUCCESS;
40 unsigned int me_dlist_get_number_devices(struct me_dlist *dlist)
42 PDEBUG_LOCKS("called.\n");
43 return dlist->n;
46 me_device_t *me_dlist_get_device(struct me_dlist * dlist, unsigned int index)
49 struct list_head *pos;
50 me_device_t *device = NULL;
51 unsigned int i = 0;
53 PDEBUG_LOCKS("called.\n");
55 if (index >= dlist->n) {
56 PERROR("Index out of range.\n");
57 return NULL;
60 list_for_each(pos, &dlist->head) {
61 if (i == index) {
62 device = list_entry(pos, me_device_t, list);
63 break;
66 ++i;
69 return device;
72 void me_dlist_add_device_tail(struct me_dlist *dlist, me_device_t *device)
74 PDEBUG_LOCKS("called.\n");
76 list_add_tail(&device->list, &dlist->head);
77 ++dlist->n;
80 me_device_t *me_dlist_del_device_tail(struct me_dlist *dlist)
83 struct list_head *last;
84 me_device_t *device;
86 PDEBUG_LOCKS("called.\n");
88 if (list_empty(&dlist->head))
89 return NULL;
91 last = dlist->head.prev;
93 device = list_entry(last, me_device_t, list);
95 list_del(last);
97 --dlist->n;
99 return device;
102 int me_dlist_init(me_dlist_t *dlist)
104 PDEBUG_LOCKS("called.\n");
106 INIT_LIST_HEAD(&dlist->head);
107 dlist->n = 0;
108 return 0;
111 void me_dlist_deinit(me_dlist_t *dlist)
114 struct list_head *s;
115 me_device_t *device;
117 PDEBUG_LOCKS("called.\n");
119 while (!list_empty(&dlist->head)) {
120 s = dlist->head.next;
121 list_del(s);
122 device = list_entry(s, me_device_t, list);
123 device->me_device_destructor(device);
126 dlist->n = 0;