~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to drivers/staging/rt2870/link_list.h

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *************************************************************************
3
 
 * Ralink Tech Inc.
4
 
 * 5F., No.36, Taiyuan St., Jhubei City,
5
 
 * Hsinchu County 302,
6
 
 * Taiwan, R.O.C.
7
 
 *
8
 
 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9
 
 *
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
 
 *************************************************************************
26
 
 */
27
 
 
28
 
#ifndef __LINK_LIST_H__
29
 
#define __LINK_LIST_H__
30
 
 
31
 
typedef struct _LIST_ENTRY
32
 
{
33
 
        struct _LIST_ENTRY *pNext;
34
 
} LIST_ENTRY, *PLIST_ENTRY;
35
 
 
36
 
typedef struct _LIST_HEADR
37
 
{
38
 
        PLIST_ENTRY pHead;
39
 
        PLIST_ENTRY pTail;
40
 
        UCHAR size;
41
 
} LIST_HEADER, *PLIST_HEADER;
42
 
 
43
 
static inline VOID initList(
44
 
        IN PLIST_HEADER pList)
45
 
{
46
 
        pList->pHead = pList->pTail = NULL;
47
 
        pList->size = 0;
48
 
        return;
49
 
}
50
 
 
51
 
static inline VOID insertTailList(
52
 
        IN PLIST_HEADER pList,
53
 
        IN PLIST_ENTRY pEntry)
54
 
{
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++;
62
 
 
63
 
        return;
64
 
}
65
 
 
66
 
static inline PLIST_ENTRY removeHeadList(
67
 
        IN PLIST_HEADER pList)
68
 
{
69
 
        PLIST_ENTRY pNext;
70
 
        PLIST_ENTRY pEntry;
71
 
 
72
 
        pEntry = pList->pHead;
73
 
        if (pList->pHead != NULL)
74
 
        {
75
 
                pNext = pList->pHead->pNext;
76
 
                pList->pHead = pNext;
77
 
                if (pNext == NULL)
78
 
                        pList->pTail = NULL;
79
 
                pList->size--;
80
 
        }
81
 
        return pEntry;
82
 
}
83
 
 
84
 
static inline int getListSize(
85
 
        IN PLIST_HEADER pList)
86
 
{
87
 
        return pList->size;
88
 
}
89
 
 
90
 
static inline PLIST_ENTRY delEntryList(
91
 
        IN PLIST_HEADER pList,
92
 
        IN PLIST_ENTRY pEntry)
93
 
{
94
 
        PLIST_ENTRY pCurEntry;
95
 
        PLIST_ENTRY pPrvEntry;
96
 
 
97
 
        if(pList->pHead == NULL)
98
 
                return NULL;
99
 
 
100
 
        if(pEntry == pList->pHead)
101
 
        {
102
 
                pCurEntry = pList->pHead;
103
 
                pList->pHead = pCurEntry->pNext;
104
 
 
105
 
                if(pList->pHead == NULL)
106
 
                        pList->pTail = NULL;
107
 
 
108
 
                pList->size--;
109
 
                return pCurEntry;
110
 
        }
111
 
 
112
 
        pPrvEntry = pList->pHead;
113
 
        pCurEntry = pPrvEntry->pNext;
114
 
        while(pCurEntry != NULL)
115
 
        {
116
 
                if (pEntry == pCurEntry)
117
 
                {
118
 
                        pPrvEntry->pNext = pCurEntry->pNext;
119
 
 
120
 
                        if(pEntry == pList->pTail)
121
 
                                pList->pTail = pPrvEntry;
122
 
 
123
 
                        pList->size--;
124
 
                        break;
125
 
                }
126
 
                pPrvEntry = pCurEntry;
127
 
                pCurEntry = pPrvEntry->pNext;
128
 
        }
129
 
 
130
 
        return pCurEntry;
131
 
}
132
 
 
133
 
#endif // ___LINK_LIST_H__ //
134
 
 
 
1
#include "../rt2860/link_list.h"