This is pre8 ...
[linux-2.6/linux-mips.git] / drivers / ieee1394 / ieee1394_types.h
blob84be6aa058c96308b78a76271c0c25f9ac39dd05
2 #ifndef _IEEE1394_TYPES_H
3 #define _IEEE1394_TYPES_H
5 #include <linux/kernel.h>
6 #include <linux/types.h>
7 #include <linux/version.h>
8 #include <linux/list.h>
9 #include <asm/byteorder.h>
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
14 #include <linux/wait.h>
15 #define DECLARE_WAITQUEUE(name, task) struct wait_queue name = { task, NULL }
17 typedef struct wait_queue *wait_queue_head_t;
18 typedef struct wait_queue wait_queue_t;
20 inline static void init_waitqueue_head(wait_queue_head_t *wh)
22 *wh = NULL;
25 inline static void init_waitqueue_entry(wait_queue_t *wq, struct task_struct *p)
27 wq->task = p;
28 wq->next = NULL;
31 static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
33 __list_add(new, head->prev, head);
36 #define __constant_cpu_to_be32(x) __constant_htonl((x))
38 #define set_current_state(state_value) \
39 do { current->state = (state_value); } while (0)
42 #include <asm/page.h>
43 /* Pure 2^n version of get_order */
44 extern __inline__ int get_order(unsigned long size)
46 int order;
47 size = (size-1) >> (PAGE_SHIFT-1);
48 order = -1;
49 do {
50 size >>= 1;
51 order++;
52 } while (size);
53 return order;
57 #include <linux/pci.h>
58 inline static int pci_enable_device(struct pci_dev *dev)
60 u16 cmd;
61 pci_read_config_word(dev, PCI_COMMAND, &cmd);
62 pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
63 return 0;
66 #define PCI_DMA_BIDIRECTIONAL 0
67 #define PCI_DMA_TODEVICE 1
68 #define PCI_DMA_FROMDEVICE 2
69 #define PCI_DMA_NONE 3
70 #define PCI_ROM_RESOURCE 6
71 #define pci_resource_start(dev, bar) ((bar) == PCI_ROM_RESOURCE \
72 ? (dev)->rom_address \
73 : (dev)->base_address[(bar)])
74 #define BUG() *(int *)0 = 0
76 #include <asm/io.h>
77 typedef u32 dma_addr_t;
79 extern inline int pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
81 return 1;
84 extern inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
85 dma_addr_t *dma_handle)
87 void *ret;
88 ret = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
89 if (ret) {
90 memset(ret, 0, size);
91 *dma_handle = virt_to_bus(ret);
93 return ret;
96 extern inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
97 void *vaddr, dma_addr_t dma_handle)
99 free_pages((unsigned long)vaddr, get_order(size));
102 extern inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
103 size_t size, int direction)
105 if (direction == PCI_DMA_NONE)
106 BUG();
107 return virt_to_bus(ptr);
110 extern inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
111 size_t size, int direction)
113 if (direction == PCI_DMA_NONE)
114 BUG();
117 struct scatterlist {};
118 extern inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
119 int nents, int direction)
121 if (direction == PCI_DMA_NONE)
122 BUG();
123 return nents;
126 extern inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
127 int nents, int direction)
129 if (direction == PCI_DMA_NONE)
130 BUG();
133 extern inline void pci_dma_sync_single(struct pci_dev *hwdev,
134 dma_addr_t dma_handle,
135 size_t size, int direction)
137 if (direction == PCI_DMA_NONE)
138 BUG();
141 extern inline void pci_dma_sync_sg(struct pci_dev *hwdev,
142 struct scatterlist *sg,
143 int nelems, int direction)
145 if (direction == PCI_DMA_NONE)
146 BUG();
150 #ifndef _LINUX_DEVFS_FS_KERNEL_H
151 typedef struct devfs_entry * devfs_handle_t;
152 #define DEVFS_FL_NONE 0
154 static inline devfs_handle_t devfs_register (devfs_handle_t dir,
155 const char *name,
156 unsigned int flags,
157 unsigned int major,
158 unsigned int minor,
159 umode_t mode,
160 void *ops, void *info)
162 return NULL;
164 static inline void devfs_unregister (devfs_handle_t de)
166 return;
168 static inline int devfs_register_chrdev (unsigned int major, const char *name,
169 struct file_operations *fops)
171 return register_chrdev (major, name, fops);
173 static inline int devfs_unregister_chrdev (unsigned int major,const char *name)
175 return unregister_chrdev (major, name);
177 #endif /* _LINUX_DEVFS_FS_KERNEL_H */
180 #define V22_COMPAT_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
181 #define V22_COMPAT_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
182 #define OWNER_THIS_MODULE
184 #else /* Linux version < 2.3 */
186 #define V22_COMPAT_MOD_INC_USE_COUNT do {} while (0)
187 #define V22_COMPAT_MOD_DEC_USE_COUNT do {} while (0)
188 #define OWNER_THIS_MODULE owner: THIS_MODULE,
190 #endif /* Linux version < 2.3 */
194 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,18)
195 #include <asm/spinlock.h>
196 #else
197 #include <linux/spinlock.h>
198 #endif
200 #ifndef MIN
201 #define MIN(a,b) ((a) < (b) ? (a) : (b))
202 #endif
204 #ifndef MAX
205 #define MAX(a,b) ((a) > (b) ? (a) : (b))
206 #endif
208 typedef u32 quadlet_t;
209 typedef u64 octlet_t;
210 typedef u16 nodeid_t;
212 #define BUS_MASK 0xffc0
213 #define NODE_MASK 0x003f
214 #define LOCAL_BUS 0xffc0
215 #define ALL_NODES 0x003f
217 #define HPSB_PRINT(level, fmt, args...) printk(level "ieee1394: " fmt "\n" , ## args)
219 #define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
220 #define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args)
221 #define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args)
222 #define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args)
223 #define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)
225 #define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "\n" , ## args)
227 #define HPSB_TRACE() HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__)
230 #ifdef __BIG_ENDIAN
232 static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
234 void *tmp = dest;
236 count /= 4;
238 while (count--) {
239 *dest++ = swab32p(src++);
242 return tmp;
245 #else
247 static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
249 return memcpy(dest, src, count);
252 #endif /* __BIG_ENDIAN */
254 #endif /* _IEEE1394_TYPES_H */