upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / usb / host / s3c-otg / s3c-otg-hcdi-list.h
1 /****************************************************************************
2  *  (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
3  *
4  * @file   s3c-otg-hcdi-list.h
5  * @brief  list functions for otg \n
6  * @version
7  *  -# Jun 9,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
8  *        : Creating the initial version of this code \n
9  *  -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com) \n
10  *        : Optimizing for performance \n
11  * @see None
12  ****************************************************************************/
13 /****************************************************************************
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27  ****************************************************************************/
28
29 #ifndef _S3C_OTG_HCDI_LIST_H_
30 #define _S3C_OTG_HCDI_LIST_H_
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36
37 #include "s3c-otg-common-common.h"
38 #include "s3c-otg-hcdi-debug.h"
39
40 #include <linux/list.h>
41
42 typedef   struct  list_head    otg_list_head;
43
44 #define otg_list_get_node(ptr, type, member) container_of(ptr, type, member)
45
46
47 #define otg_list_for_each_safe(pos, n, head) \
48                                 for (pos = (head)->next, n = pos->next; pos != (head); \
49                                         pos = n, n = pos->next)
50
51
52 /**
53  * void otg_list_push_next(otg_list_head *new_node_p, otg_list_head *list_head_p)
54  *
55  * @brief push a list node into the next of head
56  *
57  * @param [in] new_node_p : node to be pushed
58  * @param [in] otg_list_head : target list head
59  *
60  * @return void \n
61  */
62
63 static  inline
64 void    otg_list_push_next(otg_list_head *new_node_p, otg_list_head *list_head_p)
65 {
66         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_push_next \n");
67         list_add(new_node_p, list_head_p);
68 }
69 //-------------------------------------------------------------------------------
70
71 /**
72  * void otg_list_push_prev(otg_list_head *new_node_p, otg_list_head *list_head_p)
73  *
74  * @brief push a list node into the previous of head
75  *
76  * @param [in] new_node_p : node to be pushed
77  * @param [in] otg_list_head : target list head
78  *
79  * @return void \n
80  */
81 static  inline
82 void    otg_list_push_prev(otg_list_head *new_node_p, otg_list_head *list_head_p)
83 {
84         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_push_prev \n");
85         list_add_tail(new_node_p, list_head_p);
86 }
87 //-------------------------------------------------------------------------------
88
89 /**
90  * void otg_list_pop(otg_list_head *list_entity_p)
91  *
92  * @brief pop a list node
93  *
94  * @param [in] new_node_p : node to be poped
95  * @param [in] otg_list_head : target list head
96  *
97  * @return void \n
98  */
99 static  inline
100 void    otg_list_pop(otg_list_head *list_entity_p)
101 {
102         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_pop \n");
103         list_del(list_entity_p);
104 }
105 //-------------------------------------------------------------------------------
106
107 /**
108  * void otg_list_move_next(otg_list_head *node_p, otg_list_head *list_head_p)
109  *
110  * @brief move a list to next of head
111  *
112  * @param [in] new_node_p : node to be moved
113  * @param [in] otg_list_head : target list head
114  *
115  * @return void \n
116  */
117 static  inline
118 void    otg_list_move_next(otg_list_head *node_p, otg_list_head *list_head_p)
119 {
120         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_move_next \n");
121         list_move(node_p, list_head_p);
122 }
123 //-------------------------------------------------------------------------------
124
125 /**
126  * void otg_list_move_prev(otg_list_head *node_p, otg_list_head *list_head_p)
127  *
128  * @brief move a list to previous of head
129  *
130  * @param [in] new_node_p : node to be moved
131  * @param [in] otg_list_head : target list head
132  *
133  * @return void \n
134  */
135 static  inline
136 void    otg_list_move_prev(otg_list_head *node_p, otg_list_head *list_head_p)
137 {
138         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_move_prev \n");
139         list_move_tail(node_p, list_head_p);
140 }
141 //-------------------------------------------------------------------------------
142
143 /**
144  * bool otg_list_empty(otg_list_head *list_head_p)
145  *
146  * @brief check a list empty or not
147  *
148  * @param [in] list_head_p : node to check
149  *
150  * @return true : empty list \n
151  *                 false : not empty list
152  */
153 static  inline
154 bool    otg_list_empty(otg_list_head *list_head_p)
155 {
156
157         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_empty \n");
158         if(list_empty(list_head_p))
159                 return true;
160         return false;
161 }
162 //-------------------------------------------------------------------------------
163
164 /**
165  * void otg_list_merge(otg_list_head *list_p, otg_list_head *head_p)
166  *
167  * @brief merge two list
168  *
169  * @param [in] list_p : a head
170  * @param [in] head_p : target list head
171  *
172  * @return void \n
173  */
174 static  inline
175 void    otg_list_merge(otg_list_head *list_p, otg_list_head *head_p)
176 {
177         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_merge \n");
178         list_splice(list_p, head_p);
179 }
180 //-------------------------------------------------------------------------------
181
182 /**
183  * void    otg_list_init(otg_list_head *list_p)
184  *
185  * @brief initialize a list
186  *
187  * @param [in] list_p : node to be initialized
188  *
189  * @return void \n
190  */
191 static  inline
192 void    otg_list_init(otg_list_head *list_p)
193 {
194         otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_init \n");
195         list_p->next = list_p;
196         list_p->prev = list_p;
197 }
198 //-------------------------------------------------------------------------------
199
200 /*
201 void    otg_list_push_next(otg_list_head *new_node_p, otg_list_head *list_head_p );
202 void    otg_list_push_prev(otg_list_head *new_node_p, otg_list_head *list_head_p);
203 void    otg_list_pop(otg_list_head *list_entity_p);
204
205 void    otg_list_move_next(otg_list_head *node_p, otg_list_head *list_head_p);
206 void    otg_list_move_prev(otg_list_head *node_p, otg_list_head *list_head_p);
207
208 bool    otg_list_empty(otg_list_head *list_head_p);
209 void    otg_list_merge(otg_list_head *list_p, otg_list_head *head_p);
210 void    otg_list_init(otg_list_head *list_p);
211 */
212
213 #ifdef __cplusplus
214 }
215 #endif
216 #endif /* _S3C_OTG_HCDI_LIST_H_ */
217