Merge branch 'fix/asoc' into topic/asoc
[linux-2.6] / drivers / staging / sxg / sxg_os.h
1 /**************************************************************************
2  *
3  * Copyright (C) 2000-2008 Alacritech, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above
12  *    copyright notice, this list of conditions and the following
13  *    disclaimer in the documentation and/or other materials provided
14  *    with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY ALACRITECH, INC. ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ALACRITECH, INC. OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * The views and conclusions contained in the software and documentation
30  * are those of the authors and should not be interpreted as representing
31  * official policies, either expressed or implied, of Alacritech, Inc.
32  *
33  **************************************************************************/
34
35 /*
36  * FILENAME: sxg_os.h
37  *
38  * These are the Linux-specific definitions required for the SLICOSS
39  * driver, which should allow for greater portability to other OSes.
40  */
41 #ifndef _SLIC_OS_SPECIFIC_H_
42 #define _SLIC_OS_SPECIFIC_H_
43
44 #define FALSE   (0)
45 #define TRUE    (1)
46
47 struct list_entry {
48         struct list_entry *nle_flink;
49         struct list_entry *nle_blink;
50 };
51
52 #define InitializeListHead(l)                                           \
53         (l)->nle_flink = (l)->nle_blink = (l)
54
55 #define IsListEmpty(h)                                                  \
56         ((h)->nle_flink == (h))
57
58 #define RemoveEntryList(e)                                              \
59         do {                                                            \
60                 list_entry              *b;                             \
61                 list_entry              *f;                             \
62                                                                         \
63                 f = (e)->nle_flink;                                     \
64                 b = (e)->nle_blink;                                     \
65                 b->nle_flink = f;                                       \
66                 f->nle_blink = b;                                       \
67         } while (0)
68
69 /* These two have to be inlined since they return things. */
70
71 static inline struct list_entry *RemoveHeadList(struct list_entry *l)
72 {
73         struct list_entry *f;
74         struct list_entry *e;
75
76         e = l->nle_flink;
77         f = e->nle_flink;
78         l->nle_flink = f;
79         f->nle_blink = l;
80
81         return (e);
82 }
83
84 static inline struct list_entry *RemoveTailList(struct list_entry *l)
85 {
86         struct list_entry *b;
87         struct list_entry *e;
88
89         e = l->nle_blink;
90         b = e->nle_blink;
91         l->nle_blink = b;
92         b->nle_flink = l;
93
94         return (e);
95 }
96
97 #define InsertTailList(l, e)                                            \
98         do {                                                            \
99                 struct list_entry       *b;                             \
100                                                                         \
101                 b = (l)->nle_blink;                                     \
102                 (e)->nle_flink = (l);                                   \
103                 (e)->nle_blink = b;                                     \
104                 b->nle_flink = (e);                                     \
105                 (l)->nle_blink = (e);                                   \
106         } while (0)
107
108 #define InsertHeadList(l, e)                                            \
109         do {                                                            \
110                 struct list_entry       *f;                             \
111                                                                         \
112                 f = (l)->nle_flink;                                     \
113                 (e)->nle_flink = f;                                     \
114                 (e)->nle_blink = l;                                     \
115                 f->nle_blink = (e);                                     \
116                 (l)->nle_flink = (e);                                   \
117         } while (0)
118
119 #define ATK_DEBUG  1
120
121 #if ATK_DEBUG
122 #define SLIC_TIMESTAMP(value) {                                         \
123         struct timeval  timev;                                          \
124         do_gettimeofday(&timev);                                        \
125         value = timev.tv_sec*1000000 + timev.tv_usec;                   \
126 }
127 #else
128 #define SLIC_TIMESTAMP(value)
129 #endif
130
131 /* SXG DEFINES */
132
133 #ifdef  ATKDBG
134 #define SXG_TIMESTAMP(value) {                                          \
135         struct timeval  timev;                                          \
136         do_gettimeofday(&timev);                                        \
137         value = timev.tv_sec*1000000 + timev.tv_usec;                   \
138 }
139 #else
140 #define SXG_TIMESTAMP(value)
141 #endif
142
143 #define WRITE_REG(reg,value,flush)                                      \
144                                 sxg_reg32_write((&reg), (value), (flush))
145 #define WRITE_REG64(a,reg,value,cpu)                                    \
146                                 sxg_reg64_write((a),(&reg),(value),(cpu))
147 #define READ_REG(reg,value)   (value) = readl((void __iomem *)(&reg))
148
149 #endif /* _SLIC_OS_SPECIFIC_H_  */