Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm
[linux-2.6.git] / drivers / staging / cxt1e1 / sbecom_inline_linux.h
blob3c6d1c0fc6d69050c893a320781facd7419114d8
1 #ifndef _INC_SBECOM_INLNX_H_
2 #define _INC_SBECOM_INLNX_H_
4 /*-----------------------------------------------------------------------------
5 * sbecom_inline_linux.h - SBE common Linux inlined routines
7 * Copyright (C) 2007 One Stop Systems, Inc.
8 * Copyright (C) 2005 SBE, 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.
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.
20 * For further information, contact via email: support@onestopsystems.com
21 * One Stop Systems, Inc. Escondido, California U.S.A.
22 *-----------------------------------------------------------------------------
26 #include <linux/types.h>
27 #include <linux/module.h>
28 #include <linux/kernel.h> /* resolves kmalloc references */
29 #include <linux/skbuff.h> /* resolves skb references */
30 #include <linux/netdevice.h> /* resolves dev_kree_skb_any */
31 #include <asm/byteorder.h> /* resolves cpu_to_le32 */
33 /* forward reference */
34 u_int32_t pci_read_32 (u_int32_t *p);
35 void pci_write_32 (u_int32_t *p, u_int32_t v);
39 * system dependent callbacks
42 /**********/
43 /* malloc */
44 /**********/
46 static inline void *
47 OS_kmalloc (size_t size)
49 char *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA);
51 if (ptr)
52 memset (ptr, 0, size);
53 return ptr;
56 static inline void
57 OS_kfree (void *x)
59 kfree (x);
63 /****************/
64 /* memory token */
65 /****************/
67 static inline void *
68 OS_mem_token_alloc (size_t size)
70 struct sk_buff *skb;
72 skb = dev_alloc_skb (size);
73 if (!skb)
75 //pr_warning("no mem in OS_mem_token_alloc !\n");
76 return 0;
78 return skb;
82 static inline void
83 OS_mem_token_free (void *token)
85 dev_kfree_skb_any (token);
89 static inline void
90 OS_mem_token_free_irq (void *token)
92 dev_kfree_skb_irq (token);
96 static inline void *
97 OS_mem_token_data (void *token)
99 return ((struct sk_buff *) token)->data;
103 static inline void *
104 OS_mem_token_next (void *token)
106 return 0;
110 static inline int
111 OS_mem_token_len (void *token)
113 return ((struct sk_buff *) token)->len;
117 static inline int
118 OS_mem_token_tlen (void *token)
120 return ((struct sk_buff *) token)->len;
124 /***************************************/
125 /* virtual to physical addr conversion */
126 /***************************************/
128 static inline u_long
129 OS_phystov (void *addr)
131 return (u_long) __va (addr);
135 static inline u_long
136 OS_vtophys (void *addr)
138 return __pa (addr);
142 /**********/
143 /* semops */
144 /**********/
146 void OS_sem_init (void *, int);
149 static inline void
150 OS_sem_free (void *sem)
153 * NOOP - since semaphores structures predeclared w/in structures, no
154 * longer malloc'd
158 #define SD_SEM_TAKE(sem,desc) down(sem)
159 #define SD_SEM_GIVE(sem) up(sem)
160 #define SEM_AVAILABLE 1
161 #define SEM_TAKEN 0
164 /**********************/
165 /* watchdog functions */
166 /**********************/
168 struct watchdog
170 struct timer_list h;
171 struct work_struct work;
172 void *softc;
173 void (*func) (void *softc);
174 int ticks;
175 int init_tq;
179 static inline int
180 OS_start_watchdog (struct watchdog *wd)
182 wd->h.expires = jiffies + wd->ticks;
183 add_timer (&wd->h);
184 return 0;
188 static inline int
189 OS_stop_watchdog (struct watchdog *wd)
191 del_timer_sync (&wd->h);
192 return 0;
196 static inline int
197 OS_free_watchdog (struct watchdog *wd)
199 OS_stop_watchdog (wd);
200 OS_kfree (wd);
201 return 0;
205 /* sleep in microseconds */
206 void OS_uwait (int usec, char *description);
207 void OS_uwait_dummy (void);
210 /* watchdog functions */
211 int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *ci, int usec);
214 #endif /*** _INC_SBECOM_INLNX_H_ ***/