ddrmat patches
Ed Anderson
nilbus at nilbus.com
Tue May 25 03:06:16 EDT 2004
Hello,
I fixed the problems with ddrmat not compiling on 2.6 after
parport_enumerate was removed from the kernel. ddrmat-0.10 would not
compile on 2.4 kernels because of differences in the input_dev struct.
Now, ddrmat should compile on both 2.4 and 2.6 kernels by simply typing
make. By default, it compiles for the kernel you are running, but this
can be overridden by specifying KERNEL_SOURCE and KERNEL_VERSION_NUMBER
on the command line when running make. Note that to build kernel modules
under 2.6, the kernel source must be fully configured and compiled.
Dance pads must be plugged in at the time the module is loaded but
afterward can be unplugged and plugged in freely.
If you have more than one parallel port, load the module with the
following options:
modprobe ddrmat gc=0,7 gc_2=1,7
Some of this information might be added to the README.
This module seems to work fine with devfs on 2.6 as long as the joydev
module is loaded/built into the kernel (which is required anyway).
Why does the README say not to use DevFS, especially in 2.6? Has it been
a source of problems in the past?
Enjoy the patches :)
Ed Anderson
Nilbus
-------------- next part --------------
--- ../orig_ddrmat-0.10/Makefile 2004-01-14 02:13:32.000000000 -0500
+++ Makefile 2004-05-25 02:24:52.128045880 -0400
@@ -1,2 +1,24 @@
obj-m := ddrmat.o
+PWD:= $(shell pwd)
+KERNEL_VERSION_NUMBER ?= $(shell uname -r)
+KERNEL_SOURCE ?= /lib/modules/$(shell uname -r)/build
+MODULE_PATH ?= $(DESTDIR)/lib/modules/$(KERNEL_VERSION_NUMBER)/kernel/drivers/char/joystick
+ifeq "$(shell echo $(KERNEL_VERSION_NUMBER)|cut -b 1-3)" "2.6"
+EXT:=ko
+else
+EXT:=o
+endif
+Default:
+ifeq "$(shell echo $(KERNEL_VERSION_NUMBER)|cut -b 1-3)" "2.6"
+ $(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(PWD) modules
+else
+ $(CC) -D__KERNEL__ -I$(KERNEL_SOURCE)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -falign-functions=4 -DMODULE -DMODVERSIONS -include $(KERNEL_SOURCE)/include/linux/modversions.h -c ddrmat.c
+endif
+
+install:
+ install -D -m 644 ddrmat.$(EXT) $(MODULE_PATH)/ddrmat.$(EXT)
+ @echo "Be sure to run depmod -ae."
+
+clean:
+ rm -rf *~ *.o *.ko *.mod.* .*.cmd .tmp*
-------------- next part --------------
--- test/ddrmat.c 2004-05-25 01:35:52.739900800 -0400
+++ ddrmat.c 2004-05-25 01:43:55.890450752 -0400
@@ -9,6 +9,8 @@
*
* Updated by Tom Grimes on 13-January 2004 using
* gamecon.c v1.22 for compilation in Linux 2.6
+ * Updated by Ed Anderson on 25 May 2004
+ * for compatibility with both kernel ver 2.4 and 2.6.
*/
/*
@@ -227,14 +229,22 @@
{
struct gc *gc;
struct parport *pp;
- int i, j, psx;
+ int j, psx, i=0;
unsigned char data[32];
if (config[0] < 0)
return NULL;
+ /* parport_enumerate was deprecated and does not work in the 2.6 kern
for (pp = parport_enumerate(); pp && (config[0] > 0); pp = pp->next)
config[0]--;
+ */
+ pp = parport_find_number(0);
+ while (pp && config[0] > 0) {
+ config[0]--;
+ pp = parport_find_number(++i);
+ }
+
if (!pp) {
printk(KERN_ERR "ddrmat.c: no such parport\n");
@@ -325,18 +335,21 @@
}
break;
}
-// gc->dev[i].name = gc_names[config[i + 1]];
-// gc->dev[i].idbus = BUS_PARPORT;
-// gc->dev[i].idvendor = 0x0001;
-// gc->dev[i].idproduct = config[i + 1];
-// gc->dev[i].idversion = 0x0100;
-
- gc->dev[i].name = gc_names[config[i + 1]];
-// gc->dev[i].phys = gc->phys[i];
+ gc->dev[i].name = gc_names[config[i + 1]];
+#ifndef init_input_dev
+//2.4 kernel
+ gc->dev[i].idbus = BUS_PARPORT;
+ gc->dev[i].idvendor = 0x0001;
+ gc->dev[i].idproduct = config[i + 1];
+ gc->dev[i].idversion = 0x0100;
+#else
+//2.6 kernel
+ //gc->dev[i].phys = gc->phys[i];
gc->dev[i].id.bustype = BUS_PARPORT;
gc->dev[i].id.vendor = 0x0001;
gc->dev[i].id.product = config[i + 1];
gc->dev[i].id.version = 0x0100;
+#endif
}
parport_release(gc->pd);
More information about the pyddr-discuss
mailing list