This source file includes following definitions.
- mouse_open
- mouse_register
- mouse_deregister
- cleanup_module
- mouse_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include <linux/module.h>
23
24 #include <linux/fs.h>
25 #include <linux/errno.h>
26 #include <linux/mouse.h>
27 #include <linux/config.h>
28 #include <linux/kernel.h>
29 #include <linux/major.h>
30 #include <linux/malloc.h>
31
32
33
34
35 static struct mouse mouse_list = { 0, "head", NULL, &mouse_list, &mouse_list };
36
37 #ifndef MODULE
38 extern int bus_mouse_init(void);
39 extern int psaux_init(void);
40 extern int ms_bus_mouse_init(void);
41 extern int atixl_busmouse_init(void);
42 #endif
43
44 static int mouse_open(struct inode * inode, struct file * file)
45 {
46 int minor = MINOR(inode->i_rdev);
47 struct mouse *c = mouse_list.next;
48 file->f_op = NULL;
49
50 while (c != &mouse_list) {
51 if (c->minor == minor) {
52 file->f_op = c->fops;
53 break;
54 }
55 c = c->next;
56 }
57
58 if (file->f_op == NULL)
59 return -ENODEV;
60 return file->f_op->open(inode,file);
61 }
62
63 static struct file_operations mouse_fops = {
64 NULL,
65 NULL,
66 NULL,
67 NULL,
68 NULL,
69 NULL,
70 NULL,
71 mouse_open,
72 NULL
73 };
74
75 int mouse_register(struct mouse * mouse)
76 {
77 if (mouse->next || mouse->prev)
78 return -EBUSY;
79 MOD_INC_USE_COUNT;
80 mouse->next = &mouse_list;
81 mouse->prev = mouse_list.prev;
82 mouse->prev->next = mouse;
83 mouse->next->prev = mouse;
84 return 0;
85 }
86
87 int mouse_deregister(struct mouse * mouse)
88 {
89 if (!mouse->next || !mouse->prev)
90 return -EINVAL;
91 MOD_DEC_USE_COUNT;
92 mouse->prev->next = mouse->next;
93 mouse->next->prev = mouse->prev;
94 mouse->next = NULL;
95 mouse->prev = NULL;
96 return 0;
97 }
98
99 #ifdef MODULE
100
101 #define mouse_init init_module
102
103 void cleanup_module(void)
104 {
105 unregister_chrdev(MOUSE_MAJOR, "mouse");
106 }
107
108 #endif
109
110 static struct symbol_table mouse_syms = {
111
112 #include <linux/symtab_begin.h>
113 X(mouse_register),
114 X(mouse_deregister),
115 #include <linux/symtab_end.h>
116 };
117
118 int mouse_init(void)
119 {
120 #ifndef MODULE
121 #ifdef CONFIG_BUSMOUSE
122 bus_mouse_init();
123 #endif
124 #if defined CONFIG_PSMOUSE || defined CONFIG_82C710_MOUSE
125 psaux_init();
126 #endif
127 #ifdef CONFIG_MS_BUSMOUSE
128 ms_bus_mouse_init();
129 #endif
130 #ifdef CONFIG_ATIXL_BUSMOUSE
131 atixl_busmouse_init();
132 #endif
133 #ifdef CONFIG_SOFT_WATCHDOG
134 watchdog_init();
135 #endif
136 #endif
137 if (register_chrdev(MOUSE_MAJOR,"mouse",&mouse_fops)) {
138 printk("unable to get major %d for mouse devices\n",
139 MOUSE_MAJOR);
140 return -EIO;
141 }
142
143 if(register_symtab(&mouse_syms)!=0)
144 {
145 unregister_chrdev(MOUSE_MAJOR, "mouse");
146 return -EIO;
147 }
148 return 0;
149 }