52 #include <linux/version.h> 54 #if !defined( KERNEL_VERSION ) || ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 2, 0 ) ) 55 #error "You need to use at least a v2.2.x Linux kernel." 58 #if ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 6, 0 ) ) 59 #define __NO_VERSION__ // don't declare kernel_version in <linux/module.h> 63 #if defined( CONFIG_MODVERSIONS ) && !defined( MODVERSIONS ) 67 #if defined( MODVERSIONS ) 68 #if ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 6, 0 ) ) 69 #include <linux/modversions.h> 73 #include <linux/module.h> 74 #include <linux/init.h> 75 #include <linux/kernel.h> 77 #include <linux/poll.h> 78 #include <linux/interrupt.h> 79 #include <linux/proc_fs.h> 80 #include <linux/init.h> 81 #include <linux/param.h> 83 #include <asm/uaccess.h> 88 extern unsigned long volatile jiffies;
89 #define clock() jiffies 92 #define _MBG_INIT_CODE_ATTR __init 97 #if !defined( __devinit ) 101 #if !defined( __devinitdata ) 102 #define __devinitdata 105 #if !defined( __devexit ) 113 #if !defined( __devexit_p ) 114 #define __devexit_p( _x ) _x 119 #define _DEFAULT_MBG_TGT_LINUX_USE_PCI_PNP \ 120 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 4, 0 ) ) 122 #define _DEFAULT_MBG_TGT_LINUX_USE_USB \ 123 ( ( defined( CONFIG_USB ) || defined( CONFIG_USB_MODULE ) ) && \ 124 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 0 ) ) ) 126 #define _USE_LINUX_SYSFS \ 127 ( defined( CONFIG_SYSFS ) ) 129 #define _USE_LINUX_DEVFS \ 130 ( defined( CONFIG_DEVFS_FS ) ) 132 #define _USE_LINUX_DEVFS_26 \ 133 ( _USE_LINUX_DEVFS && \ 134 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 0 ) ) ) 136 #define _USE_LINUX_DEVFS_24 \ 137 ( _USE_LINUX_DEVFS && \ 138 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 4, 0 ) ) ) 152 #define _PCPS_CHK_BUFFER_DMA_CAPABLE \ 153 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 27 ) ) 155 #if _PCPS_CHK_BUFFER_DMA_CAPABLE 158 #if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 4, 11, 0 ) ) 159 #include <linux/sched/task_stack.h> 161 #include <linux/sched.h> 164 #define _pcps_buffer_is_dma_capable( _b ) \ 165 ( !is_vmalloc_addr( _b ) && !object_is_on_stack( _b ) ) 171 #define _PCPS_USB_TIMEOUT_IS_MS \ 172 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 12 ) ) 176 #if !_PCPS_USB_TIMEOUT_IS_MS 177 #define _pcps_ms_to_usb_timeout( _ms ) ( (_ms) * HZ / 1000 ) 182 #if !defined( _PCPS_USB_FULL_CYCLIC_INTV ) 183 #define _PCPS_USB_FULL_CYCLIC_INTV \ 184 ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 6, 11 ) ) 187 #include <linux/cdev.h> 189 #if !defined( _PCPS_USE_LINUX_KTHREAD ) 190 #define _PCPS_USE_LINUX_KTHREAD \ 191 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 10 ) ) //##++++ 194 #if _PCPS_USE_LINUX_KTHREAD 195 #include <linux/kthread.h> 199 #if !defined( NEW_FASYNC ) 203 #define NEW_FASYNC ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 2, 18 ) ) 206 #if !defined( NEW_FASYNC2 ) 208 #define NEW_FASYNC2 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 4, 0 ) ) 211 #if !defined( NEW_WAIT_QUEUE ) 213 #define NEW_WAIT_QUEUE ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 2, 18 ) ) 216 #if !defined( NEW_FILE_OPS ) 219 #define NEW_FILE_OPS ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 4, 0 ) ) 222 #if !defined( USE_WAIT_EVENT ) 225 #define USE_WAIT_EVENT ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 4, 20 ) ) 228 #if !defined( ESPIPE_BY_VFS ) 230 #define ESPIPE_BY_VFS ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 8 ) ) 233 #if !defined( FLUSH_WITH_LOCK_OWNER_ID ) 241 #define FLUSH_WITH_LOCK_OWNER_ID \ 242 ( ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 18 ) ) \ 243 || defined( FL_CLOSE ) ) 246 #if !defined( REQUEST_IRQ_WO_REGS ) 252 #define REQUEST_IRQ_WO_REGS \ 253 ( ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 19 ) \ 254 || defined( _LINUX_BH_H ) ) ) 258 #if !defined( IRQ_RETVAL ) 267 #if !defined( GENERIC_GPIO_SUPPORTED ) 270 #define GENERIC_GPIO_SUPPORTED \ 271 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 34 ) ) 277 #define _PCPS_MUST_UPDATE_USE_COUNT \ 278 ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 6, 0 ) ) 280 #define _PCPS_HAVE_LINUX_CLASS \ 281 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 0 ) ) 283 #define _PCPS_HAVE_LINUX_CLASS_SIMPLE \ 284 ( _PCPS_HAVE_LINUX_CLASS && ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 6, 13 ) ) ) 286 #define _PCPS_HAVE_LINUX_CLASS_CREATE \ 287 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 13 ) ) 289 #define _PCPS_CLASS_DEVICE_CREATE_WITH_PARENT \ 290 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 14 ) ) 292 #define _PCPS_CLASS_DEV_OBSOLETED \ 293 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 26 ) ) 295 #define _PCPS_DEVICE_CREATE_WITH_DEV_DATA \ 296 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 27 ) ) 302 extern struct class_simple *class_simple_create(
struct module *owner,
char *name);
303 extern void class_simple_destroy(
struct class_simple *cs);
304 extern struct class_device *class_simple_device_add(
struct class_simple *cs, dev_t dev,
305 struct device *device,
const char *fmt, ...)
306 __attribute__((format(printf,4,5)));
307 extern
int class_simple_set_hotplug(struct class_simple *,
308 int (*hotplug)(struct class_device *dev,
char **envp,
int num_envp,
char *buffer,
int buffer_size));
309 extern
void class_simple_device_remove(dev_t dev);
313 extern struct class_device *class_device_create(struct class *cls,
315 struct device *device,
317 __attribute__((format(printf,4,5)));
321 extern struct class *class_create(struct module *owner, const
char *name);
322 extern
void class_destroy(struct class *cls);
323 extern struct class_device *class_device_create(struct class *cls,
324 struct class_device *parent,
326 struct device *device,
327 const
char *fmt, ...)
328 __attribute__((format(printf,5,6)));
329 extern
void class_device_destroy(struct class *cls, dev_t devt);
333 extern struct class *class_create(struct module *owner, const
char *name);
334 extern
void class_destroy(struct class *cls);
335 extern struct class_device *class_device_create(struct class *cls,
336 struct class_device *parent,
338 struct device *device,
339 const
char *fmt, ...)
340 __attribute__((format(printf, 5, 6)));
341 extern
void class_device_destroy(struct class *cls, dev_t devt);
345 extern struct device *device_create(struct class *cls, struct device *parent,
346 dev_t devt, const
char *fmt, ...)
347 __attribute__((format(printf, 4, 5)));
348 extern
void device_destroy(struct class *cls, dev_t devt);
352 extern struct class * __must_check __class_create(struct module *owner,
354 struct lock_class_key *key);
357 #define class_create(owner, name) \ 359 static struct lock_class_key __key; \ 360 __class_create(owner, name, &__key); \ 362 extern void class_destroy(
struct class *cls);
364 extern struct device *device_create(
struct class *cls,
struct device *parent,
365 dev_t devt,
void *drvdata,
366 const char *fmt, ...)
367 __attribute__((format(printf, 5, 6)));
368 #define device_create_drvdata device_create 369 extern void device_destroy(
struct class *cls, dev_t devt);
371 - class_device_create() and class_device_destroy() have been removed
372 - use device_create() and device_destroy() instead
377 #if !defined( STRUCT_USB_DEVICE_HAS_SERIAL ) 378 #define STRUCT_USB_DEVICE_HAS_SERIAL \ 379 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 12 ) ) 382 #if !defined( STRUCT_USB_DEVICE_HAS_STATIC_SERIAL ) 383 #define STRUCT_USB_DEVICE_HAS_STATIC_SERIAL 0 388 #if !defined( VMA_HAS_VM_PGOFF ) 389 #define VMA_HAS_VM_PGOFF \ 390 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 0 ) ) //##++ needs verification !! 393 #if !defined( _PCPS_HAS_REMAP_PFN ) 398 #define _PCPS_HAS_REMAP_PFN \ 399 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 10 ) ) 412 #if !defined( NEED_IMINOR ) 413 #define NEED_IMINOR \ 414 ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 4, 0 ) ) //##++ needs verification !! 418 #define iminor( _d ) MINOR( (_d)->i_rdev ) unsigned long volatile jiffies