Re: [BUG] Linux v1.3.32 does not compile mouse modules ...

Linus Torvalds (Linus.Torvalds@cs.helsinki.fi)
Mon, 9 Oct 1995 09:24:54 +0200


Mister Linux: "[BUG] Linux v1.3.32 does not compile mouse modules ..." (Oct 8, 22:58):
>
> Hi Linus,
>
> it's me again. Just patched my kernel up to pl32 to fix that SCSI tape
> problem and decided to try a more modularized kernel this time.
>
> However the module compilation stalled at line 139 of mouse.c
> The problem is that 'mouse_data' seems not to be defined anywhere.

How about this patch?

Linus

----------
diff -u --recursive --new-file v1.3.32/linux/drivers/char/mouse.c linux/drivers/char/mouse.c
--- v1.3.32/linux/drivers/char/mouse.c Fri Sep 15 11:13:00 1995
+++ linux/drivers/char/mouse.c Sat Oct 7 14:01:57 1995
@@ -79,6 +79,7 @@
{
if (mouse->next || mouse->prev)
return -EBUSY;
+ MOD_INC_USE_COUNT;
mouse->next = &mouse_list;
mouse->prev = mouse_list.prev;
mouse->prev->next = mouse;
@@ -90,6 +91,7 @@
{
if (!mouse->next || !mouse->prev)
return -EINVAL;
+ MOD_DEC_USE_COUNT;
mouse->prev->next = mouse->next;
mouse->next->prev = mouse->prev;
mouse->next = NULL;
@@ -136,16 +138,10 @@
#ifdef MODULE
void cleanup_module(void)
{
- mouse_data *c = mouse_list, *n;
if (MOD_IN_USE) {
printk("mouse: in use, remove delayed\n");
return;
}
unregister_chrdev(MOUSE_MAJOR, "mouse");
- while (c) {
- n = c->next;
- kfree(c);
- c = n;
- }
}
#endif
diff -u --recursive --new-file v1.3.32/linux/drivers/char/psaux.c linux/drivers/char/psaux.c
--- v1.3.32/linux/drivers/char/psaux.c Wed Oct 4 14:14:30 1995
+++ linux/drivers/char/psaux.c Mon Oct 9 09:08:08 1995
@@ -123,7 +123,7 @@

static struct aux_queue *queue;
static int aux_ready = 0;
-static int aux_busy = 0;
+static int aux_count = 0;
static int aux_present = 0;
static int poll_aux_status(void);
static int poll_aux_status_nosleep(void);
@@ -131,7 +131,7 @@

#ifdef CONFIG_82C710_MOUSE
static int qp_present = 0;
-static int qp_busy = 0;
+static int qp_count = 0;
static int qp_data = QP_DATA;
static int qp_status = QP_STATUS;

@@ -260,13 +260,15 @@

static void release_aux(struct inode * inode, struct file * file)
{
+ fasync_aux(inode, file, 0);
+ if (--aux_count)
+ return;
aux_write_cmd(AUX_INTS_OFF); /* disable controller ints */
poll_aux_status();
outb_p(AUX_DISABLE,AUX_COMMAND); /* Disable Aux device */
poll_aux_status();
free_irq(AUX_IRQ);
- fasync_aux(inode, file, 0);
- aux_busy = 0;
+ MOD_DEC_USE_COUNT;
}

#ifdef CONFIG_82C710_MOUSE
@@ -274,6 +276,9 @@
{
unsigned char status;

+ fasync_aux(inode, file, 0);
+ if (--qp_count)
+ return;
if (!poll_qp_status())
printk("Warning: Mouse device busy in release_qp()\n");
status = inb_p(qp_status);
@@ -281,8 +286,7 @@
if (!poll_qp_status())
printk("Warning: Mouse device busy in release_qp()\n");
free_irq(QP_IRQ);
- fasync_aux(inode, file, 0);
- qp_busy = 0;
+ MOD_DEC_USE_COUNT;
}
#endif

@@ -304,15 +308,16 @@
static int open_aux(struct inode * inode, struct file * file)
{
if (!aux_present)
- return -EINVAL;
- if (aux_busy)
+ return -ENODEV;
+ if (aux_count++)
+ return 0;
+ if (!poll_aux_status()) {
+ aux_count--;
return -EBUSY;
- if (!poll_aux_status())
- return -EBUSY;
- aux_busy = 1;
+ }
queue->head = queue->tail = 0; /* Flush input queue */
if (request_irq(AUX_IRQ, aux_interrupt, 0, "PS/2 Mouse")) {
- aux_busy = 0;
+ aux_count--;
return -EBUSY;
}
poll_aux_status();
@@ -321,14 +326,14 @@
aux_write_cmd(AUX_INTS_ON); /* enable controller ints */
poll_aux_status();
aux_ready = 0;
+ MOD_INC_USE_COUNT;
return 0;
}

#ifdef CONFIG_82C710_MOUSE
/*
* Install interrupt handler.
- * Enable the device, enable interrupts. Set qp_busy
- * (allow only one opener at a time.)
+ * Enable the device, enable interrupts.
*/

static int open_qp(struct inode * inode, struct file * file)
@@ -338,13 +343,13 @@
if (!qp_present)
return -EINVAL;

- if (qp_busy)
- return -EBUSY;
+ if (qp_count++)
+ return 0;

- if (request_irq(QP_IRQ, qp_interrupt, 0, "PS/2 Mouse"))
+ if (request_irq(QP_IRQ, qp_interrupt, 0, "PS/2 Mouse")) {
+ qp_count--;
return -EBUSY;
-
- qp_busy = 1;
+ }

status = inb_p(qp_status);
status |= (QP_ENABLE|QP_RESET);
@@ -358,11 +363,15 @@

while (!poll_qp_status()) {
printk("Error: Mouse device busy in open_qp()\n");
+ qp_count--;
+ status &= ~(QP_ENABLE|QP_INTS_ON);
+ outb_p(status, qp_status);
+ free_irq(QP_IRQ);
return -EBUSY;
}

outb_p(AUX_ENABLE_DEV, qp_data); /* Wake up mouse */
-
+ MOD_INC_USE_COUNT;
return 0;
}
#endif
----------