new module: ati mouse driver

Todd Fries (tfries@umr.edu)
Wed, 14 Jun 1995 00:08:56 -0500 (CDT)


I have produced a patch that will enhance and modularize the atixlmouse.c
driver. Hopefully there will be a better way to change mouse.c in the
future (I vote for Jim Nance's makefile changes, personally)...but this
works for me.

I have also 'made' the ati mouse register it's ioports:
023c-023e : atixl
(exerp from my /proc/ioports)...

So far it works fine for me..maybe some 'experienced' hacker with an atixl
mouse would like to try this to verify it's usability.

Later,

-- 
Todd Fries...tfries@umr.edu

To apply the following patch, save, cd to linux/drivers/char, and apply... ('twas done using diff -ru oldfile.c newfile.c > diff)

-----------CUT HERE-----------

--- atixlmouse.c Tue Jun 13 15:32:47 1995 +++ atixlmouse.new.c Tue Jun 13 19:36:12 1995 @@ -9,10 +9,20 @@ * version 0.3 */ +#ifdef MODULE +#include <linux/module.h> +#include <linux/version.h> +char kernel_version[]=UTS_RELEASE; +#else +#define MOD_INC_USE_COUNT +#define MOD_DEC_USE_COUNT +#endif + #include <linux/kernel.h> #include <linux/sched.h> #include <linux/signal.h> #include <linux/errno.h> +#include <linux/ioport.h> #include <asm/io.h> #include <asm/segment.h> @@ -20,7 +30,7 @@ #include <asm/irq.h> #define ATIXL_MOUSE_IRQ 5 /* H/W interrupt # set up on ATIXL board */ -#define ATIXL_BUSMOUSE 3 /* Minor device # (mknod c 10 3 /dev/bm) */ +#define ATIXL_BUSMOUSE 3 /* Minor device # (mknod c 10 3 /dev/atibm) */ /* ATI XL Inport Busmouse Definitions */ @@ -171,7 +181,12 @@ release_mouse, }; +#ifdef MODULE + +int init_module(void) +#else unsigned long atixl_busmouse_init(unsigned long kmem_start) +#endif { unsigned char a,b,c; @@ -179,10 +194,14 @@ b = inb( ATIXL_MSE_SIGNATURE_PORT ); c = inb( ATIXL_MSE_SIGNATURE_PORT ); if (( a != b ) && ( a == c )) - printk("\nATI Inport "); + printk("ATI Inport "); else{ mouse.present = 0; +#ifdef MODULE + return -EIO; +#else return kmem_start; +#endif } outb(0x80, ATIXL_MSE_CONTROL_PORT); /* Reset the Inport device */ outb(0x07, ATIXL_MSE_CONTROL_PORT); /* Select Internal Register 7 */ @@ -193,6 +212,26 @@ mouse.buttons = mouse.latch_buttons = 0; mouse.dx = mouse.dy = 0; mouse.wait = NULL; - printk("Bus mouse detected and installed.\n"); + request_region(0x23c,3,"atixl"); + printk("Bus mouse at 0x23c,3 (irq = 5) detected and installed.\n"); +#ifdef MODULE +/* if (register_chrdev(10,"whatever",&atixl_busmouse_fops)); */ + + + return 0; +#else return kmem_start; +#endif } + +#ifdef MODULE +void cleanup_module(void) +{ + if(MOD_IN_USE) + printk("atixl: busy - remove delayed\n"); + else { + release_region(0x23c,3); + } +} + +#endif --- mouse.c Tue Jun 13 17:07:16 1995 +++ mouse.new.c Tue Jun 13 17:24:55 1995 @@ -14,6 +14,15 @@ * of the mouse drivers, as they are now completely independent. Linus. */ +#ifdef MODULE +#include <linux/module.h> +#include <linux/version.h> +char kernel_version[]=UTS_RELEASE; +#else +#define MOD_INC_USE_COUNT +#define MOD_DEC_USE_COUNT +#endif + #include <linux/fs.h> #include <linux/errno.h> #include <linux/mouse.h> @@ -60,6 +69,11 @@ file->f_op = &atixl_busmouse_fops; break; #endif +#ifdef MODULE + case ATIXL_BUSMOUSE_MINOR: + file->f_op = &atixl_busmouse_fops; + break; +#endif default: return -ENODEV; } @@ -78,8 +92,13 @@ NULL /* release */ }; +#ifdef MODULE +int init_module(void) +#else unsigned long mouse_init(unsigned long kmem_start) +#endif { +#ifndef MODULE #ifdef CONFIG_BUSMOUSE kmem_start = bus_mouse_init(kmem_start); #endif @@ -92,8 +111,23 @@ #ifdef CONFIG_ATIXL_BUSMOUSE kmem_start = atixl_busmouse_init(kmem_start); #endif +#endif /* ifndef MODULE */ + if (register_chrdev(MOUSE_MAJOR,"mouse",&mouse_fops)) printk("unable to get major %d for mouse devices\n", MOUSE_MAJOR); +#ifdef MODULE + return 0; +#else return kmem_start; +#endif } + +#ifdef MODULE +void cleanup_module(void) +{ + if(MOD_IN_USE) + printk("mouse: busy - remove delayed\n"); +} + +#endif --- Makefile Tue Jun 13 16:14:26 1995 +++ Makefile.new Tue Jun 13 17:25:32 1995 @@ -38,6 +38,8 @@ M = y OBJS := $(OBJS) atixlmouse.o SRCS := $(SRCS) atixlmouse.c +else +MODULES += atixlmouse.o endif ifdef CONFIG_BUSMOUSE @@ -77,6 +79,8 @@ ifdef M OBJS := $(OBJS) mouse.o SRCS := $(SRCS) mouse.c +else +MODULES += mouse.o endif ifdef CONFIG_SCC