4 * @brief Implements the device list class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
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.
28 #include "medefines.h"
33 int me_dlist_query_number_devices(struct me_dlist
*dlist
, int *number
)
35 PDEBUG_LOCKS("called.\n");
37 return ME_ERRNO_SUCCESS
;
40 unsigned int me_dlist_get_number_devices(struct me_dlist
*dlist
)
42 PDEBUG_LOCKS("called.\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
;
53 PDEBUG_LOCKS("called.\n");
55 if (index
>= dlist
->n
) {
56 PERROR("Index out of range.\n");
60 list_for_each(pos
, &dlist
->head
) {
62 device
= list_entry(pos
, me_device_t
, list
);
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
);
80 me_device_t
*me_dlist_del_device_tail(struct me_dlist
*dlist
)
83 struct list_head
*last
;
86 PDEBUG_LOCKS("called.\n");
88 if (list_empty(&dlist
->head
))
91 last
= dlist
->head
.prev
;
93 device
= list_entry(last
, me_device_t
, list
);
102 int me_dlist_init(me_dlist_t
*dlist
)
104 PDEBUG_LOCKS("called.\n");
106 INIT_LIST_HEAD(&dlist
->head
);
111 void me_dlist_deinit(me_dlist_t
*dlist
)
117 PDEBUG_LOCKS("called.\n");
119 while (!list_empty(&dlist
->head
)) {
120 s
= dlist
->head
.next
;
122 device
= list_entry(s
, me_device_t
, list
);
123 device
->me_device_destructor(device
);