Merge branch 'dma' into devel
[linux-2.6] / drivers / staging / meilhaus / meslist.h
1 /**
2  * @file me_slist.h
3  *
4  * @brief Provides the subdevice list class.
5  * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6  * @author Guenter Gebhardt
7  */
8
9 #ifndef _ME_SLIST_H_
10 #define _ME_SLIST_H_
11
12 #include <linux/list.h>
13
14 #include "mesubdevice.h"
15
16 #ifdef __KERNEL__
17
18 /**
19  * @brief The subdevice list container.
20  */
21 typedef struct me_slist {
22         struct list_head head;          /**< The head of the internal list. */
23         unsigned int n;                 /**< The number of subdevices in the list. */
24 } me_slist_t;
25
26 /**
27  * @brief Queries the number of subdevices currently inside the list.
28  *
29  * @param slist The subdevice list to query.
30  * @param[out] number The number of subdevices of the device.
31  *
32  * @return ME-iDS error code.
33  */
34 int me_slist_query_number_subdevices(struct me_slist *slist, int *number);
35
36 /**
37  * @brief Returns the number of subdevices currently inside the list.
38  *
39  * @param slist The subdevice list to query.
40  *
41  * @return The number of subdevices in the list.
42  */
43 unsigned int me_slist_get_number_subdevices(struct me_slist *slist);
44
45 /**
46  * @brief Get a subdevice by index.
47  *
48  * @param slist The subdevice list to query.
49  * @param index The index of the subdevice to get in the list.
50  *
51  * @return The subdevice at index if available.\n
52  *         NULL if the index is out of range.
53  */
54 me_subdevice_t *me_slist_get_subdevice(struct me_slist *slist,
55                                        unsigned int index);
56
57 /**
58  * @brief Get a subdevice index by type and subtype.
59  *
60  * @param slist The subdevice list to query.
61  * @param start_subdevice The subdevice index at which the start shall begin.
62  * @param type The type of the subdevice to query.
63  * @param subtype The subtype of the subdevice to query.
64  * @param[out] subdevice On success this parameter returns the index of the subdevice matching the requested type.
65  *
66  * @return ME_ERRNO_SUCCESS on success.
67  */
68 int me_slist_get_subdevice_by_type(struct me_slist *slist,
69                                    unsigned int start_subdevice,
70                                    int type, int subtype, int *subdevice);
71
72 /**
73  * @brief Adds a subdevice to the tail of the list.
74  *
75  * @param slist The subdevice list to add a subdevice to.
76  * @param subdevice The subdevice to add to the list.
77  */
78 void me_slist_add_subdevice_tail(struct me_slist *slist,
79                                  me_subdevice_t * subdevice);
80
81 /**
82  * @brief Removes a subdevice from the tail of the list.
83  *
84  * @param slist The subdevice list.
85  *
86  * @return Pointer to the removed subdeivce.\n
87  *         NULL in cases where the list was empty.
88  */
89 me_subdevice_t *me_slist_del_subdevice_tail(struct me_slist *slist);
90
91 /**
92  * @brief Initializes a subdevice list structure.
93  *
94  * @param lock The subdevice list structure to initialize.
95  * @return 0 on success.
96  */
97 int me_slist_init(me_slist_t * slist);
98
99 /**
100  * @brief Deinitializes a subdevice list structure and destructs every subdevice in it.
101  *
102  * @param slist The subdevice list structure to deinitialize.
103  * @return 0 on success.
104  */
105 void me_slist_deinit(me_slist_t * slist);
106
107 #endif
108 #endif