Staging: Add the Meilhaus ME-IDS driver package
[linux-2.6/mini2440.git] / drivers / staging / meilhaus / meslist.h
blobd26c89693d2cf7171c4e904cc25021dcd70bb1bd
1 /**
2 * @file me_slist.h
4 * @brief Provides the subdevice list class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
9 #ifndef _ME_SLIST_H_
10 #define _ME_SLIST_H_
12 #include <linux/list.h>
14 #include "mesubdevice.h"
16 #ifdef __KERNEL__
18 /**
19 * @brief The subdevice list container.
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;
26 /**
27 * @brief Queries the number of subdevices currently inside the list.
29 * @param slist The subdevice list to query.
30 * @param[out] number The number of subdevices of the device.
32 * @return ME-iDS error code.
34 int me_slist_query_number_subdevices(struct me_slist *slist, int *number);
36 /**
37 * @brief Returns the number of subdevices currently inside the list.
39 * @param slist The subdevice list to query.
41 * @return The number of subdevices in the list.
43 unsigned int me_slist_get_number_subdevices(struct me_slist *slist);
45 /**
46 * @brief Get a subdevice by index.
48 * @param slist The subdevice list to query.
49 * @param index The index of the subdevice to get in the list.
51 * @return The subdevice at index if available.\n
52 * NULL if the index is out of range.
54 me_subdevice_t *me_slist_get_subdevice(struct me_slist *slist,
55 unsigned int index);
57 /**
58 * @brief Get a subdevice index by type and subtype.
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.
66 * @return ME_ERRNO_SUCCESS on success.
68 int me_slist_get_subdevice_by_type(struct me_slist *slist,
69 unsigned int start_subdevice,
70 int type, int subtype, int *subdevice);
72 /**
73 * @brief Adds a subdevice to the tail of the list.
75 * @param slist The subdevice list to add a subdevice to.
76 * @param subdevice The subdevice to add to the list.
78 void me_slist_add_subdevice_tail(struct me_slist *slist,
79 me_subdevice_t * subdevice);
81 /**
82 * @brief Removes a subdevice from the tail of the list.
84 * @param slist The subdevice list.
86 * @return Pointer to the removed subdeivce.\n
87 * NULL in cases where the list was empty.
89 me_subdevice_t *me_slist_del_subdevice_tail(struct me_slist *slist);
91 /**
92 * @brief Initializes a subdevice list structure.
94 * @param lock The subdevice list structure to initialize.
95 * @return 0 on success.
97 int me_slist_init(me_slist_t * slist);
99 /**
100 * @brief Deinitializes a subdevice list structure and destructs every subdevice in it.
102 * @param slist The subdevice list structure to deinitialize.
103 * @return 0 on success.
105 void me_slist_deinit(me_slist_t * slist);
107 #endif
108 #endif