aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/csr1212.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/csr1212.h')
-rw-r--r--drivers/ieee1394/csr1212.h90
1 files changed, 8 insertions, 82 deletions
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h
index 86f23d6bba86..f42e12e58ae7 100644
--- a/drivers/ieee1394/csr1212.h
+++ b/drivers/ieee1394/csr1212.h
@@ -30,87 +30,13 @@
30#ifndef __CSR1212_H__ 30#ifndef __CSR1212_H__
31#define __CSR1212_H__ 31#define __CSR1212_H__
32 32
33
34/* Compatibility layer */
35#ifdef __KERNEL__
36
37#include <linux/types.h> 33#include <linux/types.h>
38#include <linux/slab.h>
39#include <linux/interrupt.h>
40#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
41#include <asm/pgalloc.h>
42 35
43#define CSR1212_MALLOC(size) vmalloc((size)) 36#define CSR1212_MALLOC(size) vmalloc((size))
44#define CSR1212_FREE(ptr) vfree(ptr) 37#define CSR1212_FREE(ptr) vfree(ptr)
45#define CSR1212_BE16_TO_CPU(quad) be16_to_cpu(quad)
46#define CSR1212_CPU_TO_BE16(quad) cpu_to_be16(quad)
47#define CSR1212_BE32_TO_CPU(quad) be32_to_cpu(quad)
48#define CSR1212_CPU_TO_BE32(quad) cpu_to_be32(quad)
49#define CSR1212_BE64_TO_CPU(quad) be64_to_cpu(quad)
50#define CSR1212_CPU_TO_BE64(quad) cpu_to_be64(quad)
51
52#define CSR1212_LE16_TO_CPU(quad) le16_to_cpu(quad)
53#define CSR1212_CPU_TO_LE16(quad) cpu_to_le16(quad)
54#define CSR1212_LE32_TO_CPU(quad) le32_to_cpu(quad)
55#define CSR1212_CPU_TO_LE32(quad) cpu_to_le32(quad)
56#define CSR1212_LE64_TO_CPU(quad) le64_to_cpu(quad)
57#define CSR1212_CPU_TO_LE64(quad) cpu_to_le64(quad)
58
59#include <linux/errno.h>
60#define CSR1212_SUCCESS (0)
61#define CSR1212_EINVAL (-EINVAL)
62#define CSR1212_ENOMEM (-ENOMEM)
63#define CSR1212_ENOENT (-ENOENT)
64#define CSR1212_EIO (-EIO)
65#define CSR1212_EBUSY (-EBUSY)
66
67#else /* Userspace */
68
69#include <sys/types.h>
70#include <malloc.h>
71#define CSR1212_MALLOC(size) malloc(size)
72#define CSR1212_FREE(ptr) free(ptr)
73#include <endian.h>
74#if __BYTE_ORDER == __LITTLE_ENDIAN
75#include <byteswap.h>
76#define CSR1212_BE16_TO_CPU(quad) bswap_16(quad)
77#define CSR1212_CPU_TO_BE16(quad) bswap_16(quad)
78#define CSR1212_BE32_TO_CPU(quad) bswap_32(quad)
79#define CSR1212_CPU_TO_BE32(quad) bswap_32(quad)
80#define CSR1212_BE64_TO_CPU(quad) bswap_64(quad)
81#define CSR1212_CPU_TO_BE64(quad) bswap_64(quad)
82
83#define CSR1212_LE16_TO_CPU(quad) (quad)
84#define CSR1212_CPU_TO_LE16(quad) (quad)
85#define CSR1212_LE32_TO_CPU(quad) (quad)
86#define CSR1212_CPU_TO_LE32(quad) (quad)
87#define CSR1212_LE64_TO_CPU(quad) (quad)
88#define CSR1212_CPU_TO_LE64(quad) (quad)
89#else
90#define CSR1212_BE16_TO_CPU(quad) (quad)
91#define CSR1212_CPU_TO_BE16(quad) (quad)
92#define CSR1212_BE32_TO_CPU(quad) (quad)
93#define CSR1212_CPU_TO_BE32(quad) (quad)
94#define CSR1212_BE64_TO_CPU(quad) (quad)
95#define CSR1212_CPU_TO_BE64(quad) (quad)
96
97#define CSR1212_LE16_TO_CPU(quad) bswap_16(quad)
98#define CSR1212_CPU_TO_LE16(quad) bswap_16(quad)
99#define CSR1212_LE32_TO_CPU(quad) bswap_32(quad)
100#define CSR1212_CPU_TO_LE32(quad) bswap_32(quad)
101#define CSR1212_LE64_TO_CPU(quad) bswap_64(quad)
102#define CSR1212_CPU_TO_LE64(quad) bswap_64(quad)
103#endif
104
105#include <errno.h>
106#define CSR1212_SUCCESS (0)
107#define CSR1212_EINVAL (EINVAL)
108#define CSR1212_ENOMEM (ENOMEM)
109#define CSR1212_ENOENT (ENOENT)
110#define CSR1212_EIO (EIO)
111#define CSR1212_EBUSY (EBUSY)
112 38
113#endif 39#define CSR1212_SUCCESS (0)
114 40
115 41
116/* CSR 1212 key types */ 42/* CSR 1212 key types */
@@ -302,9 +228,9 @@ struct csr1212_bus_ops {
302#define CSR1212_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u_int32_t)) 228#define CSR1212_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u_int32_t))
303 229
304#define CSR1212_DESCRIPTOR_LEAF_TYPE(kv) \ 230#define CSR1212_DESCRIPTOR_LEAF_TYPE(kv) \
305 (CSR1212_BE32_TO_CPU((kv)->value.leaf.data[0]) >> CSR1212_DESCRIPTOR_LEAF_TYPE_SHIFT) 231 (be32_to_cpu((kv)->value.leaf.data[0]) >> CSR1212_DESCRIPTOR_LEAF_TYPE_SHIFT)
306#define CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) \ 232#define CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) \
307 (CSR1212_BE32_TO_CPU((kv)->value.leaf.data[0]) & \ 233 (be32_to_cpu((kv)->value.leaf.data[0]) & \
308 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID_MASK) 234 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID_MASK)
309 235
310 236
@@ -317,14 +243,14 @@ struct csr1212_bus_ops {
317#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u_int32_t)) 243#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u_int32_t))
318 244
319#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) \ 245#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) \
320 (CSR1212_BE32_TO_CPU((kv)->value.leaf.data[1]) >> \ 246 (be32_to_cpu((kv)->value.leaf.data[1]) >> \
321 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH_SHIFT) 247 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH_SHIFT)
322#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) \ 248#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) \
323 ((CSR1212_BE32_TO_CPU((kv)->value.leaf.data[1]) >> \ 249 ((be32_to_cpu((kv)->value.leaf.data[1]) >> \
324 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_SHIFT) & \ 250 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_SHIFT) & \
325 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_MASK) 251 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_MASK)
326#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) \ 252#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) \
327 (CSR1212_BE32_TO_CPU((kv)->value.leaf.data[1]) & \ 253 (be32_to_cpu((kv)->value.leaf.data[1]) & \
328 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK) 254 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK)
329#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA(kv) \ 255#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA(kv) \
330 (&((kv)->value.leaf.data[2])) 256 (&((kv)->value.leaf.data[2]))