diff --git a/backend/plustek-pp_ptdrv.c b/backend/plustek-pp_ptdrv.c index 84658eafb..8d062797f 100644 --- a/backend/plustek-pp_ptdrv.c +++ b/backend/plustek-pp_ptdrv.c @@ -209,8 +209,14 @@ MODULE_PARM_DESC(forceMode, "0 = use auto detection, " "1 = use SPP mode, 2 = use EPP mode"); #endif -#if (defined(CONFIG_DEVFS_FS) && !defined(DEVFS_26_STYLE)) -static devfs_handle_t devfs_handle = NULL; +#if defined (CONFIG_DEVFS_FS) +# ifndef (DEVFS_26_STYLE) + static devfs_handle_t devfs_handle = NULL; +# endif +#else +# ifdef LINUX_26 + static class_t *ptdrv_class; +# endif #endif /* @@ -1605,6 +1611,12 @@ int init_module( void ) } printk( KERN_INFO "pt_drv : driver version "_PTDRV_VERSTR"\n" ); +#if !defined (CONFIG_DEVFS_FS) && defined (LINUX_26) + ptdrv_class = class_create(THIS_MODULE, "scanner"); + if (IS_ERR(ptdrv_class)) + goto out_devfs; +#endif + /* register the proc_fs */ ProcFsInitialize(); @@ -1631,7 +1643,14 @@ int init_module( void ) (S_IFCHR | S_IRUGO | S_IWUGO | S_IFCHR), "scanner/pt_drv%d", devCount); # endif -#endif +#else +# ifdef LINUX_26 + CLASS_DEVICE_CREATE(ptdrv_class, + MKDEV(_PTDRV_MAJOR, devCount), NULL, + "pt_drv%d", devCount); + +# endif /* LINUX_26 */ +#endif /* CONFIG_DEVFS_FS */ ProcFsRegisterDevice( PtDrvDevices[i] ); devCount++; } else { @@ -1645,6 +1664,11 @@ int init_module( void ) /* * if something went wrong, shutdown all... */ if( devCount == 0 ) { +#if !defined (CONFIG_DEVFS_FS) && defined (LINUX_26) +out_devfs: + class_destroy(ptdrv_class); +#endif + #if (defined(CONFIG_DEVFS_FS) && !defined(DEVFS_26_STYLE)) devfs_unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME ); #else @@ -1700,7 +1724,11 @@ void cleanup_module( void ) # else devfs_remove("scanner/pt_drv%d", i); # endif -#endif +#else +# ifdef LINUX_26 + class_device_destroy(ptdrv_class, MKDEV(_PTDRV_MAJOR, i)); +# endif /* LINUX_26 */ +#endif /* CONFIG_DEVFS_FS */ ptdrvShutdown( ps ); ProcFsUnregisterDevice( ps ); } @@ -1713,6 +1741,10 @@ void cleanup_module( void ) #endif ProcFsShutdown(); +#if !defined (CONFIG_DEVFS_FS) && defined (LINUX_26) + class_destroy(ptdrv_class); +#endif + DBG( DBG_HIGH, "pt_drv: cleanup done.\n" ); DBG( DBG_HIGH, "*********************************************\n" ); } diff --git a/backend/plustek-pp_sysdep.h b/backend/plustek-pp_sysdep.h index 6a0d3ce7e..3165dfe67 100644 --- a/backend/plustek-pp_sysdep.h +++ b/backend/plustek-pp_sysdep.h @@ -13,7 +13,7 @@ * 0.42 - added _GET_TIME * - added LINUX_26 for new kernel * - added _MINOR - * 0.43 - no changes + * 0.43 - added class functions * . *
* This file is part of the SANE package. @@ -59,7 +59,7 @@ #define _SYSDEP_H_ #ifndef LINUX_VERSION_CODE -# include +# include #endif #ifndef VERSION_CODE @@ -79,6 +79,7 @@ #else # define LINUX_24 # define LINUX_26 +# include #endif #include /* used later in this header */ @@ -302,6 +303,30 @@ # define _MINOR(p) minor(p->i_rdev) #endif +/* Basic class macros */ +#ifdef LINUX_26 +#if LINUX_VERSION_CODE >= VERSION_CODE(2,6,15) + +typedef struct class class_t; +#define CLASS_DEVICE_CREATE(cls, devt, device, fmt, arg...) class_device_create(cls, NULL, devt, device, fmt, ## arg) + +#else /* LINUX 2.6.0 - 2.6.14 */ + +#if LINUX_VERSION_CODE >= VERSION_CODE(2,6,13) /* LINUX 2.6.13 - 2.6.14 */ +typedef struct class class_t; +#define CLASS_DEVICE_CREATE class_device_create + +#else /* LINUX 2.6.0 - 2.6.12, class_simple */ + +typedef struct class_simple class_t; +#define CLASS_DEVICE_CREATE class_simple_device_add +#define class_create class_simple_create +#define class_destroy class_simple_destroy +#define class_device_destroy(a, b) class_simple_device_remove(b) + +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) */ +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) */ +#endif #endif /* _SYSDEP_H_ */