Yes (was: Re: Does anyone have a solution to the psaux / watchdog problem?)

Bjorn Ekwall (bj0rn@blox.se)
Tue, 19 Mar 1996 02:43:57 +0100 (MET)


Hi!

Here is a solution for mice and kerneld...

Bjorn

--- linux/drivers/char/mouse.c.org Tue Mar 19 01:34:28 1996
+++ linux/drivers/char/mouse.c Tue Mar 19 02:34:47 1996
@@ -17,8 +17,13 @@
*
* Fixed a failing symbol register to free the device registration
* Alan Cox <alan@lxorguk.ukuu.org.uk> 21-Jan-96
+ *
+ * Handling of mouse minor numbers for kerneld:
+ * Idea by Jacques Gelinas <jack@solucorp.qc.ca>,
+ * adapted by Bjorn Ekwall <bj0rn@blox.se>
*/

+#include <linux/config.h>
#include <linux/module.h>

#include <linux/fs.h>
@@ -28,6 +33,9 @@
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/malloc.h>
+#ifdef CONFIG_KERNELD
+#include <linux/kerneld.h>
+#endif

/*
* Head entry for the doubly linked mouse list
@@ -41,6 +49,26 @@
extern int atixl_busmouse_init(void);
#endif

+#ifndef WATCHDOG_MINOR
+#define WATCHDOG_MINOR 130
+#endif
+#ifndef TEMP_MINOR
+#define TEMP_MINOR 131
+#endif
+
+static struct {
+ int minor;
+ char *module;
+} mice[] = {
+ { BUSMOUSE_MINOR, "busmouse" },
+ { PSMOUSE_MINOR, "psaux" },
+ { MS_BUSMOUSE_MINOR, "msbusmouse" },
+ { ATIXL_BUSMOUSE_MINOR, "atixlmouse" },
+ { WATCHDOG_MINOR, "wdt" },
+ { TEMP_MINOR, "wdt" },
+ {-1, NULL} /* end of list */
+};
+
static int mouse_open(struct inode * inode, struct file * file)
{
int minor = MINOR(inode->i_rdev);
@@ -47,17 +75,29 @@
struct mouse *c = mouse_list.next;
file->f_op = NULL;

- while (c != &mouse_list) {
- if (c->minor == minor) {
- file->f_op = c->fops;
- break;
- }
+ while ((c != &mouse_list) && (c->minor != minor))
c = c->next;
+ if (c == &mouse_list) {
+#ifdef CONFIG_KERNELD
+ int i;
+ for (i = 0; mice[i].minor >= 0 && mice[i].minor != minor; ++i)
+ ;
+ if (mice[i].minor != -1) {
+ request_module(mice[i].module);
+ c = mouse_list.next;
+ while ((c != &mouse_list) && (c->minor != minor))
+ c = c->next;
+ }
+ if (c == &mouse_list)
+#else
+ return -ENODEV;
+#endif
}

- if (file->f_op == NULL)
+ if ((file->f_op = c->fops))
+ return file->f_op->open(inode,file);
+ else
return -ENODEV;
- return file->f_op->open(inode,file);
}

static struct file_operations mouse_fops = {