1 /****************************************************************************
2 * (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
4 * @file s3c-otg-hcdi-list.h
5 * @brief list functions for otg \n
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
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.
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.
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 ****************************************************************************/
29 #ifndef _S3C_OTG_HCDI_LIST_H_
30 #define _S3C_OTG_HCDI_LIST_H_
37 #include "s3c-otg-common-common.h"
38 #include "s3c-otg-hcdi-debug.h"
40 #include <linux/list.h>
42 typedef struct list_head otg_list_head;
44 #define otg_list_get_node(ptr, type, member) container_of(ptr, type, member)
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)
53 * void otg_list_push_next(otg_list_head *new_node_p, otg_list_head *list_head_p)
55 * @brief push a list node into the next of head
57 * @param [in] new_node_p : node to be pushed
58 * @param [in] otg_list_head : target list head
64 void otg_list_push_next(otg_list_head *new_node_p, otg_list_head *list_head_p)
66 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_push_next \n");
67 list_add(new_node_p, list_head_p);
69 //-------------------------------------------------------------------------------
72 * void otg_list_push_prev(otg_list_head *new_node_p, otg_list_head *list_head_p)
74 * @brief push a list node into the previous of head
76 * @param [in] new_node_p : node to be pushed
77 * @param [in] otg_list_head : target list head
82 void otg_list_push_prev(otg_list_head *new_node_p, otg_list_head *list_head_p)
84 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_push_prev \n");
85 list_add_tail(new_node_p, list_head_p);
87 //-------------------------------------------------------------------------------
90 * void otg_list_pop(otg_list_head *list_entity_p)
92 * @brief pop a list node
94 * @param [in] new_node_p : node to be poped
95 * @param [in] otg_list_head : target list head
100 void otg_list_pop(otg_list_head *list_entity_p)
102 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_pop \n");
103 list_del(list_entity_p);
105 //-------------------------------------------------------------------------------
108 * void otg_list_move_next(otg_list_head *node_p, otg_list_head *list_head_p)
110 * @brief move a list to next of head
112 * @param [in] new_node_p : node to be moved
113 * @param [in] otg_list_head : target list head
118 void otg_list_move_next(otg_list_head *node_p, otg_list_head *list_head_p)
120 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_move_next \n");
121 list_move(node_p, list_head_p);
123 //-------------------------------------------------------------------------------
126 * void otg_list_move_prev(otg_list_head *node_p, otg_list_head *list_head_p)
128 * @brief move a list to previous of head
130 * @param [in] new_node_p : node to be moved
131 * @param [in] otg_list_head : target list head
136 void otg_list_move_prev(otg_list_head *node_p, otg_list_head *list_head_p)
138 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_move_prev \n");
139 list_move_tail(node_p, list_head_p);
141 //-------------------------------------------------------------------------------
144 * bool otg_list_empty(otg_list_head *list_head_p)
146 * @brief check a list empty or not
148 * @param [in] list_head_p : node to check
150 * @return true : empty list \n
151 * false : not empty list
154 bool otg_list_empty(otg_list_head *list_head_p)
157 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_empty \n");
158 if(list_empty(list_head_p))
162 //-------------------------------------------------------------------------------
165 * void otg_list_merge(otg_list_head *list_p, otg_list_head *head_p)
167 * @brief merge two list
169 * @param [in] list_p : a head
170 * @param [in] head_p : target list head
175 void otg_list_merge(otg_list_head *list_p, otg_list_head *head_p)
177 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_merge \n");
178 list_splice(list_p, head_p);
180 //-------------------------------------------------------------------------------
183 * void otg_list_init(otg_list_head *list_p)
185 * @brief initialize a list
187 * @param [in] list_p : node to be initialized
192 void otg_list_init(otg_list_head *list_p)
194 otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_init \n");
195 list_p->next = list_p;
196 list_p->prev = list_p;
198 //-------------------------------------------------------------------------------
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);
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);
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);
216 #endif /* _S3C_OTG_HCDI_LIST_H_ */