aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/shost/shost_list.h
blob: 7283fb77730f9b00a5fb240dbe2cdd693335e00d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/****************************************************************************
 *  (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
 *
 * @file   s3c-otg-hcdi-list.h
 * @brief  list functions for otg
 * @version
 *  -# Jun 9,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com)
 *	  : Creating the initial version of this code
 *  -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com)
 *	  : Optimizing for performance
 * @see None
 ****************************************************************************/
/****************************************************************************
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ****************************************************************************/

#ifndef _S3C_OTG_HCDI_LIST_H_
#define _S3C_OTG_HCDI_LIST_H_

#include <linux/list.h>

typedef   struct  list_head    otg_list_head;

#define	otg_list_get_node(ptr, type, member) container_of(ptr, type, member)


#define	otg_list_for_each_safe(pos, n, head) \
	for (pos = (head)->next, n = pos->next; pos != (head); \
		pos = n, n = pos->next)


/**
 * void	otg_list_push_next(otg_list_head *n, otg_list_head *list)
 *
 * @brief push a list node into the next of head
 *
 * @param [in] n : node to be pushed
 * @param [in] otg_list_head : target list head
 *
 * @return void \n
 */

static	inline
void otg_list_push_next(otg_list_head *n, otg_list_head *list)
{
	otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_push_next\n");
	list_add(n, list);
}

/**
 * void	otg_list_push_prev(otg_list_head *n, otg_list_head *list)
 *
 * @brief push a list node into the previous of head
 *
 * @param [in] n : node to be pushed
 * @param [in] otg_list_head : target list head
 *
 * @return void \n
 */
static	inline
void otg_list_push_prev(otg_list_head *n, otg_list_head *list)
{
	otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_push_prev\n");
	list_add_tail(n, list);
}

/**
 * void	otg_list_pop(otg_list_head *list_entity_p)
 *
 * @brief pop a list node
 *
 * @param [in] n : node to be poped
 * @param [in] otg_list_head : target list head
 *
 * @return void \n
 */
static	inline
void otg_list_pop(otg_list_head *list_entity_p)
{
	otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_pop\n");

	if (list_entity_p->prev && list_entity_p->next)
		list_del(list_entity_p);
	else
		pr_info("usb: otg_list_pop error\n");
}

/**
 * void	otg_list_move_next(otg_list_head *node_p, otg_list_head *list)
 *
 * @brief move a list to next of head
 *
 * @param [in] n : node to be moved
 * @param [in] otg_list_head : target list head
 *
 * @return void \n
 */
static	inline
void otg_list_move_next(otg_list_head *node_p, otg_list_head *list)
{
	otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_move_next\n");
	list_move(node_p, list);
}

/**
 * void	otg_list_move_prev(otg_list_head *node_p, otg_list_head *list)
 *
 * @brief move a list to previous of head
 *
 * @param [in] n : node to be moved
 * @param [in] otg_list_head : target list head
 *
 * @return void \n
 */
static	inline
void otg_list_move_prev(otg_list_head *node_p, otg_list_head *list)
{
	otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_move_prev\n");
	list_move_tail(node_p, list);
}

/**
 * bool	otg_list_empty(otg_list_head *list)
 *
 * @brief check a list empty or not
 *
 * @param [in] list : node to check
 *
 * @return true : empty list \n
 *	false : not empty list
 */
static	inline
bool otg_list_empty(otg_list_head *list)
{
	/* otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_empty\n"); */
	if (list_empty(list))
		return true;
	return false;
}

/**
 * void	otg_list_merge(otg_list_head *list_p, otg_list_head *head_p)
 *
 * @brief merge two list
 *
 * @param [in] list_p : a head
 * @param [in] head_p : target list head
 *
 * @return void \n
 */
static	inline
void otg_list_merge(otg_list_head *list_p, otg_list_head *head_p)
{
	otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_merge\n");
	list_splice(list_p, head_p);
}

/**
 * void    otg_list_init(otg_list_head *list_p)
 *
 * @brief initialize a list
 *
 * @param [in] list_p : node to be initialized
 *
 * @return void \n
 */
static	inline
void    otg_list_init(otg_list_head *list_p)
{
	otg_dbg(OTG_DBG_OTGHCDI_LIST, "otg_list_init\n");
	list_p->next = list_p;
	list_p->prev = list_p;
}

#endif /* _S3C_OTG_HCDI_LIST_H_ */