plustek@linuxhacker.org
Hello,
I have sent this before, but I don't know if it has been received. so
here is my patch again.
Gordon.
--- backends.orig/plustek_driver/src/ptdrv.c Wed Oct 18 00:41:46 2000
+++ backends/plustek_driver/src/ptdrv.c Wed Dec 27 20:44:19 2000
@@ -40,6 +40,7 @@
* and some definitions to plustek_scan.h
* moved MODELSTR to misc.c
* output of the error-code after initialization
+ * 0.37.1 - Add dev fs support for linux 2.4.0
*
*.............................................................................
*
@@ -61,6 +62,10 @@
#include <linux/module.h>
#endif
+#ifdef CONFIG_DEVFS_FS
+#include <linux/devfs_fs_kernel.h>
+#endif
+
#include "plustek_scan.h"
#include "debug.h"
#include <assert.h>
@@ -124,6 +129,10 @@
MODULE_PARM_DESC(mov, "Modell-override switch");
#endif
+#ifdef CONFIG_DEVFS_FS
+static devfs_handle_t devfs_handle = NULL;
+#endif
+
/*
* the module interface
*/
@@ -136,9 +145,9 @@
static int pt_drv_write( struct inode*, struct file*, const char*, int );
#else
static ssize_t pt_drv_read ( struct file *file,
- char *buffer, size_t count, loff_t *);
+ char *buffer, size_t count, loff_t *);
static ssize_t pt_drv_write( struct file *file,
- const char *buffer, size_t tmp,loff_t *count);
+ const char *buffer, size_t tmp,loff_t *count);
#endif
/*
@@ -1424,20 +1433,28 @@
UInt i;
int retval = _OK;
int result = _OK;
+#ifdef CONFIG_DEVFS_FS
+ char controlname[24];
+#endif
DBG( DBG_HIGH, "*********************************************\n" );
DBG( DBG_HIGH, "pt_drv: init_module()\n" );
+#ifdef CONFIG_DEVFS_FS
+ devfs_handle = devfs_mk_dir(NULL, "scanner", NULL);
+ if (devfs_register_chrdev(_PTDRV_MAJOR, _DRV_NAME, &pt_drv_fops)) {
+#else
if (register_chrdev(_PTDRV_MAJOR, _DRV_NAME, &pt_drv_fops)) {
+#endif
_PRINT(KERN_INFO "pt_drv: unable to get major %d for pt_drv devices\n",
- _PTDRV_MAJOR);
+ _PTDRV_MAJOR);
return -EIO;
}
#ifdef __KERNEL__
printk( KERN_INFO "pt_drv : driver version %d.%d-%d\n",
- _PTDRV_V1, _PTDRV_V0, _PTDRV_BUILD );
+ _PTDRV_V1, _PTDRV_V0, _PTDRV_BUILD );
#endif
/* register for proc_fs */
@@ -1451,9 +1468,15 @@
if( 0 != port[i] ) {
result = ptdrvInit( i );
-
if ( _OK == result ) {
- PtDrvDevices[i]->flags |= _PTDRV_INITALIZED;
+ PtDrvDevices[i]->flags |= _PTDRV_INITALIZED;
+#ifdef CONFIG_DEVFS_FS
+ sprintf(controlname, "scanner/pt_drv%d", devCount);
+ devfs_register(NULL, controlname,
+ DEVFS_FL_DEFAULT, _PTDRV_MAJOR, 0,
+ S_IFCHR | S_IRUGO | S_IWUGO | S_IFCHR,
+ &pt_drv_fops, NULL);
+#endif
ProcFsRegisterDevice( PtDrvDevices[i] );
devCount++;
} else {
@@ -1468,8 +1491,11 @@
* if something went wrong, shutdown all...
*/
if ( devCount == 0 ) {
-
+#ifdef CONFIG_DEVFS_FS
+ devfs_unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME );
+#else
unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME );
+#endif
ProcFsShutdown();
#ifdef __KERNEL__
@@ -1494,21 +1520,35 @@
{
UInt i;
pScanData ps;
+#ifdef CONFIG_DEVFS_FS
+ char controlname[24];
+ devfs_handle_t master;
+#endif
DBG( DBG_HIGH, "pt_drv: cleanup_module()\n" );
for ( i = 0; i < _MAX_PTDEVS; i++ ) {
ps = PtDrvDevices[i];
- PtDrvDevices[i] = NULL;
+ PtDrvDevices[i] = NULL;
- if ( NULL != ps ) {
+ if ( NULL != ps ) {
+#ifdef CONFIG_DEVFS_FS
+ sprintf(controlname, "scanner/pt_drv%d", i);
+ master = devfs_find_handle(NULL,controlname, 0, 0,
+ DEVFS_SPECIAL_CHR, 0);
+ devfs_unregister(master);
+#endif
ptdrvShutdown( ps );
ProcFsUnregisterDevice( ps );
}
}
+#ifdef CONFIG_DEVFS_FS
+ devfs_unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME );
+#else
unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME );
+#endif
ProcFsShutdown();
DBG( DBG_HIGH, "pt_drv: cleanup done.\n" );