diff -ruN backend-clean/plustek_driver/Makefile backend/plustek_driver/Makefile
--- backend-clean/plustek_driver/Makefile	2001-12-02 14:11:19.000000000 +0100
+++ backend/plustek_driver/Makefile	2003-08-10 10:38:57.000000000 +0200
@@ -1,253 +1,18 @@
-# Makefile for the plustek scanner driver
-#
-###############################################################################
-#
-# define the directories
-#
-HOME_DIR := .
-SRC_DIR  := $(HOME_DIR)/src
-INC_DIR  := $(HOME_DIR)/h
-OBJ_DIR  := $(HOME_DIR)/obj
-DOC_DIR  := $(HOME_DIR)/doc
-BACKEND  := $(HOME_DIR)/..
-
-#
-# define the used tools
-#
-MD  = mkdir -p
-CC  = gcc
-TAR = tar
-REF = cxref
-
-#
-# Comment/uncomment the following line to disable/enable debugging
-# can also be set by commandline parameter: make all DEBUG=y
-#
-#DEBUG = y
-
-#
-# common compiler options
-#
-OPT = -fomit-frame-pointer -D_PTDRV_V1=$(VERSION1) \
--D_PTDRV_V0=$(VERSION0) -D_PTDRV_BUILD=$(BUILD)
-
-#
-# cxref options
-#
-REFOPT = -xref-all -index-all -html32
-
-#
-# Comment out if you are not running SMP. Someone take this out of here
-# when the SMP stuff gets moved out of the kernel Makefile.
-# SMP = 1
-# SMP_PROF = 1
-
-#
-# add the following to get assembly listing
-# -Wa,-alh,-L -g 
-
-#
-#
-#
-ifeq ($(LINUXVERSION),)
- LINUXVERSION = $(shell uname -r)
-endif
-VERSION0 = $(shell cat VERSION0)
-VERSION1 = $(shell cat VERSION1)
-BUILD    = $(shell cat BUILD)
-
-# Change it here or specify it on the "make" commandline
-ifeq ($(HEADER_PATH),)
-MACHTYPE = $(shell env | grep debian-linux | wc -l | sed 's/ //g')
-ifeq ($(MACHTYPE),1)
-#  debian
-  HEADER_PATH = /usr/src/kernel-headers-$(LINUXVERSION)/include
-else
-#  redhat, slackware
-  HEADER_PATH = /usr/src/linux/include
-endif
-#   HEADER_PATH = /usr/include
-endif
-
-ifeq ($(DEBUG),y)
-  DEBFLAGS = -O -g -DDEBUG # "-O" is needed to expand inlines
-else
-  DEBFLAGS = -O2
-endif
-
-#
-# the new style reference
-#
-K24_HEADER_PATH = /lib/modules/$(LINUXVERSION)/build/include
-
-#
-# try to autodetect if we can use the new style header include references
-#
-KERNEL_HEADERS = $(shell if test -d $(K24_HEADER_PATH); then \
-							echo $(K24_HEADER_PATH); 		 \
-				 	     else 								 \
-							echo $(HEADER_PATH); 			 \
-					     fi; )
-
-#
-# seems to be necessary for kernels 2.4.x
-#
-MODVERFILE = $(shell if [ -e $(KERNEL_HEADERS)/linux/modversions.h ]; then \
-						echo $(KERNEL_HEADERS)/linux/modversions.h ;	   \
-					 else											       \
-						echo $(KERNEL_HEADERS)/linux/modsetver.h ;		   \
-					 fi )
-
-MODFLAGS = -DMODULE
-
-#
-# set MODVERSIONS if the kernel uses it
-#
-VERSUSED = $(shell grep 'define CONFIG_MODVERSIONS' \
-                   $(KERNEL_HEADERS)/linux/autoconf.h | wc -l | sed 's/ //g')
-ifeq ($(VERSUSED),1)
-  MODFLAGS += -DMODVERSIONS -include $(MODVERFILE)
-endif
-
-
-
-WARNFLAGS = -Wall -Wstrict-prototypes
-CFLAGS    = $(WARNFLAGS) $(OPT) -D__KERNEL__ -I$(KERNEL_HEADERS) -I$(INC_DIR) -I$(BACKEND) $(DEBFLAGS) $(MODFLAGS)
-MODLIB    = /lib/modules/$(LINUXVERSION)
-
-ifdef SMP
-CFLAGS += -D__SMP__
-
-ifdef SMP_PROF
-CFLAGS += -D__SMP_PROF__
-endif
-endif
-
-TARGET = pt_drv
-
-OBJ  = $(TARGET).o
-NAMES := dac detect genericio image map misc models io procfs
-NAMES := $(NAMES) motor p9636 ptdrv scale tpa p48xx p12 p12ccd
-SRCS  := $(addprefix $(SRC_DIR)/, $(NAMES))
-SRCS  := $(addsuffix .c, $(SRCS))
-OBJS  := $(addprefix $(OBJ_DIR)/, $(NAMES))
-OBJS  := $(addsuffix .o, $(OBJS))
-INCS  := scan dbg types scandata procs hwdefs sysdep
-INCS  := $(addsuffix .h, $(INCS))
-HDRS  = $(addprefix $(INC_DIR)/plustek_, $(INCS))
-
-#
-# the header files we need from the backend
-#
-BACKINCS := plustek-share.h
-BACKINCS := $(addprefix $(BACKEND)/, $(BACKINCS))
-
-group = "root"
-mode  = "644"
-
-
-info:
-	@clear
-	@echo "Makefile to create the Plustek-Scanner kernel-module:"
-	@echo "all          ... builds the module"
-	@echo "all DEBUG=y  ... builds the module with debug-messages enabled"
-	@echo "clean        ... cleans up the show"
-	@echo "install      ... installs the module to the library path"
-	@echo "uninstall    ... removes the module from the library path"
-	@echo "load         ... tries to load the module and creates device nodes"
-	@echo "unload       ... unloads the module"
-
-
-all: .depend chkdir $(TARGET).o
-
-#
-# create object directory
-#
-.PHONY : chkdir
-chkdir:
-	@-$(MD) $(OBJ_DIR)
-	@-$(MD) $(DOC_DIR)
-
-$(TARGET).o: $(OBJS)
-	$(LD) -r $^ -o $@
-
-$(OBJS): Makefile $(HDRS) $(BACKINCS)
-
-$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
-	$(CC) $(CFLAGS) -c $< -o $@
-
-$(OBJ_DIR)/ptdrv.o: VERSION1 VERSION0
-
-#
-# copy the driver to the modules directory
-#
-install:
-	mkdir -p /lib/modules/$(LINUXVERSION)/misc
-	install -c -m $(mode) $(TARGET).o /lib/modules/$(LINUXVERSION)/misc
-	/sbin/depmod -a
-
-#
-#
-#
-uninstall:
-	rm -f /lib/modules/$(LINUXVERSION)/misc/$(TARGET).o
-
-#
-# use modprobe to load the driver, remember to set the
-# parameter in /etc/conf.modules (see INSTALL for more details)
-#
-load:   /lib/modules/$(LINUXVERSION)/misc/$(TARGET).o
-# invoke modprobe with all arguments we got
-	/sbin/modprobe $(TARGET) || exit 1
-
-# Remove stale nodes and replace them, then give gid and perms
-	rm -f /dev/$(TARGET)*
-
-# when using the devfs support, we check the /dev/scanner entries
-# and only create links to the devfs nodes
-# at least we create one link
-	@if [ -e /dev/scanner/$(TARGET)* ]; then 				\
-		ln -s /dev/scanner/$(TARGET)0 /dev/$(TARGET);		\
-		for name in `ls /dev/scanner | grep $(TARGET)`; do	\
-			ln -s /dev/scanner/$$name /dev/$$name ;     	\
-		done												\
-	else                      								\
-		mknod /dev/$(TARGET) c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0;  \
-		mknod /dev/$(TARGET)0 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0;	\
-		mknod /dev/$(TARGET)1 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 1;	\
-		mknod /dev/$(TARGET)2 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 2; \
-		mknod /dev/$(TARGET)3 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 3;	\
-																							\
-		chgrp $(group) /dev/$(TARGET)*;	\
-		chmod $(mode)  /dev/$(TARGET)*;	\
-	fi
-
-#
-# unload the driver
-#
-unload:
-	/sbin/modprobe -r $(TARGET) || exit 1
-
-# Remove stale nodes
-	rm -f /dev/$(TARGET)*
-
-#
-# create reference docu
-#
-doc: chkdir
-	$(REF) $(REFOPT) $(INC_DIR)/*.h $(SRC_DIR)/*.c $(BACKEND)/plustek-share.h \
-    -D__KERNEL__ -I$(KERNEL_HEADERS) -I$(INC_DIR) -I$(BACKEND) $(MODFLAGS) \
-    -D_PTDRV_V1=$(VERSION1) -D_PTDRV_V0=$(VERSION0) -D_PTDRV_BUILD=$(BUILD) -O$(DOC_DIR)
-
-clean:
-	@-rm -f $(OBJ_DIR)/*.o .depend depend dep $(OBJ) $(REF).* *.html
-	@-rm -rf $(OBJ_DIR)
-	@-rm -rf $(DOC_DIR)
-
-depend .depend dep:
-	$(CC) $(CFLAGS) -M $(SRC_DIR)/*.c > $@
-
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
-
+    ifneq ($(KERNELRELEASE),)
+    VERSION0 := $(shell cat $(PWD)/VERSION0)
+    VERSION1 := $(shell cat $(PWD)/VERSION1)
+    BUILD    := $(shell cat $(PWD)/BUILD)
+    EXTRA_CFLAGS += -I$(PWD)/h -I$(PWD)/.. -D__KERNEL__ -D_PTDRV_V1=$(VERSION1) -D_PTDRV_V0=$(VERSION0) -D_PTDRV_BUILD=$(BUILD)
+    pt_drv-objs := src/dac.o src/detect.o src/genericio.o src/image.o src/map.o
+    pt_drv-objs += src/misc.o src/models.o src/io.o src/procfs.o src/motor.o
+    pt_drv-objs += src/p9636.o src/ptdrv.o src/scale.o src/tpa.o src/p48xx.o
+    pt_drv-objs += src/p12.o src/p12ccd.o
+    obj-m	:= pt_drv.o
+
+    else
+    KDIR	:= /lib/modules/$(shell uname -r)/build
+    PWD		:= $(shell pwd)
+
+    default:
+	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
+    endif
diff -ruN backend-clean/plustek_driver/Makefile.old backend/plustek_driver/Makefile.old
--- backend-clean/plustek_driver/Makefile.old	1970-01-01 01:00:00.000000000 +0100
+++ backend/plustek_driver/Makefile.old	2001-12-02 14:11:19.000000000 +0100
@@ -0,0 +1,253 @@
+# Makefile for the plustek scanner driver
+#
+###############################################################################
+#
+# define the directories
+#
+HOME_DIR := .
+SRC_DIR  := $(HOME_DIR)/src
+INC_DIR  := $(HOME_DIR)/h
+OBJ_DIR  := $(HOME_DIR)/obj
+DOC_DIR  := $(HOME_DIR)/doc
+BACKEND  := $(HOME_DIR)/..
+
+#
+# define the used tools
+#
+MD  = mkdir -p
+CC  = gcc
+TAR = tar
+REF = cxref
+
+#
+# Comment/uncomment the following line to disable/enable debugging
+# can also be set by commandline parameter: make all DEBUG=y
+#
+#DEBUG = y
+
+#
+# common compiler options
+#
+OPT = -fomit-frame-pointer -D_PTDRV_V1=$(VERSION1) \
+-D_PTDRV_V0=$(VERSION0) -D_PTDRV_BUILD=$(BUILD)
+
+#
+# cxref options
+#
+REFOPT = -xref-all -index-all -html32
+
+#
+# Comment out if you are not running SMP. Someone take this out of here
+# when the SMP stuff gets moved out of the kernel Makefile.
+# SMP = 1
+# SMP_PROF = 1
+
+#
+# add the following to get assembly listing
+# -Wa,-alh,-L -g 
+
+#
+#
+#
+ifeq ($(LINUXVERSION),)
+ LINUXVERSION = $(shell uname -r)
+endif
+VERSION0 = $(shell cat VERSION0)
+VERSION1 = $(shell cat VERSION1)
+BUILD    = $(shell cat BUILD)
+
+# Change it here or specify it on the "make" commandline
+ifeq ($(HEADER_PATH),)
+MACHTYPE = $(shell env | grep debian-linux | wc -l | sed 's/ //g')
+ifeq ($(MACHTYPE),1)
+#  debian
+  HEADER_PATH = /usr/src/kernel-headers-$(LINUXVERSION)/include
+else
+#  redhat, slackware
+  HEADER_PATH = /usr/src/linux/include
+endif
+#   HEADER_PATH = /usr/include
+endif
+
+ifeq ($(DEBUG),y)
+  DEBFLAGS = -O -g -DDEBUG # "-O" is needed to expand inlines
+else
+  DEBFLAGS = -O2
+endif
+
+#
+# the new style reference
+#
+K24_HEADER_PATH = /lib/modules/$(LINUXVERSION)/build/include
+
+#
+# try to autodetect if we can use the new style header include references
+#
+KERNEL_HEADERS = $(shell if test -d $(K24_HEADER_PATH); then \
+							echo $(K24_HEADER_PATH); 		 \
+				 	     else 								 \
+							echo $(HEADER_PATH); 			 \
+					     fi; )
+
+#
+# seems to be necessary for kernels 2.4.x
+#
+MODVERFILE = $(shell if [ -e $(KERNEL_HEADERS)/linux/modversions.h ]; then \
+						echo $(KERNEL_HEADERS)/linux/modversions.h ;	   \
+					 else											       \
+						echo $(KERNEL_HEADERS)/linux/modsetver.h ;		   \
+					 fi )
+
+MODFLAGS = -DMODULE
+
+#
+# set MODVERSIONS if the kernel uses it
+#
+VERSUSED = $(shell grep 'define CONFIG_MODVERSIONS' \
+                   $(KERNEL_HEADERS)/linux/autoconf.h | wc -l | sed 's/ //g')
+ifeq ($(VERSUSED),1)
+  MODFLAGS += -DMODVERSIONS -include $(MODVERFILE)
+endif
+
+
+
+WARNFLAGS = -Wall -Wstrict-prototypes
+CFLAGS    = $(WARNFLAGS) $(OPT) -D__KERNEL__ -I$(KERNEL_HEADERS) -I$(INC_DIR) -I$(BACKEND) $(DEBFLAGS) $(MODFLAGS)
+MODLIB    = /lib/modules/$(LINUXVERSION)
+
+ifdef SMP
+CFLAGS += -D__SMP__
+
+ifdef SMP_PROF
+CFLAGS += -D__SMP_PROF__
+endif
+endif
+
+TARGET = pt_drv
+
+OBJ  = $(TARGET).o
+NAMES := dac detect genericio image map misc models io procfs
+NAMES := $(NAMES) motor p9636 ptdrv scale tpa p48xx p12 p12ccd
+SRCS  := $(addprefix $(SRC_DIR)/, $(NAMES))
+SRCS  := $(addsuffix .c, $(SRCS))
+OBJS  := $(addprefix $(OBJ_DIR)/, $(NAMES))
+OBJS  := $(addsuffix .o, $(OBJS))
+INCS  := scan dbg types scandata procs hwdefs sysdep
+INCS  := $(addsuffix .h, $(INCS))
+HDRS  = $(addprefix $(INC_DIR)/plustek_, $(INCS))
+
+#
+# the header files we need from the backend
+#
+BACKINCS := plustek-share.h
+BACKINCS := $(addprefix $(BACKEND)/, $(BACKINCS))
+
+group = "root"
+mode  = "644"
+
+
+info:
+	@clear
+	@echo "Makefile to create the Plustek-Scanner kernel-module:"
+	@echo "all          ... builds the module"
+	@echo "all DEBUG=y  ... builds the module with debug-messages enabled"
+	@echo "clean        ... cleans up the show"
+	@echo "install      ... installs the module to the library path"
+	@echo "uninstall    ... removes the module from the library path"
+	@echo "load         ... tries to load the module and creates device nodes"
+	@echo "unload       ... unloads the module"
+
+
+all: .depend chkdir $(TARGET).o
+
+#
+# create object directory
+#
+.PHONY : chkdir
+chkdir:
+	@-$(MD) $(OBJ_DIR)
+	@-$(MD) $(DOC_DIR)
+
+$(TARGET).o: $(OBJS)
+	$(LD) -r $^ -o $@
+
+$(OBJS): Makefile $(HDRS) $(BACKINCS)
+
+$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
+	$(CC) $(CFLAGS) -c $< -o $@
+
+$(OBJ_DIR)/ptdrv.o: VERSION1 VERSION0
+
+#
+# copy the driver to the modules directory
+#
+install:
+	mkdir -p /lib/modules/$(LINUXVERSION)/misc
+	install -c -m $(mode) $(TARGET).o /lib/modules/$(LINUXVERSION)/misc
+	/sbin/depmod -a
+
+#
+#
+#
+uninstall:
+	rm -f /lib/modules/$(LINUXVERSION)/misc/$(TARGET).o
+
+#
+# use modprobe to load the driver, remember to set the
+# parameter in /etc/conf.modules (see INSTALL for more details)
+#
+load:   /lib/modules/$(LINUXVERSION)/misc/$(TARGET).o
+# invoke modprobe with all arguments we got
+	/sbin/modprobe $(TARGET) || exit 1
+
+# Remove stale nodes and replace them, then give gid and perms
+	rm -f /dev/$(TARGET)*
+
+# when using the devfs support, we check the /dev/scanner entries
+# and only create links to the devfs nodes
+# at least we create one link
+	@if [ -e /dev/scanner/$(TARGET)* ]; then 				\
+		ln -s /dev/scanner/$(TARGET)0 /dev/$(TARGET);		\
+		for name in `ls /dev/scanner | grep $(TARGET)`; do	\
+			ln -s /dev/scanner/$$name /dev/$$name ;     	\
+		done												\
+	else                      								\
+		mknod /dev/$(TARGET) c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0;  \
+		mknod /dev/$(TARGET)0 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0;	\
+		mknod /dev/$(TARGET)1 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 1;	\
+		mknod /dev/$(TARGET)2 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 2; \
+		mknod /dev/$(TARGET)3 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 3;	\
+																							\
+		chgrp $(group) /dev/$(TARGET)*;	\
+		chmod $(mode)  /dev/$(TARGET)*;	\
+	fi
+
+#
+# unload the driver
+#
+unload:
+	/sbin/modprobe -r $(TARGET) || exit 1
+
+# Remove stale nodes
+	rm -f /dev/$(TARGET)*
+
+#
+# create reference docu
+#
+doc: chkdir
+	$(REF) $(REFOPT) $(INC_DIR)/*.h $(SRC_DIR)/*.c $(BACKEND)/plustek-share.h \
+    -D__KERNEL__ -I$(KERNEL_HEADERS) -I$(INC_DIR) -I$(BACKEND) $(MODFLAGS) \
+    -D_PTDRV_V1=$(VERSION1) -D_PTDRV_V0=$(VERSION0) -D_PTDRV_BUILD=$(BUILD) -O$(DOC_DIR)
+
+clean:
+	@-rm -f $(OBJ_DIR)/*.o .depend depend dep $(OBJ) $(REF).* *.html
+	@-rm -rf $(OBJ_DIR)
+	@-rm -rf $(DOC_DIR)
+
+depend .depend dep:
+	$(CC) $(CFLAGS) -M $(SRC_DIR)/*.c > $@
+
+ifeq (.depend,$(wildcard .depend))
+include .depend
+endif
+
diff -ruN backend-clean/plustek_driver/src/procfs.c backend/plustek_driver/src/procfs.c
--- backend-clean/plustek_driver/src/procfs.c	2002-03-25 22:04:14.000000000 +0100
+++ backend/plustek_driver/src/procfs.c	2003-08-10 11:09:07.000000000 +0200
@@ -310,8 +310,7 @@
 	int i;
 
 	DBG( DBG_HIGH, "pt_drv: destroy_proc_tree !\n" );
-
-	if( ps->procDir.entry ) {
+	if( ps && ps->procDir.entry ) {
 
 		if( ps->procDir.info )
 			destroy_proc_entry( ps->procDir.entry, &ps->procDir.info );
diff -ruN backend-clean/plustek_driver/src/ptdrv.c backend/plustek_driver/src/ptdrv.c
--- backend-clean/plustek_driver/src/ptdrv.c	2002-10-12 16:17:16.000000000 +0200
+++ backend/plustek_driver/src/ptdrv.c	2003-08-10 11:25:40.000000000 +0200
@@ -226,7 +226,7 @@
  */
 static pScanData get_pt_from_inode(struct inode *ip)
 {
-    int minor = MINOR(ip->i_rdev);
+    int minor = MINOR(kdev_t_to_nr(ip->i_rdev));
 
     /*
      * unit out of range
@@ -1548,8 +1548,8 @@
                                         DEVFS_SPECIAL_CHR, 0 );
             devfs_unregister( master );
 #endif
-			ptdrvShutdown( ps );
 			ProcFsUnregisterDevice( ps );
+			ptdrvShutdown( ps );
 		 }
 	}
 
@@ -1596,7 +1596,8 @@
     	return(-EBUSY);
 	}
 
-   	MOD_INC_USE_COUNT;
+	if (!try_module_get(THIS_MODULE))
+		return -EAGAIN;
    	ps->flags |= _PTDRV_OPEN;
 
     return _OK;
@@ -1616,7 +1617,7 @@
 		ptdrvClose( ps );
 
     	ps->flags &= ~_PTDRV_OPEN;
-    	MOD_DEC_USE_COUNT;
+	module_put(THIS_MODULE);
 	    CLOSERETURN(0);
 	} else {
 
diff -ruN backend-clean/plustek_driver/src/scale.c backend/plustek_driver/src/scale.c
--- backend-clean/plustek_driver/src/scale.c	2002-03-25 22:04:38.000000000 +0100
+++ backend/plustek_driver/src/scale.c	2003-08-10 09:34:54.000000000 +0200
@@ -131,4 +131,5 @@
 	}
 }
 
-/* END SCALE.C...............................................................*/
\ No newline at end of file
+/* END SCALE.C...............................................................*/
+
diff -ruN backend-clean/plustek_driver/src/tpa.c backend/plustek_driver/src/tpa.c
--- backend-clean/plustek_driver/src/tpa.c	2002-03-25 22:03:19.000000000 +0100
+++ backend/plustek_driver/src/tpa.c	2003-08-10 09:35:01.000000000 +0200
@@ -1148,4 +1148,5 @@
     ps->AsicReg.RD_Pixels = 5400;
 }
 
-/* END TPA.C ................................................................*/
\ No newline at end of file
+/* END TPA.C ................................................................*/
+
