added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / rt2870 / link_list.h
blobf6521133fd5ec097a47f0fac1e612fd538df89dd
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
28 #ifndef __LINK_LIST_H__
29 #define __LINK_LIST_H__
31 typedef struct _LIST_ENTRY
33 struct _LIST_ENTRY *pNext;
34 } LIST_ENTRY, *PLIST_ENTRY;
36 typedef struct _LIST_HEADR
38 PLIST_ENTRY pHead;
39 PLIST_ENTRY pTail;
40 UCHAR size;
41 } LIST_HEADER, *PLIST_HEADER;
43 static inline VOID initList(
44 IN PLIST_HEADER pList)
46 pList->pHead = pList->pTail = NULL;
47 pList->size = 0;
48 return;
51 static inline VOID insertTailList(
52 IN PLIST_HEADER pList,
53 IN PLIST_ENTRY pEntry)
55 pEntry->pNext = NULL;
56 if (pList->pTail)
57 pList->pTail->pNext = pEntry;
58 else
59 pList->pHead = pEntry;
60 pList->pTail = pEntry;
61 pList->size++;
63 return;
66 static inline PLIST_ENTRY removeHeadList(
67 IN PLIST_HEADER pList)
69 PLIST_ENTRY pNext;
70 PLIST_ENTRY pEntry;
72 pEntry = pList->pHead;
73 if (pList->pHead != NULL)
75 pNext = pList->pHead->pNext;
76 pList->pHead = pNext;
77 if (pNext == NULL)
78 pList->pTail = NULL;
79 pList->size--;
81 return pEntry;
84 static inline int getListSize(
85 IN PLIST_HEADER pList)
87 return pList->size;
90 static inline PLIST_ENTRY delEntryList(
91 IN PLIST_HEADER pList,
92 IN PLIST_ENTRY pEntry)
94 PLIST_ENTRY pCurEntry;
95 PLIST_ENTRY pPrvEntry;
97 if(pList->pHead == NULL)
98 return NULL;
100 if(pEntry == pList->pHead)
102 pCurEntry = pList->pHead;
103 pList->pHead = pCurEntry->pNext;
105 if(pList->pHead == NULL)
106 pList->pTail = NULL;
108 pList->size--;
109 return pCurEntry;
112 pPrvEntry = pList->pHead;
113 pCurEntry = pPrvEntry->pNext;
114 while(pCurEntry != NULL)
116 if (pEntry == pCurEntry)
118 pPrvEntry->pNext = pCurEntry->pNext;
120 if(pEntry == pList->pTail)
121 pList->pTail = pPrvEntry;
123 pList->size--;
124 break;
126 pPrvEntry = pCurEntry;
127 pCurEntry = pPrvEntry->pNext;
130 return pCurEntry;
133 #endif // ___LINK_LIST_H__ //