1 2#ifndef _IEEE1394_TYPES_H 3#define _IEEE1394_TYPES_H 4 5#include <linux/kernel.h> 6#include <linux/types.h> 7#include <linux/version.h> 8#include <linux/list.h> 9#include <linux/init.h> 10#include <asm/byteorder.h> 11 12 13/* The great kdev_t changeover in 2.5.x */ 14#include <linux/kdev_t.h> 15#ifndef minor 16#define minor(dev) MINOR(dev) 17#endif 18 19#ifndef __devexit_p 20#define __devexit_p(x) x 21#endif 22 23/* This showed up around this time */ 24#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,12) 25 26# ifndef MODULE_LICENSE 27# define MODULE_LICENSE(x) 28# endif 29 30# ifndef min 31# define min(x,y) ({ \ 32 const typeof(x) _x = (x); \ 33 const typeof(y) _y = (y); \ 34 (void) (&_x == &_y); \ 35 _x < _y ? _x : _y; }) 36# endif 37 38#endif /* Linux version < 2.4.12 */ 39 40#include <linux/spinlock.h> 41 42#ifndef list_for_each_safe 43#define list_for_each_safe(pos, n, head) \ 44 for (pos = (head)->next, n = pos->next; pos != (head); \ 45 pos = n, n = pos->next) 46 47#endif 48 49#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,5) 50#define pte_offset_kernel pte_offset 51#endif 52 53#ifndef MIN 54#define MIN(a,b) ((a) < (b) ? (a) : (b)) 55#endif 56 57#ifndef MAX 58#define MAX(a,b) ((a) > (b) ? (a) : (b)) 59#endif 60 61typedef u32 quadlet_t; 62typedef u64 octlet_t; 63typedef u16 nodeid_t; 64 65#define BUS_MASK 0xffc0 66#define NODE_MASK 0x003f 67#define LOCAL_BUS 0xffc0 68#define ALL_NODES 0x003f 69 70/* Can be used to consistently print a node/bus ID. */ 71#define NODE_BUS_FMT "%02d:%04d" 72#define NODE_BUS_ARGS(nodeid) \ 73 (nodeid & NODE_MASK), ((nodeid & BUS_MASK) >> 6) 74 75#define HPSB_PRINT(level, fmt, args...) printk(level "ieee1394: " fmt "\n" , ## args) 76 77#define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args) 78#define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args) 79#define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args) 80#define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args) 81#define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args) 82 83#define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "\n" , ## args) 84 85#define HPSB_TRACE() HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__) 86 87 88#ifdef __BIG_ENDIAN 89 90static __inline__ void *memcpy_le32(u32 *dest, const u32 *__src, size_t count) 91{ 92 void *tmp = dest; 93 u32 *src = (u32 *)__src; 94 95 count /= 4; 96 97 while (count--) { 98 *dest++ = swab32p(src++); 99 } 100 101 return tmp; 102} 103 104#else 105 106static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count) 107{ 108 return memcpy(dest, src, count); 109} 110 111#endif /* __BIG_ENDIAN */ 112 113#endif /* _IEEE1394_TYPES_H */ 114