diff options
107 files changed, 4806 insertions, 2646 deletions
diff --git a/Documentation/block/ioprio.txt b/Documentation/block/ioprio.txt new file mode 100644 index 000000000000..96ccf681075e --- /dev/null +++ b/Documentation/block/ioprio.txt | |||
@@ -0,0 +1,176 @@ | |||
1 | Block io priorities | ||
2 | =================== | ||
3 | |||
4 | |||
5 | Intro | ||
6 | ----- | ||
7 | |||
8 | With the introduction of cfq v3 (aka cfq-ts or time sliced cfq), basic io | ||
9 | priorities is supported for reads on files. This enables users to io nice | ||
10 | processes or process groups, similar to what has been possible to cpu | ||
11 | scheduling for ages. This document mainly details the current possibilites | ||
12 | with cfq, other io schedulers do not support io priorities so far. | ||
13 | |||
14 | Scheduling classes | ||
15 | ------------------ | ||
16 | |||
17 | CFQ implements three generic scheduling classes that determine how io is | ||
18 | served for a process. | ||
19 | |||
20 | IOPRIO_CLASS_RT: This is the realtime io class. This scheduling class is given | ||
21 | higher priority than any other in the system, processes from this class are | ||
22 | given first access to the disk every time. Thus it needs to be used with some | ||
23 | care, one io RT process can starve the entire system. Within the RT class, | ||
24 | there are 8 levels of class data that determine exactly how much time this | ||
25 | process needs the disk for on each service. In the future this might change | ||
26 | to be more directly mappable to performance, by passing in a wanted data | ||
27 | rate instead. | ||
28 | |||
29 | IOPRIO_CLASS_BE: This is the best-effort scheduling class, which is the default | ||
30 | for any process that hasn't set a specific io priority. The class data | ||
31 | determines how much io bandwidth the process will get, it's directly mappable | ||
32 | to the cpu nice levels just more coarsely implemented. 0 is the highest | ||
33 | BE prio level, 7 is the lowest. The mapping between cpu nice level and io | ||
34 | nice level is determined as: io_nice = (cpu_nice + 20) / 5. | ||
35 | |||
36 | IOPRIO_CLASS_IDLE: This is the idle scheduling class, processes running at this | ||
37 | level only get io time when no one else needs the disk. The idle class has no | ||
38 | class data, since it doesn't really apply here. | ||
39 | |||
40 | Tools | ||
41 | ----- | ||
42 | |||
43 | See below for a sample ionice tool. Usage: | ||
44 | |||
45 | # ionice -c<class> -n<level> -p<pid> | ||
46 | |||
47 | If pid isn't given, the current process is assumed. IO priority settings | ||
48 | are inherited on fork, so you can use ionice to start the process at a given | ||
49 | level: | ||
50 | |||
51 | # ionice -c2 -n0 /bin/ls | ||
52 | |||
53 | will run ls at the best-effort scheduling class at the highest priority. | ||
54 | For a running process, you can give the pid instead: | ||
55 | |||
56 | # ionice -c1 -n2 -p100 | ||
57 | |||
58 | will change pid 100 to run at the realtime scheduling class, at priority 2. | ||
59 | |||
60 | ---> snip ionice.c tool <--- | ||
61 | |||
62 | #include <stdio.h> | ||
63 | #include <stdlib.h> | ||
64 | #include <errno.h> | ||
65 | #include <getopt.h> | ||
66 | #include <unistd.h> | ||
67 | #include <sys/ptrace.h> | ||
68 | #include <asm/unistd.h> | ||
69 | |||
70 | extern int sys_ioprio_set(int, int, int); | ||
71 | extern int sys_ioprio_get(int, int); | ||
72 | |||
73 | #if defined(__i386__) | ||
74 | #define __NR_ioprio_set 289 | ||
75 | #define __NR_ioprio_get 290 | ||
76 | #elif defined(__ppc__) | ||
77 | #define __NR_ioprio_set 273 | ||
78 | #define __NR_ioprio_get 274 | ||
79 | #elif defined(__x86_64__) | ||
80 | #define __NR_ioprio_set 251 | ||
81 | #define __NR_ioprio_get 252 | ||
82 | #elif defined(__ia64__) | ||
83 | #define __NR_ioprio_set 1274 | ||
84 | #define __NR_ioprio_get 1275 | ||
85 | #else | ||
86 | #error "Unsupported arch" | ||
87 | #endif | ||
88 | |||
89 | _syscall3(int, ioprio_set, int, which, int, who, int, ioprio); | ||
90 | _syscall2(int, ioprio_get, int, which, int, who); | ||
91 | |||
92 | enum { | ||
93 | IOPRIO_CLASS_NONE, | ||
94 | IOPRIO_CLASS_RT, | ||
95 | IOPRIO_CLASS_BE, | ||
96 | IOPRIO_CLASS_IDLE, | ||
97 | }; | ||
98 | |||
99 | enum { | ||
100 | IOPRIO_WHO_PROCESS = 1, | ||
101 | IOPRIO_WHO_PGRP, | ||
102 | IOPRIO_WHO_USER, | ||
103 | }; | ||
104 | |||
105 | #define IOPRIO_CLASS_SHIFT 13 | ||
106 | |||
107 | const char *to_prio[] = { "none", "realtime", "best-effort", "idle", }; | ||
108 | |||
109 | int main(int argc, char *argv[]) | ||
110 | { | ||
111 | int ioprio = 4, set = 0, ioprio_class = IOPRIO_CLASS_BE; | ||
112 | int c, pid = 0; | ||
113 | |||
114 | while ((c = getopt(argc, argv, "+n:c:p:")) != EOF) { | ||
115 | switch (c) { | ||
116 | case 'n': | ||
117 | ioprio = strtol(optarg, NULL, 10); | ||
118 | set = 1; | ||
119 | break; | ||
120 | case 'c': | ||
121 | ioprio_class = strtol(optarg, NULL, 10); | ||
122 | set = 1; | ||
123 | break; | ||
124 | case 'p': | ||
125 | pid = strtol(optarg, NULL, 10); | ||
126 | break; | ||
127 | } | ||
128 | } | ||
129 | |||
130 | switch (ioprio_class) { | ||
131 | case IOPRIO_CLASS_NONE: | ||
132 | ioprio_class = IOPRIO_CLASS_BE; | ||
133 | break; | ||
134 | case IOPRIO_CLASS_RT: | ||
135 | case IOPRIO_CLASS_BE: | ||
136 | break; | ||
137 | case IOPRIO_CLASS_IDLE: | ||
138 | ioprio = 7; | ||
139 | break; | ||
140 | default: | ||
141 | printf("bad prio class %d\n", ioprio_class); | ||
142 | return 1; | ||
143 | } | ||
144 | |||
145 | if (!set) { | ||
146 | if (!pid && argv[optind]) | ||
147 | pid = strtol(argv[optind], NULL, 10); | ||
148 | |||
149 | ioprio = ioprio_get(IOPRIO_WHO_PROCESS, pid); | ||
150 | |||
151 | printf("pid=%d, %d\n", pid, ioprio); | ||
152 | |||
153 | if (ioprio == -1) | ||
154 | perror("ioprio_get"); | ||
155 | else { | ||
156 | ioprio_class = ioprio >> IOPRIO_CLASS_SHIFT; | ||
157 | ioprio = ioprio & 0xff; | ||
158 | printf("%s: prio %d\n", to_prio[ioprio_class], ioprio); | ||
159 | } | ||
160 | } else { | ||
161 | if (ioprio_set(IOPRIO_WHO_PROCESS, pid, ioprio | ioprio_class << IOPRIO_CLASS_SHIFT) == -1) { | ||
162 | perror("ioprio_set"); | ||
163 | return 1; | ||
164 | } | ||
165 | |||
166 | if (argv[optind]) | ||
167 | execvp(argv[optind], &argv[optind]); | ||
168 | } | ||
169 | |||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | ---> snip ionice.c tool <--- | ||
174 | |||
175 | |||
176 | March 11 2005, Jens Axboe <axboe@suse.de> | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index f44bb5567c5b..89cd417651e0 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1115,7 +1115,7 @@ running once the system is up. | |||
1115 | See Documentation/ramdisk.txt. | 1115 | See Documentation/ramdisk.txt. |
1116 | 1116 | ||
1117 | psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to | 1117 | psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to |
1118 | probe for (bare|imps|exps). | 1118 | probe for (bare|imps|exps|lifebook|any). |
1119 | psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports | 1119 | psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports |
1120 | per second. | 1120 | per second. |
1121 | psmouse.resetafter= | 1121 | psmouse.resetafter= |
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S index 442a6e937b19..3db9a04aec6e 100644 --- a/arch/i386/kernel/syscall_table.S +++ b/arch/i386/kernel/syscall_table.S | |||
@@ -289,3 +289,5 @@ ENTRY(sys_call_table) | |||
289 | .long sys_add_key | 289 | .long sys_add_key |
290 | .long sys_request_key | 290 | .long sys_request_key |
291 | .long sys_keyctl | 291 | .long sys_keyctl |
292 | .long sys_ioprio_set | ||
293 | .long sys_ioprio_get /* 290 */ | ||
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index b1d5d3d5276c..785a51b0ad8e 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S | |||
@@ -1577,8 +1577,8 @@ sys_call_table: | |||
1577 | data8 sys_add_key | 1577 | data8 sys_add_key |
1578 | data8 sys_request_key | 1578 | data8 sys_request_key |
1579 | data8 sys_keyctl | 1579 | data8 sys_keyctl |
1580 | data8 sys_ni_syscall | 1580 | data8 sys_ioprio_set |
1581 | data8 sys_ni_syscall // 1275 | 1581 | data8 sys_ioprio_get // 1275 |
1582 | data8 sys_set_zone_reclaim | 1582 | data8 sys_set_zone_reclaim |
1583 | data8 sys_ni_syscall | 1583 | data8 sys_ni_syscall |
1584 | data8 sys_ni_syscall | 1584 | data8 sys_ni_syscall |
diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S index b6a63a49a232..191a8def3bdb 100644 --- a/arch/ppc/kernel/misc.S +++ b/arch/ppc/kernel/misc.S | |||
@@ -1449,3 +1449,5 @@ _GLOBAL(sys_call_table) | |||
1449 | .long sys_request_key /* 270 */ | 1449 | .long sys_request_key /* 270 */ |
1450 | .long sys_keyctl | 1450 | .long sys_keyctl |
1451 | .long sys_waitid | 1451 | .long sys_waitid |
1452 | .long sys_ioprio_set | ||
1453 | .long sys_ioprio_get | ||
diff --git a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c index 3410b4d294b9..91aeb678135d 100644 --- a/drivers/block/as-iosched.c +++ b/drivers/block/as-iosched.c | |||
@@ -1806,7 +1806,8 @@ static void as_put_request(request_queue_t *q, struct request *rq) | |||
1806 | rq->elevator_private = NULL; | 1806 | rq->elevator_private = NULL; |
1807 | } | 1807 | } |
1808 | 1808 | ||
1809 | static int as_set_request(request_queue_t *q, struct request *rq, int gfp_mask) | 1809 | static int as_set_request(request_queue_t *q, struct request *rq, |
1810 | struct bio *bio, int gfp_mask) | ||
1810 | { | 1811 | { |
1811 | struct as_data *ad = q->elevator->elevator_data; | 1812 | struct as_data *ad = q->elevator->elevator_data; |
1812 | struct as_rq *arq = mempool_alloc(ad->arq_pool, gfp_mask); | 1813 | struct as_rq *arq = mempool_alloc(ad->arq_pool, gfp_mask); |
@@ -1827,7 +1828,7 @@ static int as_set_request(request_queue_t *q, struct request *rq, int gfp_mask) | |||
1827 | return 1; | 1828 | return 1; |
1828 | } | 1829 | } |
1829 | 1830 | ||
1830 | static int as_may_queue(request_queue_t *q, int rw) | 1831 | static int as_may_queue(request_queue_t *q, int rw, struct bio *bio) |
1831 | { | 1832 | { |
1832 | int ret = ELV_MQUEUE_MAY; | 1833 | int ret = ELV_MQUEUE_MAY; |
1833 | struct as_data *ad = q->elevator->elevator_data; | 1834 | struct as_data *ad = q->elevator->elevator_data; |
diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c index 3ac47dde64da..ff1cc968f96d 100644 --- a/drivers/block/cfq-iosched.c +++ b/drivers/block/cfq-iosched.c | |||
@@ -21,22 +21,34 @@ | |||
21 | #include <linux/hash.h> | 21 | #include <linux/hash.h> |
22 | #include <linux/rbtree.h> | 22 | #include <linux/rbtree.h> |
23 | #include <linux/mempool.h> | 23 | #include <linux/mempool.h> |
24 | 24 | #include <linux/ioprio.h> | |
25 | static unsigned long max_elapsed_crq; | 25 | #include <linux/writeback.h> |
26 | static unsigned long max_elapsed_dispatch; | ||
27 | 26 | ||
28 | /* | 27 | /* |
29 | * tunables | 28 | * tunables |
30 | */ | 29 | */ |
31 | static int cfq_quantum = 4; /* max queue in one round of service */ | 30 | static int cfq_quantum = 4; /* max queue in one round of service */ |
32 | static int cfq_queued = 8; /* minimum rq allocate limit per-queue*/ | 31 | static int cfq_queued = 8; /* minimum rq allocate limit per-queue*/ |
33 | static int cfq_service = HZ; /* period over which service is avg */ | 32 | static int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 }; |
34 | static int cfq_fifo_expire_r = HZ / 2; /* fifo timeout for sync requests */ | ||
35 | static int cfq_fifo_expire_w = 5 * HZ; /* fifo timeout for async requests */ | ||
36 | static int cfq_fifo_rate = HZ / 8; /* fifo expiry rate */ | ||
37 | static int cfq_back_max = 16 * 1024; /* maximum backwards seek, in KiB */ | 33 | static int cfq_back_max = 16 * 1024; /* maximum backwards seek, in KiB */ |
38 | static int cfq_back_penalty = 2; /* penalty of a backwards seek */ | 34 | static int cfq_back_penalty = 2; /* penalty of a backwards seek */ |
39 | 35 | ||
36 | static int cfq_slice_sync = HZ / 10; | ||
37 | static int cfq_slice_async = HZ / 25; | ||
38 | static int cfq_slice_async_rq = 2; | ||
39 | static int cfq_slice_idle = HZ / 100; | ||
40 | |||
41 | #define CFQ_IDLE_GRACE (HZ / 10) | ||
42 | #define CFQ_SLICE_SCALE (5) | ||
43 | |||
44 | #define CFQ_KEY_ASYNC (0) | ||
45 | #define CFQ_KEY_ANY (0xffff) | ||
46 | |||
47 | /* | ||
48 | * disable queueing at the driver/hardware level | ||
49 | */ | ||
50 | static int cfq_max_depth = 1; | ||
51 | |||
40 | /* | 52 | /* |
41 | * for the hash of cfqq inside the cfqd | 53 | * for the hash of cfqq inside the cfqd |
42 | */ | 54 | */ |
@@ -55,6 +67,7 @@ static int cfq_back_penalty = 2; /* penalty of a backwards seek */ | |||
55 | #define list_entry_hash(ptr) hlist_entry((ptr), struct cfq_rq, hash) | 67 | #define list_entry_hash(ptr) hlist_entry((ptr), struct cfq_rq, hash) |
56 | 68 | ||
57 | #define list_entry_cfqq(ptr) list_entry((ptr), struct cfq_queue, cfq_list) | 69 | #define list_entry_cfqq(ptr) list_entry((ptr), struct cfq_queue, cfq_list) |
70 | #define list_entry_fifo(ptr) list_entry((ptr), struct request, queuelist) | ||
58 | 71 | ||
59 | #define RQ_DATA(rq) (rq)->elevator_private | 72 | #define RQ_DATA(rq) (rq)->elevator_private |
60 | 73 | ||
@@ -75,78 +88,110 @@ static int cfq_back_penalty = 2; /* penalty of a backwards seek */ | |||
75 | #define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node) | 88 | #define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node) |
76 | #define rq_rb_key(rq) (rq)->sector | 89 | #define rq_rb_key(rq) (rq)->sector |
77 | 90 | ||
78 | /* | ||
79 | * threshold for switching off non-tag accounting | ||
80 | */ | ||
81 | #define CFQ_MAX_TAG (4) | ||
82 | |||
83 | /* | ||
84 | * sort key types and names | ||
85 | */ | ||
86 | enum { | ||
87 | CFQ_KEY_PGID, | ||
88 | CFQ_KEY_TGID, | ||
89 | CFQ_KEY_UID, | ||
90 | CFQ_KEY_GID, | ||
91 | CFQ_KEY_LAST, | ||
92 | }; | ||
93 | |||
94 | static char *cfq_key_types[] = { "pgid", "tgid", "uid", "gid", NULL }; | ||
95 | |||
96 | static kmem_cache_t *crq_pool; | 91 | static kmem_cache_t *crq_pool; |
97 | static kmem_cache_t *cfq_pool; | 92 | static kmem_cache_t *cfq_pool; |
98 | static kmem_cache_t *cfq_ioc_pool; | 93 | static kmem_cache_t *cfq_ioc_pool; |
99 | 94 | ||
95 | #define CFQ_PRIO_LISTS IOPRIO_BE_NR | ||
96 | #define cfq_class_idle(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_IDLE) | ||
97 | #define cfq_class_be(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_BE) | ||
98 | #define cfq_class_rt(cfqq) ((cfqq)->ioprio_class == IOPRIO_CLASS_RT) | ||
99 | |||
100 | #define ASYNC (0) | ||
101 | #define SYNC (1) | ||
102 | |||
103 | #define cfq_cfqq_dispatched(cfqq) \ | ||
104 | ((cfqq)->on_dispatch[ASYNC] + (cfqq)->on_dispatch[SYNC]) | ||
105 | |||
106 | #define cfq_cfqq_class_sync(cfqq) ((cfqq)->key != CFQ_KEY_ASYNC) | ||
107 | |||
108 | #define cfq_cfqq_sync(cfqq) \ | ||
109 | (cfq_cfqq_class_sync(cfqq) || (cfqq)->on_dispatch[SYNC]) | ||
110 | |||
111 | /* | ||
112 | * Per block device queue structure | ||
113 | */ | ||
100 | struct cfq_data { | 114 | struct cfq_data { |
101 | struct list_head rr_list; | 115 | atomic_t ref; |
116 | request_queue_t *queue; | ||
117 | |||
118 | /* | ||
119 | * rr list of queues with requests and the count of them | ||
120 | */ | ||
121 | struct list_head rr_list[CFQ_PRIO_LISTS]; | ||
122 | struct list_head busy_rr; | ||
123 | struct list_head cur_rr; | ||
124 | struct list_head idle_rr; | ||
125 | unsigned int busy_queues; | ||
126 | |||
127 | /* | ||
128 | * non-ordered list of empty cfqq's | ||
129 | */ | ||
102 | struct list_head empty_list; | 130 | struct list_head empty_list; |
103 | 131 | ||
132 | /* | ||
133 | * cfqq lookup hash | ||
134 | */ | ||
104 | struct hlist_head *cfq_hash; | 135 | struct hlist_head *cfq_hash; |
105 | struct hlist_head *crq_hash; | ||
106 | 136 | ||
107 | /* queues on rr_list (ie they have pending requests */ | 137 | /* |
108 | unsigned int busy_queues; | 138 | * global crq hash for all queues |
139 | */ | ||
140 | struct hlist_head *crq_hash; | ||
109 | 141 | ||
110 | unsigned int max_queued; | 142 | unsigned int max_queued; |
111 | 143 | ||
112 | atomic_t ref; | 144 | mempool_t *crq_pool; |
113 | 145 | ||
114 | int key_type; | 146 | int rq_in_driver; |
115 | 147 | ||
116 | mempool_t *crq_pool; | 148 | /* |
149 | * schedule slice state info | ||
150 | */ | ||
151 | /* | ||
152 | * idle window management | ||
153 | */ | ||
154 | struct timer_list idle_slice_timer; | ||
155 | struct work_struct unplug_work; | ||
117 | 156 | ||
118 | request_queue_t *queue; | 157 | struct cfq_queue *active_queue; |
158 | struct cfq_io_context *active_cic; | ||
159 | int cur_prio, cur_end_prio; | ||
160 | unsigned int dispatch_slice; | ||
161 | |||
162 | struct timer_list idle_class_timer; | ||
119 | 163 | ||
120 | sector_t last_sector; | 164 | sector_t last_sector; |
165 | unsigned long last_end_request; | ||
121 | 166 | ||
122 | int rq_in_driver; | 167 | unsigned int rq_starved; |
123 | 168 | ||
124 | /* | 169 | /* |
125 | * tunables, see top of file | 170 | * tunables, see top of file |
126 | */ | 171 | */ |
127 | unsigned int cfq_quantum; | 172 | unsigned int cfq_quantum; |
128 | unsigned int cfq_queued; | 173 | unsigned int cfq_queued; |
129 | unsigned int cfq_fifo_expire_r; | 174 | unsigned int cfq_fifo_expire[2]; |
130 | unsigned int cfq_fifo_expire_w; | ||
131 | unsigned int cfq_fifo_batch_expire; | ||
132 | unsigned int cfq_back_penalty; | 175 | unsigned int cfq_back_penalty; |
133 | unsigned int cfq_back_max; | 176 | unsigned int cfq_back_max; |
134 | unsigned int find_best_crq; | 177 | unsigned int cfq_slice[2]; |
135 | 178 | unsigned int cfq_slice_async_rq; | |
136 | unsigned int cfq_tagged; | 179 | unsigned int cfq_slice_idle; |
180 | unsigned int cfq_max_depth; | ||
137 | }; | 181 | }; |
138 | 182 | ||
183 | /* | ||
184 | * Per process-grouping structure | ||
185 | */ | ||
139 | struct cfq_queue { | 186 | struct cfq_queue { |
140 | /* reference count */ | 187 | /* reference count */ |
141 | atomic_t ref; | 188 | atomic_t ref; |
142 | /* parent cfq_data */ | 189 | /* parent cfq_data */ |
143 | struct cfq_data *cfqd; | 190 | struct cfq_data *cfqd; |
144 | /* hash of mergeable requests */ | 191 | /* cfqq lookup hash */ |
145 | struct hlist_node cfq_hash; | 192 | struct hlist_node cfq_hash; |
146 | /* hash key */ | 193 | /* hash key */ |
147 | unsigned long key; | 194 | unsigned int key; |
148 | /* whether queue is on rr (or empty) list */ | ||
149 | int on_rr; | ||
150 | /* on either rr or empty list of cfqd */ | 195 | /* on either rr or empty list of cfqd */ |
151 | struct list_head cfq_list; | 196 | struct list_head cfq_list; |
152 | /* sorted list of pending requests */ | 197 | /* sorted list of pending requests */ |
@@ -158,21 +203,22 @@ struct cfq_queue { | |||
158 | /* currently allocated requests */ | 203 | /* currently allocated requests */ |
159 | int allocated[2]; | 204 | int allocated[2]; |
160 | /* fifo list of requests in sort_list */ | 205 | /* fifo list of requests in sort_list */ |
161 | struct list_head fifo[2]; | 206 | struct list_head fifo; |
162 | /* last time fifo expired */ | ||
163 | unsigned long last_fifo_expire; | ||
164 | 207 | ||
165 | int key_type; | 208 | unsigned long slice_start; |
209 | unsigned long slice_end; | ||
210 | unsigned long slice_left; | ||
211 | unsigned long service_last; | ||
166 | 212 | ||
167 | unsigned long service_start; | 213 | /* number of requests that are on the dispatch list */ |
168 | unsigned long service_used; | 214 | int on_dispatch[2]; |
169 | 215 | ||
170 | unsigned int max_rate; | 216 | /* io prio of this group */ |
217 | unsigned short ioprio, org_ioprio; | ||
218 | unsigned short ioprio_class, org_ioprio_class; | ||
171 | 219 | ||
172 | /* number of requests that have been handed to the driver */ | 220 | /* various state flags, see below */ |
173 | int in_flight; | 221 | unsigned int flags; |
174 | /* number of currently allocated requests */ | ||
175 | int alloc_limit[2]; | ||
176 | }; | 222 | }; |
177 | 223 | ||
178 | struct cfq_rq { | 224 | struct cfq_rq { |
@@ -184,42 +230,79 @@ struct cfq_rq { | |||
184 | struct cfq_queue *cfq_queue; | 230 | struct cfq_queue *cfq_queue; |
185 | struct cfq_io_context *io_context; | 231 | struct cfq_io_context *io_context; |
186 | 232 | ||
187 | unsigned long service_start; | 233 | unsigned int crq_flags; |
188 | unsigned long queue_start; | 234 | }; |
235 | |||
236 | enum cfqq_state_flags { | ||
237 | CFQ_CFQQ_FLAG_on_rr = 0, | ||
238 | CFQ_CFQQ_FLAG_wait_request, | ||
239 | CFQ_CFQQ_FLAG_must_alloc, | ||
240 | CFQ_CFQQ_FLAG_must_alloc_slice, | ||
241 | CFQ_CFQQ_FLAG_must_dispatch, | ||
242 | CFQ_CFQQ_FLAG_fifo_expire, | ||
243 | CFQ_CFQQ_FLAG_idle_window, | ||
244 | CFQ_CFQQ_FLAG_prio_changed, | ||
245 | CFQ_CFQQ_FLAG_expired, | ||
246 | }; | ||
189 | 247 | ||
190 | unsigned int in_flight : 1; | 248 | #define CFQ_CFQQ_FNS(name) \ |
191 | unsigned int accounted : 1; | 249 | static inline void cfq_mark_cfqq_##name(struct cfq_queue *cfqq) \ |
192 | unsigned int is_sync : 1; | 250 | { \ |
193 | unsigned int is_write : 1; | 251 | cfqq->flags |= (1 << CFQ_CFQQ_FLAG_##name); \ |
252 | } \ | ||
253 | static inline void cfq_clear_cfqq_##name(struct cfq_queue *cfqq) \ | ||
254 | { \ | ||
255 | cfqq->flags &= ~(1 << CFQ_CFQQ_FLAG_##name); \ | ||
256 | } \ | ||
257 | static inline int cfq_cfqq_##name(const struct cfq_queue *cfqq) \ | ||
258 | { \ | ||
259 | return (cfqq->flags & (1 << CFQ_CFQQ_FLAG_##name)) != 0; \ | ||
260 | } | ||
261 | |||
262 | CFQ_CFQQ_FNS(on_rr); | ||
263 | CFQ_CFQQ_FNS(wait_request); | ||
264 | CFQ_CFQQ_FNS(must_alloc); | ||
265 | CFQ_CFQQ_FNS(must_alloc_slice); | ||
266 | CFQ_CFQQ_FNS(must_dispatch); | ||
267 | CFQ_CFQQ_FNS(fifo_expire); | ||
268 | CFQ_CFQQ_FNS(idle_window); | ||
269 | CFQ_CFQQ_FNS(prio_changed); | ||
270 | CFQ_CFQQ_FNS(expired); | ||
271 | #undef CFQ_CFQQ_FNS | ||
272 | |||
273 | enum cfq_rq_state_flags { | ||
274 | CFQ_CRQ_FLAG_in_flight = 0, | ||
275 | CFQ_CRQ_FLAG_in_driver, | ||
276 | CFQ_CRQ_FLAG_is_sync, | ||
277 | CFQ_CRQ_FLAG_requeued, | ||
194 | }; | 278 | }; |
195 | 279 | ||
196 | static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned long); | 280 | #define CFQ_CRQ_FNS(name) \ |
281 | static inline void cfq_mark_crq_##name(struct cfq_rq *crq) \ | ||
282 | { \ | ||
283 | crq->crq_flags |= (1 << CFQ_CRQ_FLAG_##name); \ | ||
284 | } \ | ||
285 | static inline void cfq_clear_crq_##name(struct cfq_rq *crq) \ | ||
286 | { \ | ||
287 | crq->crq_flags &= ~(1 << CFQ_CRQ_FLAG_##name); \ | ||
288 | } \ | ||
289 | static inline int cfq_crq_##name(const struct cfq_rq *crq) \ | ||
290 | { \ | ||
291 | return (crq->crq_flags & (1 << CFQ_CRQ_FLAG_##name)) != 0; \ | ||
292 | } | ||
293 | |||
294 | CFQ_CRQ_FNS(in_flight); | ||
295 | CFQ_CRQ_FNS(in_driver); | ||
296 | CFQ_CRQ_FNS(is_sync); | ||
297 | CFQ_CRQ_FNS(requeued); | ||
298 | #undef CFQ_CRQ_FNS | ||
299 | |||
300 | static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsigned short); | ||
197 | static void cfq_dispatch_sort(request_queue_t *, struct cfq_rq *); | 301 | static void cfq_dispatch_sort(request_queue_t *, struct cfq_rq *); |
198 | static void cfq_update_next_crq(struct cfq_rq *); | ||
199 | static void cfq_put_cfqd(struct cfq_data *cfqd); | 302 | static void cfq_put_cfqd(struct cfq_data *cfqd); |
303 | static inline int cfq_pending_requests(struct cfq_data *cfqd); | ||
200 | 304 | ||
201 | /* | 305 | #define process_sync(tsk) ((tsk)->flags & PF_SYNCWRITE) |
202 | * what the fairness is based on (ie how processes are grouped and | ||
203 | * differentiated) | ||
204 | */ | ||
205 | static inline unsigned long | ||
206 | cfq_hash_key(struct cfq_data *cfqd, struct task_struct *tsk) | ||
207 | { | ||
208 | /* | ||
209 | * optimize this so that ->key_type is the offset into the struct | ||
210 | */ | ||
211 | switch (cfqd->key_type) { | ||
212 | case CFQ_KEY_PGID: | ||
213 | return process_group(tsk); | ||
214 | default: | ||
215 | case CFQ_KEY_TGID: | ||
216 | return tsk->tgid; | ||
217 | case CFQ_KEY_UID: | ||
218 | return tsk->uid; | ||
219 | case CFQ_KEY_GID: | ||
220 | return tsk->gid; | ||
221 | } | ||
222 | } | ||
223 | 306 | ||
224 | /* | 307 | /* |
225 | * lots of deadline iosched dupes, can be abstracted later... | 308 | * lots of deadline iosched dupes, can be abstracted later... |
@@ -235,16 +318,12 @@ static void cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq) | |||
235 | 318 | ||
236 | if (q->last_merge == crq->request) | 319 | if (q->last_merge == crq->request) |
237 | q->last_merge = NULL; | 320 | q->last_merge = NULL; |
238 | |||
239 | cfq_update_next_crq(crq); | ||
240 | } | 321 | } |
241 | 322 | ||
242 | static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq) | 323 | static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq) |
243 | { | 324 | { |
244 | const int hash_idx = CFQ_MHASH_FN(rq_hash_key(crq->request)); | 325 | const int hash_idx = CFQ_MHASH_FN(rq_hash_key(crq->request)); |
245 | 326 | ||
246 | BUG_ON(!hlist_unhashed(&crq->hash)); | ||
247 | |||
248 | hlist_add_head(&crq->hash, &cfqd->crq_hash[hash_idx]); | 327 | hlist_add_head(&crq->hash, &cfqd->crq_hash[hash_idx]); |
249 | } | 328 | } |
250 | 329 | ||
@@ -257,8 +336,6 @@ static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset) | |||
257 | struct cfq_rq *crq = list_entry_hash(entry); | 336 | struct cfq_rq *crq = list_entry_hash(entry); |
258 | struct request *__rq = crq->request; | 337 | struct request *__rq = crq->request; |
259 | 338 | ||
260 | BUG_ON(hlist_unhashed(&crq->hash)); | ||
261 | |||
262 | if (!rq_mergeable(__rq)) { | 339 | if (!rq_mergeable(__rq)) { |
263 | cfq_del_crq_hash(crq); | 340 | cfq_del_crq_hash(crq); |
264 | continue; | 341 | continue; |
@@ -287,36 +364,16 @@ cfq_choose_req(struct cfq_data *cfqd, struct cfq_rq *crq1, struct cfq_rq *crq2) | |||
287 | return crq2; | 364 | return crq2; |
288 | if (crq2 == NULL) | 365 | if (crq2 == NULL) |
289 | return crq1; | 366 | return crq1; |
367 | if (cfq_crq_requeued(crq1)) | ||
368 | return crq1; | ||
369 | if (cfq_crq_requeued(crq2)) | ||
370 | return crq2; | ||
290 | 371 | ||
291 | s1 = crq1->request->sector; | 372 | s1 = crq1->request->sector; |
292 | s2 = crq2->request->sector; | 373 | s2 = crq2->request->sector; |
293 | 374 | ||
294 | last = cfqd->last_sector; | 375 | last = cfqd->last_sector; |
295 | 376 | ||
296 | #if 0 | ||
297 | if (!list_empty(&cfqd->queue->queue_head)) { | ||
298 | struct list_head *entry = &cfqd->queue->queue_head; | ||
299 | unsigned long distance = ~0UL; | ||
300 | struct request *rq; | ||
301 | |||
302 | while ((entry = entry->prev) != &cfqd->queue->queue_head) { | ||
303 | rq = list_entry_rq(entry); | ||
304 | |||
305 | if (blk_barrier_rq(rq)) | ||
306 | break; | ||
307 | |||
308 | if (distance < abs(s1 - rq->sector + rq->nr_sectors)) { | ||
309 | distance = abs(s1 - rq->sector +rq->nr_sectors); | ||
310 | last = rq->sector + rq->nr_sectors; | ||
311 | } | ||
312 | if (distance < abs(s2 - rq->sector + rq->nr_sectors)) { | ||
313 | distance = abs(s2 - rq->sector +rq->nr_sectors); | ||
314 | last = rq->sector + rq->nr_sectors; | ||
315 | } | ||
316 | } | ||
317 | } | ||
318 | #endif | ||
319 | |||
320 | /* | 377 | /* |
321 | * by definition, 1KiB is 2 sectors | 378 | * by definition, 1KiB is 2 sectors |
322 | */ | 379 | */ |
@@ -377,11 +434,14 @@ cfq_find_next_crq(struct cfq_data *cfqd, struct cfq_queue *cfqq, | |||
377 | struct cfq_rq *crq_next = NULL, *crq_prev = NULL; | 434 | struct cfq_rq *crq_next = NULL, *crq_prev = NULL; |
378 | struct rb_node *rbnext, *rbprev; | 435 | struct rb_node *rbnext, *rbprev; |
379 | 436 | ||
380 | if (!ON_RB(&last->rb_node)) | 437 | rbnext = NULL; |
381 | return NULL; | 438 | if (ON_RB(&last->rb_node)) |
382 | 439 | rbnext = rb_next(&last->rb_node); | |
383 | if ((rbnext = rb_next(&last->rb_node)) == NULL) | 440 | if (!rbnext) { |
384 | rbnext = rb_first(&cfqq->sort_list); | 441 | rbnext = rb_first(&cfqq->sort_list); |
442 | if (rbnext == &last->rb_node) | ||
443 | rbnext = NULL; | ||
444 | } | ||
385 | 445 | ||
386 | rbprev = rb_prev(&last->rb_node); | 446 | rbprev = rb_prev(&last->rb_node); |
387 | 447 | ||
@@ -401,67 +461,53 @@ static void cfq_update_next_crq(struct cfq_rq *crq) | |||
401 | cfqq->next_crq = cfq_find_next_crq(cfqq->cfqd, cfqq, crq); | 461 | cfqq->next_crq = cfq_find_next_crq(cfqq->cfqd, cfqq, crq); |
402 | } | 462 | } |
403 | 463 | ||
404 | static int cfq_check_sort_rr_list(struct cfq_queue *cfqq) | 464 | static void cfq_resort_rr_list(struct cfq_queue *cfqq, int preempted) |
405 | { | 465 | { |
406 | struct list_head *head = &cfqq->cfqd->rr_list; | 466 | struct cfq_data *cfqd = cfqq->cfqd; |
407 | struct list_head *next, *prev; | 467 | struct list_head *list, *entry; |
408 | |||
409 | /* | ||
410 | * list might still be ordered | ||
411 | */ | ||
412 | next = cfqq->cfq_list.next; | ||
413 | if (next != head) { | ||
414 | struct cfq_queue *cnext = list_entry_cfqq(next); | ||
415 | 468 | ||
416 | if (cfqq->service_used > cnext->service_used) | 469 | BUG_ON(!cfq_cfqq_on_rr(cfqq)); |
417 | return 1; | ||
418 | } | ||
419 | 470 | ||
420 | prev = cfqq->cfq_list.prev; | 471 | list_del(&cfqq->cfq_list); |
421 | if (prev != head) { | ||
422 | struct cfq_queue *cprev = list_entry_cfqq(prev); | ||
423 | 472 | ||
424 | if (cfqq->service_used < cprev->service_used) | 473 | if (cfq_class_rt(cfqq)) |
425 | return 1; | 474 | list = &cfqd->cur_rr; |
475 | else if (cfq_class_idle(cfqq)) | ||
476 | list = &cfqd->idle_rr; | ||
477 | else { | ||
478 | /* | ||
479 | * if cfqq has requests in flight, don't allow it to be | ||
480 | * found in cfq_set_active_queue before it has finished them. | ||
481 | * this is done to increase fairness between a process that | ||
482 | * has lots of io pending vs one that only generates one | ||
483 | * sporadically or synchronously | ||
484 | */ | ||
485 | if (cfq_cfqq_dispatched(cfqq)) | ||
486 | list = &cfqd->busy_rr; | ||
487 | else | ||
488 | list = &cfqd->rr_list[cfqq->ioprio]; | ||
426 | } | 489 | } |
427 | 490 | ||
428 | return 0; | 491 | /* |
429 | } | 492 | * if queue was preempted, just add to front to be fair. busy_rr |
430 | 493 | * isn't sorted. | |
431 | static void cfq_sort_rr_list(struct cfq_queue *cfqq, int new_queue) | 494 | */ |
432 | { | 495 | if (preempted || list == &cfqd->busy_rr) { |
433 | struct list_head *entry = &cfqq->cfqd->rr_list; | 496 | list_add(&cfqq->cfq_list, list); |
434 | |||
435 | if (!cfqq->on_rr) | ||
436 | return; | ||
437 | if (!new_queue && !cfq_check_sort_rr_list(cfqq)) | ||
438 | return; | 497 | return; |
439 | 498 | } | |
440 | list_del(&cfqq->cfq_list); | ||
441 | 499 | ||
442 | /* | 500 | /* |
443 | * sort by our mean service_used, sub-sort by in-flight requests | 501 | * sort by when queue was last serviced |
444 | */ | 502 | */ |
445 | while ((entry = entry->prev) != &cfqq->cfqd->rr_list) { | 503 | entry = list; |
504 | while ((entry = entry->prev) != list) { | ||
446 | struct cfq_queue *__cfqq = list_entry_cfqq(entry); | 505 | struct cfq_queue *__cfqq = list_entry_cfqq(entry); |
447 | 506 | ||
448 | if (cfqq->service_used > __cfqq->service_used) | 507 | if (!__cfqq->service_last) |
508 | break; | ||
509 | if (time_before(__cfqq->service_last, cfqq->service_last)) | ||
449 | break; | 510 | break; |
450 | else if (cfqq->service_used == __cfqq->service_used) { | ||
451 | struct list_head *prv; | ||
452 | |||
453 | while ((prv = entry->prev) != &cfqq->cfqd->rr_list) { | ||
454 | __cfqq = list_entry_cfqq(prv); | ||
455 | |||
456 | WARN_ON(__cfqq->service_used > cfqq->service_used); | ||
457 | if (cfqq->service_used != __cfqq->service_used) | ||
458 | break; | ||
459 | if (cfqq->in_flight > __cfqq->in_flight) | ||
460 | break; | ||
461 | |||
462 | entry = prv; | ||
463 | } | ||
464 | } | ||
465 | } | 511 | } |
466 | 512 | ||
467 | list_add(&cfqq->cfq_list, entry); | 513 | list_add(&cfqq->cfq_list, entry); |
@@ -469,28 +515,24 @@ static void cfq_sort_rr_list(struct cfq_queue *cfqq, int new_queue) | |||
469 | 515 | ||
470 | /* | 516 | /* |
471 | * add to busy list of queues for service, trying to be fair in ordering | 517 | * add to busy list of queues for service, trying to be fair in ordering |
472 | * the pending list according to requests serviced | 518 | * the pending list according to last request service |
473 | */ | 519 | */ |
474 | static inline void | 520 | static inline void |
475 | cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq) | 521 | cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq, int requeue) |
476 | { | 522 | { |
477 | /* | 523 | BUG_ON(cfq_cfqq_on_rr(cfqq)); |
478 | * it's currently on the empty list | 524 | cfq_mark_cfqq_on_rr(cfqq); |
479 | */ | ||
480 | cfqq->on_rr = 1; | ||
481 | cfqd->busy_queues++; | 525 | cfqd->busy_queues++; |
482 | 526 | ||
483 | if (time_after(jiffies, cfqq->service_start + cfq_service)) | 527 | cfq_resort_rr_list(cfqq, requeue); |
484 | cfqq->service_used >>= 3; | ||
485 | |||
486 | cfq_sort_rr_list(cfqq, 1); | ||
487 | } | 528 | } |
488 | 529 | ||
489 | static inline void | 530 | static inline void |
490 | cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq) | 531 | cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq) |
491 | { | 532 | { |
533 | BUG_ON(!cfq_cfqq_on_rr(cfqq)); | ||
534 | cfq_clear_cfqq_on_rr(cfqq); | ||
492 | list_move(&cfqq->cfq_list, &cfqd->empty_list); | 535 | list_move(&cfqq->cfq_list, &cfqd->empty_list); |
493 | cfqq->on_rr = 0; | ||
494 | 536 | ||
495 | BUG_ON(!cfqd->busy_queues); | 537 | BUG_ON(!cfqd->busy_queues); |
496 | cfqd->busy_queues--; | 538 | cfqd->busy_queues--; |
@@ -505,16 +547,17 @@ static inline void cfq_del_crq_rb(struct cfq_rq *crq) | |||
505 | 547 | ||
506 | if (ON_RB(&crq->rb_node)) { | 548 | if (ON_RB(&crq->rb_node)) { |
507 | struct cfq_data *cfqd = cfqq->cfqd; | 549 | struct cfq_data *cfqd = cfqq->cfqd; |
550 | const int sync = cfq_crq_is_sync(crq); | ||
508 | 551 | ||
509 | BUG_ON(!cfqq->queued[crq->is_sync]); | 552 | BUG_ON(!cfqq->queued[sync]); |
553 | cfqq->queued[sync]--; | ||
510 | 554 | ||
511 | cfq_update_next_crq(crq); | 555 | cfq_update_next_crq(crq); |
512 | 556 | ||
513 | cfqq->queued[crq->is_sync]--; | ||
514 | rb_erase(&crq->rb_node, &cfqq->sort_list); | 557 | rb_erase(&crq->rb_node, &cfqq->sort_list); |
515 | RB_CLEAR_COLOR(&crq->rb_node); | 558 | RB_CLEAR_COLOR(&crq->rb_node); |
516 | 559 | ||
517 | if (RB_EMPTY(&cfqq->sort_list) && cfqq->on_rr) | 560 | if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY(&cfqq->sort_list)) |
518 | cfq_del_cfqq_rr(cfqd, cfqq); | 561 | cfq_del_cfqq_rr(cfqd, cfqq); |
519 | } | 562 | } |
520 | } | 563 | } |
@@ -550,7 +593,7 @@ static void cfq_add_crq_rb(struct cfq_rq *crq) | |||
550 | struct cfq_rq *__alias; | 593 | struct cfq_rq *__alias; |
551 | 594 | ||
552 | crq->rb_key = rq_rb_key(rq); | 595 | crq->rb_key = rq_rb_key(rq); |
553 | cfqq->queued[crq->is_sync]++; | 596 | cfqq->queued[cfq_crq_is_sync(crq)]++; |
554 | 597 | ||
555 | /* | 598 | /* |
556 | * looks a little odd, but the first insert might return an alias. | 599 | * looks a little odd, but the first insert might return an alias. |
@@ -561,8 +604,8 @@ static void cfq_add_crq_rb(struct cfq_rq *crq) | |||
561 | 604 | ||
562 | rb_insert_color(&crq->rb_node, &cfqq->sort_list); | 605 | rb_insert_color(&crq->rb_node, &cfqq->sort_list); |
563 | 606 | ||
564 | if (!cfqq->on_rr) | 607 | if (!cfq_cfqq_on_rr(cfqq)) |
565 | cfq_add_cfqq_rr(cfqd, cfqq); | 608 | cfq_add_cfqq_rr(cfqd, cfqq, cfq_crq_requeued(crq)); |
566 | 609 | ||
567 | /* | 610 | /* |
568 | * check if this request is a better next-serve candidate | 611 | * check if this request is a better next-serve candidate |
@@ -575,17 +618,16 @@ cfq_reposition_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq) | |||
575 | { | 618 | { |
576 | if (ON_RB(&crq->rb_node)) { | 619 | if (ON_RB(&crq->rb_node)) { |
577 | rb_erase(&crq->rb_node, &cfqq->sort_list); | 620 | rb_erase(&crq->rb_node, &cfqq->sort_list); |
578 | cfqq->queued[crq->is_sync]--; | 621 | cfqq->queued[cfq_crq_is_sync(crq)]--; |
579 | } | 622 | } |
580 | 623 | ||
581 | cfq_add_crq_rb(crq); | 624 | cfq_add_crq_rb(crq); |
582 | } | 625 | } |
583 | 626 | ||
584 | static struct request * | 627 | static struct request *cfq_find_rq_rb(struct cfq_data *cfqd, sector_t sector) |
585 | cfq_find_rq_rb(struct cfq_data *cfqd, sector_t sector) | 628 | |
586 | { | 629 | { |
587 | const unsigned long key = cfq_hash_key(cfqd, current); | 630 | struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, current->pid, CFQ_KEY_ANY); |
588 | struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, key); | ||
589 | struct rb_node *n; | 631 | struct rb_node *n; |
590 | 632 | ||
591 | if (!cfqq) | 633 | if (!cfqq) |
@@ -609,20 +651,25 @@ out: | |||
609 | 651 | ||
610 | static void cfq_deactivate_request(request_queue_t *q, struct request *rq) | 652 | static void cfq_deactivate_request(request_queue_t *q, struct request *rq) |
611 | { | 653 | { |
654 | struct cfq_data *cfqd = q->elevator->elevator_data; | ||
612 | struct cfq_rq *crq = RQ_DATA(rq); | 655 | struct cfq_rq *crq = RQ_DATA(rq); |
613 | 656 | ||
614 | if (crq) { | 657 | if (crq) { |
615 | struct cfq_queue *cfqq = crq->cfq_queue; | 658 | struct cfq_queue *cfqq = crq->cfq_queue; |
616 | 659 | ||
617 | if (cfqq->cfqd->cfq_tagged) { | 660 | if (cfq_crq_in_driver(crq)) { |
618 | cfqq->service_used--; | 661 | cfq_clear_crq_in_driver(crq); |
619 | cfq_sort_rr_list(cfqq, 0); | 662 | WARN_ON(!cfqd->rq_in_driver); |
663 | cfqd->rq_in_driver--; | ||
620 | } | 664 | } |
665 | if (cfq_crq_in_flight(crq)) { | ||
666 | const int sync = cfq_crq_is_sync(crq); | ||
621 | 667 | ||
622 | if (crq->accounted) { | 668 | cfq_clear_crq_in_flight(crq); |
623 | crq->accounted = 0; | 669 | WARN_ON(!cfqq->on_dispatch[sync]); |
624 | cfqq->cfqd->rq_in_driver--; | 670 | cfqq->on_dispatch[sync]--; |
625 | } | 671 | } |
672 | cfq_mark_crq_requeued(crq); | ||
626 | } | 673 | } |
627 | } | 674 | } |
628 | 675 | ||
@@ -640,11 +687,10 @@ static void cfq_remove_request(request_queue_t *q, struct request *rq) | |||
640 | struct cfq_rq *crq = RQ_DATA(rq); | 687 | struct cfq_rq *crq = RQ_DATA(rq); |
641 | 688 | ||
642 | if (crq) { | 689 | if (crq) { |
643 | cfq_remove_merge_hints(q, crq); | ||
644 | list_del_init(&rq->queuelist); | 690 | list_del_init(&rq->queuelist); |
691 | cfq_del_crq_rb(crq); | ||
692 | cfq_remove_merge_hints(q, crq); | ||
645 | 693 | ||
646 | if (crq->cfq_queue) | ||
647 | cfq_del_crq_rb(crq); | ||
648 | } | 694 | } |
649 | } | 695 | } |
650 | 696 | ||
@@ -662,21 +708,15 @@ cfq_merge(request_queue_t *q, struct request **req, struct bio *bio) | |||
662 | } | 708 | } |
663 | 709 | ||
664 | __rq = cfq_find_rq_hash(cfqd, bio->bi_sector); | 710 | __rq = cfq_find_rq_hash(cfqd, bio->bi_sector); |
665 | if (__rq) { | 711 | if (__rq && elv_rq_merge_ok(__rq, bio)) { |
666 | BUG_ON(__rq->sector + __rq->nr_sectors != bio->bi_sector); | 712 | ret = ELEVATOR_BACK_MERGE; |
667 | 713 | goto out; | |
668 | if (elv_rq_merge_ok(__rq, bio)) { | ||
669 | ret = ELEVATOR_BACK_MERGE; | ||
670 | goto out; | ||
671 | } | ||
672 | } | 714 | } |
673 | 715 | ||
674 | __rq = cfq_find_rq_rb(cfqd, bio->bi_sector + bio_sectors(bio)); | 716 | __rq = cfq_find_rq_rb(cfqd, bio->bi_sector + bio_sectors(bio)); |
675 | if (__rq) { | 717 | if (__rq && elv_rq_merge_ok(__rq, bio)) { |
676 | if (elv_rq_merge_ok(__rq, bio)) { | 718 | ret = ELEVATOR_FRONT_MERGE; |
677 | ret = ELEVATOR_FRONT_MERGE; | 719 | goto out; |
678 | goto out; | ||
679 | } | ||
680 | } | 720 | } |
681 | 721 | ||
682 | return ELEVATOR_NO_MERGE; | 722 | return ELEVATOR_NO_MERGE; |
@@ -709,20 +749,220 @@ static void | |||
709 | cfq_merged_requests(request_queue_t *q, struct request *rq, | 749 | cfq_merged_requests(request_queue_t *q, struct request *rq, |
710 | struct request *next) | 750 | struct request *next) |
711 | { | 751 | { |
712 | struct cfq_rq *crq = RQ_DATA(rq); | ||
713 | struct cfq_rq *cnext = RQ_DATA(next); | ||
714 | |||
715 | cfq_merged_request(q, rq); | 752 | cfq_merged_request(q, rq); |
716 | 753 | ||
717 | if (!list_empty(&rq->queuelist) && !list_empty(&next->queuelist)) { | 754 | /* |
718 | if (time_before(cnext->queue_start, crq->queue_start)) { | 755 | * reposition in fifo if next is older than rq |
719 | list_move(&rq->queuelist, &next->queuelist); | 756 | */ |
720 | crq->queue_start = cnext->queue_start; | 757 | if (!list_empty(&rq->queuelist) && !list_empty(&next->queuelist) && |
758 | time_before(next->start_time, rq->start_time)) | ||
759 | list_move(&rq->queuelist, &next->queuelist); | ||
760 | |||
761 | cfq_remove_request(q, next); | ||
762 | } | ||
763 | |||
764 | static inline void | ||
765 | __cfq_set_active_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq) | ||
766 | { | ||
767 | if (cfqq) { | ||
768 | /* | ||
769 | * stop potential idle class queues waiting service | ||
770 | */ | ||
771 | del_timer(&cfqd->idle_class_timer); | ||
772 | |||
773 | cfqq->slice_start = jiffies; | ||
774 | cfqq->slice_end = 0; | ||
775 | cfqq->slice_left = 0; | ||
776 | cfq_clear_cfqq_must_alloc_slice(cfqq); | ||
777 | cfq_clear_cfqq_fifo_expire(cfqq); | ||
778 | cfq_clear_cfqq_expired(cfqq); | ||
779 | } | ||
780 | |||
781 | cfqd->active_queue = cfqq; | ||
782 | } | ||
783 | |||
784 | /* | ||
785 | * 0 | ||
786 | * 0,1 | ||
787 | * 0,1,2 | ||
788 | * 0,1,2,3 | ||
789 | * 0,1,2,3,4 | ||
790 | * 0,1,2,3,4,5 | ||
791 | * 0,1,2,3,4,5,6 | ||
792 | * 0,1,2,3,4,5,6,7 | ||
793 | */ | ||
794 | static int cfq_get_next_prio_level(struct cfq_data *cfqd) | ||
795 | { | ||
796 | int prio, wrap; | ||
797 | |||
798 | prio = -1; | ||
799 | wrap = 0; | ||
800 | do { | ||
801 | int p; | ||
802 | |||
803 | for (p = cfqd->cur_prio; p <= cfqd->cur_end_prio; p++) { | ||
804 | if (!list_empty(&cfqd->rr_list[p])) { | ||
805 | prio = p; | ||
806 | break; | ||
807 | } | ||
808 | } | ||
809 | |||
810 | if (prio != -1) | ||
811 | break; | ||
812 | cfqd->cur_prio = 0; | ||
813 | if (++cfqd->cur_end_prio == CFQ_PRIO_LISTS) { | ||
814 | cfqd->cur_end_prio = 0; | ||
815 | if (wrap) | ||
816 | break; | ||
817 | wrap = 1; | ||
721 | } | 818 | } |
819 | } while (1); | ||
820 | |||
821 | if (unlikely(prio == -1)) | ||
822 | return -1; | ||
823 | |||
824 | BUG_ON(prio >= CFQ_PRIO_LISTS); | ||
825 | |||
826 | list_splice_init(&cfqd->rr_list[prio], &cfqd->cur_rr); | ||
827 | |||
828 | cfqd->cur_prio = prio + 1; | ||
829 | if (cfqd->cur_prio > cfqd->cur_end_prio) { | ||
830 | cfqd->cur_end_prio = cfqd->cur_prio; | ||
831 | cfqd->cur_prio = 0; | ||
832 | } | ||
833 | if (cfqd->cur_end_prio == CFQ_PRIO_LISTS) { | ||
834 | cfqd->cur_prio = 0; | ||
835 | cfqd->cur_end_prio = 0; | ||
722 | } | 836 | } |
723 | 837 | ||
724 | cfq_update_next_crq(cnext); | 838 | return prio; |
725 | cfq_remove_request(q, next); | 839 | } |
840 | |||
841 | static struct cfq_queue *cfq_set_active_queue(struct cfq_data *cfqd) | ||
842 | { | ||
843 | struct cfq_queue *cfqq; | ||
844 | |||
845 | /* | ||
846 | * if current queue is expired but not done with its requests yet, | ||
847 | * wait for that to happen | ||
848 | */ | ||
849 | if ((cfqq = cfqd->active_queue) != NULL) { | ||
850 | if (cfq_cfqq_expired(cfqq) && cfq_cfqq_dispatched(cfqq)) | ||
851 | return NULL; | ||
852 | } | ||
853 | |||
854 | /* | ||
855 | * if current list is non-empty, grab first entry. if it is empty, | ||
856 | * get next prio level and grab first entry then if any are spliced | ||
857 | */ | ||
858 | if (!list_empty(&cfqd->cur_rr) || cfq_get_next_prio_level(cfqd) != -1) | ||
859 | cfqq = list_entry_cfqq(cfqd->cur_rr.next); | ||
860 | |||
861 | /* | ||
862 | * if we have idle queues and no rt or be queues had pending | ||
863 | * requests, either allow immediate service if the grace period | ||
864 | * has passed or arm the idle grace timer | ||
865 | */ | ||
866 | if (!cfqq && !list_empty(&cfqd->idle_rr)) { | ||
867 | unsigned long end = cfqd->last_end_request + CFQ_IDLE_GRACE; | ||
868 | |||
869 | if (time_after_eq(jiffies, end)) | ||
870 | cfqq = list_entry_cfqq(cfqd->idle_rr.next); | ||
871 | else | ||
872 | mod_timer(&cfqd->idle_class_timer, end); | ||
873 | } | ||
874 | |||
875 | __cfq_set_active_queue(cfqd, cfqq); | ||
876 | return cfqq; | ||
877 | } | ||
878 | |||
879 | /* | ||
880 | * current cfqq expired its slice (or was too idle), select new one | ||
881 | */ | ||
882 | static void | ||
883 | __cfq_slice_expired(struct cfq_data *cfqd, struct cfq_queue *cfqq, | ||
884 | int preempted) | ||
885 | { | ||
886 | unsigned long now = jiffies; | ||
887 | |||
888 | if (cfq_cfqq_wait_request(cfqq)) | ||
889 | del_timer(&cfqd->idle_slice_timer); | ||
890 | |||
891 | if (!preempted && !cfq_cfqq_dispatched(cfqq)) | ||
892 | cfqq->service_last = now; | ||
893 | |||
894 | cfq_clear_cfqq_must_dispatch(cfqq); | ||
895 | cfq_clear_cfqq_wait_request(cfqq); | ||
896 | |||
897 | /* | ||
898 | * store what was left of this slice, if the queue idled out | ||
899 | * or was preempted | ||
900 | */ | ||
901 | if (time_after(now, cfqq->slice_end)) | ||
902 | cfqq->slice_left = now - cfqq->slice_end; | ||
903 | else | ||
904 | cfqq->slice_left = 0; | ||
905 | |||
906 | if (cfq_cfqq_on_rr(cfqq)) | ||
907 | cfq_resort_rr_list(cfqq, preempted); | ||
908 | |||
909 | if (cfqq == cfqd->active_queue) | ||
910 | cfqd->active_queue = NULL; | ||
911 | |||
912 | if (cfqd->active_cic) { | ||
913 | put_io_context(cfqd->active_cic->ioc); | ||
914 | cfqd->active_cic = NULL; | ||
915 | } | ||
916 | |||
917 | cfqd->dispatch_slice = 0; | ||
918 | } | ||
919 | |||
920 | static inline void cfq_slice_expired(struct cfq_data *cfqd, int preempted) | ||
921 | { | ||
922 | struct cfq_queue *cfqq = cfqd->active_queue; | ||
923 | |||
924 | if (cfqq) { | ||
925 | /* | ||
926 | * use deferred expiry, if there are requests in progress as | ||
927 | * not to disturb the slice of the next queue | ||
928 | */ | ||
929 | if (cfq_cfqq_dispatched(cfqq)) | ||
930 | cfq_mark_cfqq_expired(cfqq); | ||
931 | else | ||
932 | __cfq_slice_expired(cfqd, cfqq, preempted); | ||
933 | } | ||
934 | } | ||
935 | |||
936 | static int cfq_arm_slice_timer(struct cfq_data *cfqd, struct cfq_queue *cfqq) | ||
937 | |||
938 | { | ||
939 | WARN_ON(!RB_EMPTY(&cfqq->sort_list)); | ||
940 | WARN_ON(cfqq != cfqd->active_queue); | ||
941 | |||
942 | /* | ||
943 | * idle is disabled, either manually or by past process history | ||
944 | */ | ||
945 | if (!cfqd->cfq_slice_idle) | ||
946 | return 0; | ||
947 | if (!cfq_cfqq_idle_window(cfqq)) | ||
948 | return 0; | ||
949 | /* | ||
950 | * task has exited, don't wait | ||
951 | */ | ||
952 | if (cfqd->active_cic && !cfqd->active_cic->ioc->task) | ||
953 | return 0; | ||
954 | |||
955 | cfq_mark_cfqq_must_dispatch(cfqq); | ||
956 | cfq_mark_cfqq_wait_request(cfqq); | ||
957 | |||
958 | if (!timer_pending(&cfqd->idle_slice_timer)) { | ||
959 | unsigned long slice_left = min(cfqq->slice_end - 1, (unsigned long) cfqd->cfq_slice_idle); | ||
960 | |||
961 | cfqd->idle_slice_timer.expires = jiffies + slice_left; | ||
962 | add_timer(&cfqd->idle_slice_timer); | ||
963 | } | ||
964 | |||
965 | return 1; | ||
726 | } | 966 | } |
727 | 967 | ||
728 | /* | 968 | /* |
@@ -738,31 +978,40 @@ static void cfq_dispatch_sort(request_queue_t *q, struct cfq_rq *crq) | |||
738 | struct request *__rq; | 978 | struct request *__rq; |
739 | sector_t last; | 979 | sector_t last; |
740 | 980 | ||
741 | cfq_del_crq_rb(crq); | ||
742 | cfq_remove_merge_hints(q, crq); | ||
743 | list_del(&crq->request->queuelist); | 981 | list_del(&crq->request->queuelist); |
744 | 982 | ||
745 | last = cfqd->last_sector; | 983 | last = cfqd->last_sector; |
746 | while ((entry = entry->prev) != head) { | 984 | list_for_each_entry_reverse(__rq, head, queuelist) { |
747 | __rq = list_entry_rq(entry); | 985 | struct cfq_rq *__crq = RQ_DATA(__rq); |
748 | 986 | ||
749 | if (blk_barrier_rq(crq->request)) | 987 | if (blk_barrier_rq(__rq)) |
988 | break; | ||
989 | if (!blk_fs_request(__rq)) | ||
750 | break; | 990 | break; |
751 | if (!blk_fs_request(crq->request)) | 991 | if (cfq_crq_requeued(__crq)) |
752 | break; | 992 | break; |
753 | 993 | ||
754 | if (crq->request->sector > __rq->sector) | 994 | if (__rq->sector <= crq->request->sector) |
755 | break; | 995 | break; |
756 | if (__rq->sector > last && crq->request->sector < last) { | 996 | if (__rq->sector > last && crq->request->sector < last) { |
757 | last = crq->request->sector; | 997 | last = crq->request->sector + crq->request->nr_sectors; |
758 | break; | 998 | break; |
759 | } | 999 | } |
1000 | entry = &__rq->queuelist; | ||
760 | } | 1001 | } |
761 | 1002 | ||
762 | cfqd->last_sector = last; | 1003 | cfqd->last_sector = last; |
763 | crq->in_flight = 1; | 1004 | |
764 | cfqq->in_flight++; | 1005 | cfqq->next_crq = cfq_find_next_crq(cfqd, cfqq, crq); |
765 | list_add(&crq->request->queuelist, entry); | 1006 | |
1007 | cfq_del_crq_rb(crq); | ||
1008 | cfq_remove_merge_hints(q, crq); | ||
1009 | |||
1010 | cfq_mark_crq_in_flight(crq); | ||
1011 | cfq_clear_crq_requeued(crq); | ||
1012 | |||
1013 | cfqq->on_dispatch[cfq_crq_is_sync(crq)]++; | ||
1014 | list_add_tail(&crq->request->queuelist, entry); | ||
766 | } | 1015 | } |
767 | 1016 | ||
768 | /* | 1017 | /* |
@@ -771,173 +1020,235 @@ static void cfq_dispatch_sort(request_queue_t *q, struct cfq_rq *crq) | |||
771 | static inline struct cfq_rq *cfq_check_fifo(struct cfq_queue *cfqq) | 1020 | static inline struct cfq_rq *cfq_check_fifo(struct cfq_queue *cfqq) |
772 | { | 1021 | { |
773 | struct cfq_data *cfqd = cfqq->cfqd; | 1022 | struct cfq_data *cfqd = cfqq->cfqd; |
774 | const int reads = !list_empty(&cfqq->fifo[0]); | 1023 | struct request *rq; |
775 | const int writes = !list_empty(&cfqq->fifo[1]); | ||
776 | unsigned long now = jiffies; | ||
777 | struct cfq_rq *crq; | 1024 | struct cfq_rq *crq; |
778 | 1025 | ||
779 | if (time_before(now, cfqq->last_fifo_expire + cfqd->cfq_fifo_batch_expire)) | 1026 | if (cfq_cfqq_fifo_expire(cfqq)) |
780 | return NULL; | 1027 | return NULL; |
781 | 1028 | ||
782 | crq = RQ_DATA(list_entry(cfqq->fifo[0].next, struct request, queuelist)); | 1029 | if (!list_empty(&cfqq->fifo)) { |
783 | if (reads && time_after(now, crq->queue_start + cfqd->cfq_fifo_expire_r)) { | 1030 | int fifo = cfq_cfqq_class_sync(cfqq); |
784 | cfqq->last_fifo_expire = now; | ||
785 | return crq; | ||
786 | } | ||
787 | 1031 | ||
788 | crq = RQ_DATA(list_entry(cfqq->fifo[1].next, struct request, queuelist)); | 1032 | crq = RQ_DATA(list_entry_fifo(cfqq->fifo.next)); |
789 | if (writes && time_after(now, crq->queue_start + cfqd->cfq_fifo_expire_w)) { | 1033 | rq = crq->request; |
790 | cfqq->last_fifo_expire = now; | 1034 | if (time_after(jiffies, rq->start_time + cfqd->cfq_fifo_expire[fifo])) { |
791 | return crq; | 1035 | cfq_mark_cfqq_fifo_expire(cfqq); |
1036 | return crq; | ||
1037 | } | ||
792 | } | 1038 | } |
793 | 1039 | ||
794 | return NULL; | 1040 | return NULL; |
795 | } | 1041 | } |
796 | 1042 | ||
797 | /* | 1043 | /* |
798 | * dispatch a single request from given queue | 1044 | * Scale schedule slice based on io priority. Use the sync time slice only |
1045 | * if a queue is marked sync and has sync io queued. A sync queue with async | ||
1046 | * io only, should not get full sync slice length. | ||
799 | */ | 1047 | */ |
1048 | static inline int | ||
1049 | cfq_prio_to_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq) | ||
1050 | { | ||
1051 | const int base_slice = cfqd->cfq_slice[cfq_cfqq_sync(cfqq)]; | ||
1052 | |||
1053 | WARN_ON(cfqq->ioprio >= IOPRIO_BE_NR); | ||
1054 | |||
1055 | return base_slice + (base_slice/CFQ_SLICE_SCALE * (4 - cfqq->ioprio)); | ||
1056 | } | ||
1057 | |||
800 | static inline void | 1058 | static inline void |
801 | cfq_dispatch_request(request_queue_t *q, struct cfq_data *cfqd, | 1059 | cfq_set_prio_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq) |
802 | struct cfq_queue *cfqq) | ||
803 | { | 1060 | { |
804 | struct cfq_rq *crq; | 1061 | cfqq->slice_end = cfq_prio_to_slice(cfqd, cfqq) + jiffies; |
1062 | } | ||
1063 | |||
1064 | static inline int | ||
1065 | cfq_prio_to_maxrq(struct cfq_data *cfqd, struct cfq_queue *cfqq) | ||
1066 | { | ||
1067 | const int base_rq = cfqd->cfq_slice_async_rq; | ||
1068 | |||
1069 | WARN_ON(cfqq->ioprio >= IOPRIO_BE_NR); | ||
1070 | |||
1071 | return 2 * (base_rq + base_rq * (CFQ_PRIO_LISTS - 1 - cfqq->ioprio)); | ||
1072 | } | ||
1073 | |||
1074 | /* | ||
1075 | * scheduler run of queue, if there are requests pending and no one in the | ||
1076 | * driver that will restart queueing | ||
1077 | */ | ||
1078 | static inline void cfq_schedule_dispatch(struct cfq_data *cfqd) | ||
1079 | { | ||
1080 | if (!cfqd->rq_in_driver && cfq_pending_requests(cfqd)) | ||
1081 | kblockd_schedule_work(&cfqd->unplug_work); | ||
1082 | } | ||
1083 | |||
1084 | /* | ||
1085 | * get next queue for service | ||
1086 | */ | ||
1087 | static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd, int force) | ||
1088 | { | ||
1089 | unsigned long now = jiffies; | ||
1090 | struct cfq_queue *cfqq; | ||
1091 | |||
1092 | cfqq = cfqd->active_queue; | ||
1093 | if (!cfqq) | ||
1094 | goto new_queue; | ||
1095 | |||
1096 | if (cfq_cfqq_expired(cfqq)) | ||
1097 | goto new_queue; | ||
805 | 1098 | ||
806 | /* | 1099 | /* |
807 | * follow expired path, else get first next available | 1100 | * slice has expired |
808 | */ | 1101 | */ |
809 | if ((crq = cfq_check_fifo(cfqq)) == NULL) { | 1102 | if (!cfq_cfqq_must_dispatch(cfqq) && time_after(now, cfqq->slice_end)) |
810 | if (cfqd->find_best_crq) | 1103 | goto expire; |
811 | crq = cfqq->next_crq; | ||
812 | else | ||
813 | crq = rb_entry_crq(rb_first(&cfqq->sort_list)); | ||
814 | } | ||
815 | |||
816 | cfqd->last_sector = crq->request->sector + crq->request->nr_sectors; | ||
817 | 1104 | ||
818 | /* | 1105 | /* |
819 | * finally, insert request into driver list | 1106 | * if queue has requests, dispatch one. if not, check if |
1107 | * enough slice is left to wait for one | ||
820 | */ | 1108 | */ |
821 | cfq_dispatch_sort(q, crq); | 1109 | if (!RB_EMPTY(&cfqq->sort_list)) |
1110 | goto keep_queue; | ||
1111 | else if (!force && cfq_cfqq_class_sync(cfqq) && | ||
1112 | time_before(now, cfqq->slice_end)) { | ||
1113 | if (cfq_arm_slice_timer(cfqd, cfqq)) | ||
1114 | return NULL; | ||
1115 | } | ||
1116 | |||
1117 | expire: | ||
1118 | cfq_slice_expired(cfqd, 0); | ||
1119 | new_queue: | ||
1120 | cfqq = cfq_set_active_queue(cfqd); | ||
1121 | keep_queue: | ||
1122 | return cfqq; | ||
822 | } | 1123 | } |
823 | 1124 | ||
824 | static int cfq_dispatch_requests(request_queue_t *q, int max_dispatch) | 1125 | static int |
1126 | __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq, | ||
1127 | int max_dispatch) | ||
825 | { | 1128 | { |
826 | struct cfq_data *cfqd = q->elevator->elevator_data; | 1129 | int dispatched = 0; |
827 | struct cfq_queue *cfqq; | ||
828 | struct list_head *entry, *tmp; | ||
829 | int queued, busy_queues, first_round; | ||
830 | 1130 | ||
831 | if (list_empty(&cfqd->rr_list)) | 1131 | BUG_ON(RB_EMPTY(&cfqq->sort_list)); |
832 | return 0; | ||
833 | 1132 | ||
834 | queued = 0; | 1133 | do { |
835 | first_round = 1; | 1134 | struct cfq_rq *crq; |
836 | restart: | ||
837 | busy_queues = 0; | ||
838 | list_for_each_safe(entry, tmp, &cfqd->rr_list) { | ||
839 | cfqq = list_entry_cfqq(entry); | ||
840 | 1135 | ||
841 | BUG_ON(RB_EMPTY(&cfqq->sort_list)); | 1136 | /* |
1137 | * follow expired path, else get first next available | ||
1138 | */ | ||
1139 | if ((crq = cfq_check_fifo(cfqq)) == NULL) | ||
1140 | crq = cfqq->next_crq; | ||
842 | 1141 | ||
843 | /* | 1142 | /* |
844 | * first round of queueing, only select from queues that | 1143 | * finally, insert request into driver dispatch list |
845 | * don't already have io in-flight | ||
846 | */ | 1144 | */ |
847 | if (first_round && cfqq->in_flight) | 1145 | cfq_dispatch_sort(cfqd->queue, crq); |
848 | continue; | 1146 | |
1147 | cfqd->dispatch_slice++; | ||
1148 | dispatched++; | ||
849 | 1149 | ||
850 | cfq_dispatch_request(q, cfqd, cfqq); | 1150 | if (!cfqd->active_cic) { |
1151 | atomic_inc(&crq->io_context->ioc->refcount); | ||
1152 | cfqd->active_cic = crq->io_context; | ||
1153 | } | ||
851 | 1154 | ||
852 | if (!RB_EMPTY(&cfqq->sort_list)) | 1155 | if (RB_EMPTY(&cfqq->sort_list)) |
853 | busy_queues++; | 1156 | break; |
854 | 1157 | ||
855 | queued++; | 1158 | } while (dispatched < max_dispatch); |
856 | } | 1159 | |
1160 | /* | ||
1161 | * if slice end isn't set yet, set it. if at least one request was | ||
1162 | * sync, use the sync time slice value | ||
1163 | */ | ||
1164 | if (!cfqq->slice_end) | ||
1165 | cfq_set_prio_slice(cfqd, cfqq); | ||
1166 | |||
1167 | /* | ||
1168 | * expire an async queue immediately if it has used up its slice. idle | ||
1169 | * queue always expire after 1 dispatch round. | ||
1170 | */ | ||
1171 | if ((!cfq_cfqq_sync(cfqq) && | ||
1172 | cfqd->dispatch_slice >= cfq_prio_to_maxrq(cfqd, cfqq)) || | ||
1173 | cfq_class_idle(cfqq)) | ||
1174 | cfq_slice_expired(cfqd, 0); | ||
1175 | |||
1176 | return dispatched; | ||
1177 | } | ||
1178 | |||
1179 | static int | ||
1180 | cfq_dispatch_requests(request_queue_t *q, int max_dispatch, int force) | ||
1181 | { | ||
1182 | struct cfq_data *cfqd = q->elevator->elevator_data; | ||
1183 | struct cfq_queue *cfqq; | ||
1184 | |||
1185 | if (!cfqd->busy_queues) | ||
1186 | return 0; | ||
857 | 1187 | ||
858 | if ((queued < max_dispatch) && (busy_queues || first_round)) { | 1188 | cfqq = cfq_select_queue(cfqd, force); |
859 | first_round = 0; | 1189 | if (cfqq) { |
860 | goto restart; | 1190 | cfq_clear_cfqq_must_dispatch(cfqq); |
1191 | cfq_clear_cfqq_wait_request(cfqq); | ||
1192 | del_timer(&cfqd->idle_slice_timer); | ||
1193 | |||
1194 | if (cfq_class_idle(cfqq)) | ||
1195 | max_dispatch = 1; | ||
1196 | |||
1197 | return __cfq_dispatch_requests(cfqd, cfqq, max_dispatch); | ||
861 | } | 1198 | } |
862 | 1199 | ||
863 | return queued; | 1200 | return 0; |
864 | } | 1201 | } |
865 | 1202 | ||
866 | static inline void cfq_account_dispatch(struct cfq_rq *crq) | 1203 | static inline void cfq_account_dispatch(struct cfq_rq *crq) |
867 | { | 1204 | { |
868 | struct cfq_queue *cfqq = crq->cfq_queue; | 1205 | struct cfq_queue *cfqq = crq->cfq_queue; |
869 | struct cfq_data *cfqd = cfqq->cfqd; | 1206 | struct cfq_data *cfqd = cfqq->cfqd; |
870 | unsigned long now, elapsed; | ||
871 | 1207 | ||
872 | if (!blk_fs_request(crq->request)) | 1208 | if (unlikely(!blk_fs_request(crq->request))) |
873 | return; | 1209 | return; |
874 | 1210 | ||
875 | /* | 1211 | /* |
876 | * accounted bit is necessary since some drivers will call | 1212 | * accounted bit is necessary since some drivers will call |
877 | * elv_next_request() many times for the same request (eg ide) | 1213 | * elv_next_request() many times for the same request (eg ide) |
878 | */ | 1214 | */ |
879 | if (crq->accounted) | 1215 | if (cfq_crq_in_driver(crq)) |
880 | return; | 1216 | return; |
881 | 1217 | ||
882 | now = jiffies; | 1218 | cfq_mark_crq_in_driver(crq); |
883 | if (cfqq->service_start == ~0UL) | 1219 | cfqd->rq_in_driver++; |
884 | cfqq->service_start = now; | ||
885 | |||
886 | /* | ||
887 | * on drives with tagged command queueing, command turn-around time | ||
888 | * doesn't necessarily reflect the time spent processing this very | ||
889 | * command inside the drive. so do the accounting differently there, | ||
890 | * by just sorting on the number of requests | ||
891 | */ | ||
892 | if (cfqd->cfq_tagged) { | ||
893 | if (time_after(now, cfqq->service_start + cfq_service)) { | ||
894 | cfqq->service_start = now; | ||
895 | cfqq->service_used /= 10; | ||
896 | } | ||
897 | |||
898 | cfqq->service_used++; | ||
899 | cfq_sort_rr_list(cfqq, 0); | ||
900 | } | ||
901 | |||
902 | elapsed = now - crq->queue_start; | ||
903 | if (elapsed > max_elapsed_dispatch) | ||
904 | max_elapsed_dispatch = elapsed; | ||
905 | |||
906 | crq->accounted = 1; | ||
907 | crq->service_start = now; | ||
908 | |||
909 | if (++cfqd->rq_in_driver >= CFQ_MAX_TAG && !cfqd->cfq_tagged) { | ||
910 | cfqq->cfqd->cfq_tagged = 1; | ||
911 | printk("cfq: depth %d reached, tagging now on\n", CFQ_MAX_TAG); | ||
912 | } | ||
913 | } | 1220 | } |
914 | 1221 | ||
915 | static inline void | 1222 | static inline void |
916 | cfq_account_completion(struct cfq_queue *cfqq, struct cfq_rq *crq) | 1223 | cfq_account_completion(struct cfq_queue *cfqq, struct cfq_rq *crq) |
917 | { | 1224 | { |
918 | struct cfq_data *cfqd = cfqq->cfqd; | 1225 | struct cfq_data *cfqd = cfqq->cfqd; |
1226 | unsigned long now; | ||
919 | 1227 | ||
920 | if (!crq->accounted) | 1228 | if (!cfq_crq_in_driver(crq)) |
921 | return; | 1229 | return; |
922 | 1230 | ||
1231 | now = jiffies; | ||
1232 | |||
923 | WARN_ON(!cfqd->rq_in_driver); | 1233 | WARN_ON(!cfqd->rq_in_driver); |
924 | cfqd->rq_in_driver--; | 1234 | cfqd->rq_in_driver--; |
925 | 1235 | ||
926 | if (!cfqd->cfq_tagged) { | 1236 | if (!cfq_class_idle(cfqq)) |
927 | unsigned long now = jiffies; | 1237 | cfqd->last_end_request = now; |
928 | unsigned long duration = now - crq->service_start; | ||
929 | 1238 | ||
930 | if (time_after(now, cfqq->service_start + cfq_service)) { | 1239 | if (!cfq_cfqq_dispatched(cfqq)) { |
931 | cfqq->service_start = now; | 1240 | if (cfq_cfqq_on_rr(cfqq)) { |
932 | cfqq->service_used >>= 3; | 1241 | cfqq->service_last = now; |
1242 | cfq_resort_rr_list(cfqq, 0); | ||
1243 | } | ||
1244 | if (cfq_cfqq_expired(cfqq)) { | ||
1245 | __cfq_slice_expired(cfqd, cfqq, 0); | ||
1246 | cfq_schedule_dispatch(cfqd); | ||
933 | } | 1247 | } |
934 | |||
935 | cfqq->service_used += duration; | ||
936 | cfq_sort_rr_list(cfqq, 0); | ||
937 | |||
938 | if (duration > max_elapsed_crq) | ||
939 | max_elapsed_crq = duration; | ||
940 | } | 1248 | } |
1249 | |||
1250 | if (cfq_crq_is_sync(crq)) | ||
1251 | crq->io_context->last_end_request = now; | ||
941 | } | 1252 | } |
942 | 1253 | ||
943 | static struct request *cfq_next_request(request_queue_t *q) | 1254 | static struct request *cfq_next_request(request_queue_t *q) |
@@ -950,7 +1261,18 @@ static struct request *cfq_next_request(request_queue_t *q) | |||
950 | dispatch: | 1261 | dispatch: |
951 | rq = list_entry_rq(q->queue_head.next); | 1262 | rq = list_entry_rq(q->queue_head.next); |
952 | 1263 | ||
953 | if ((crq = RQ_DATA(rq)) != NULL) { | 1264 | crq = RQ_DATA(rq); |
1265 | if (crq) { | ||
1266 | struct cfq_queue *cfqq = crq->cfq_queue; | ||
1267 | |||
1268 | /* | ||
1269 | * if idle window is disabled, allow queue buildup | ||
1270 | */ | ||
1271 | if (!cfq_crq_in_driver(crq) && | ||
1272 | !cfq_cfqq_idle_window(cfqq) && | ||
1273 | cfqd->rq_in_driver >= cfqd->cfq_max_depth) | ||
1274 | return NULL; | ||
1275 | |||
954 | cfq_remove_merge_hints(q, crq); | 1276 | cfq_remove_merge_hints(q, crq); |
955 | cfq_account_dispatch(crq); | 1277 | cfq_account_dispatch(crq); |
956 | } | 1278 | } |
@@ -958,7 +1280,7 @@ dispatch: | |||
958 | return rq; | 1280 | return rq; |
959 | } | 1281 | } |
960 | 1282 | ||
961 | if (cfq_dispatch_requests(q, cfqd->cfq_quantum)) | 1283 | if (cfq_dispatch_requests(q, cfqd->cfq_quantum, 0)) |
962 | goto dispatch; | 1284 | goto dispatch; |
963 | 1285 | ||
964 | return NULL; | 1286 | return NULL; |
@@ -972,13 +1294,21 @@ dispatch: | |||
972 | */ | 1294 | */ |
973 | static void cfq_put_queue(struct cfq_queue *cfqq) | 1295 | static void cfq_put_queue(struct cfq_queue *cfqq) |
974 | { | 1296 | { |
975 | BUG_ON(!atomic_read(&cfqq->ref)); | 1297 | struct cfq_data *cfqd = cfqq->cfqd; |
1298 | |||
1299 | BUG_ON(atomic_read(&cfqq->ref) <= 0); | ||
976 | 1300 | ||
977 | if (!atomic_dec_and_test(&cfqq->ref)) | 1301 | if (!atomic_dec_and_test(&cfqq->ref)) |
978 | return; | 1302 | return; |
979 | 1303 | ||
980 | BUG_ON(rb_first(&cfqq->sort_list)); | 1304 | BUG_ON(rb_first(&cfqq->sort_list)); |
981 | BUG_ON(cfqq->on_rr); | 1305 | BUG_ON(cfqq->allocated[READ] + cfqq->allocated[WRITE]); |
1306 | BUG_ON(cfq_cfqq_on_rr(cfqq)); | ||
1307 | |||
1308 | if (unlikely(cfqd->active_queue == cfqq)) { | ||
1309 | __cfq_slice_expired(cfqd, cfqq, 0); | ||
1310 | cfq_schedule_dispatch(cfqd); | ||
1311 | } | ||
982 | 1312 | ||
983 | cfq_put_cfqd(cfqq->cfqd); | 1313 | cfq_put_cfqd(cfqq->cfqd); |
984 | 1314 | ||
@@ -991,15 +1321,17 @@ static void cfq_put_queue(struct cfq_queue *cfqq) | |||
991 | } | 1321 | } |
992 | 1322 | ||
993 | static inline struct cfq_queue * | 1323 | static inline struct cfq_queue * |
994 | __cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned long key, const int hashval) | 1324 | __cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned int key, unsigned int prio, |
1325 | const int hashval) | ||
995 | { | 1326 | { |
996 | struct hlist_head *hash_list = &cfqd->cfq_hash[hashval]; | 1327 | struct hlist_head *hash_list = &cfqd->cfq_hash[hashval]; |
997 | struct hlist_node *entry, *next; | 1328 | struct hlist_node *entry, *next; |
998 | 1329 | ||
999 | hlist_for_each_safe(entry, next, hash_list) { | 1330 | hlist_for_each_safe(entry, next, hash_list) { |
1000 | struct cfq_queue *__cfqq = list_entry_qhash(entry); | 1331 | struct cfq_queue *__cfqq = list_entry_qhash(entry); |
1332 | const unsigned short __p = IOPRIO_PRIO_VALUE(__cfqq->ioprio_class, __cfqq->ioprio); | ||
1001 | 1333 | ||
1002 | if (__cfqq->key == key) | 1334 | if (__cfqq->key == key && (__p == prio || prio == CFQ_KEY_ANY)) |
1003 | return __cfqq; | 1335 | return __cfqq; |
1004 | } | 1336 | } |
1005 | 1337 | ||
@@ -1007,94 +1339,220 @@ __cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned long key, const int hashval) | |||
1007 | } | 1339 | } |
1008 | 1340 | ||
1009 | static struct cfq_queue * | 1341 | static struct cfq_queue * |
1010 | cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned long key) | 1342 | cfq_find_cfq_hash(struct cfq_data *cfqd, unsigned int key, unsigned short prio) |
1011 | { | 1343 | { |
1012 | return __cfq_find_cfq_hash(cfqd, key, hash_long(key, CFQ_QHASH_SHIFT)); | 1344 | return __cfq_find_cfq_hash(cfqd, key, prio, hash_long(key, CFQ_QHASH_SHIFT)); |
1013 | } | 1345 | } |
1014 | 1346 | ||
1015 | static inline void | 1347 | static void cfq_free_io_context(struct cfq_io_context *cic) |
1016 | cfq_rehash_cfqq(struct cfq_data *cfqd, struct cfq_queue **cfqq, | ||
1017 | struct cfq_io_context *cic) | ||
1018 | { | 1348 | { |
1019 | unsigned long hashkey = cfq_hash_key(cfqd, current); | 1349 | struct cfq_io_context *__cic; |
1020 | unsigned long hashval = hash_long(hashkey, CFQ_QHASH_SHIFT); | 1350 | struct list_head *entry, *next; |
1021 | struct cfq_queue *__cfqq; | ||
1022 | unsigned long flags; | ||
1023 | |||
1024 | spin_lock_irqsave(cfqd->queue->queue_lock, flags); | ||
1025 | 1351 | ||
1026 | hlist_del(&(*cfqq)->cfq_hash); | 1352 | list_for_each_safe(entry, next, &cic->list) { |
1027 | 1353 | __cic = list_entry(entry, struct cfq_io_context, list); | |
1028 | __cfqq = __cfq_find_cfq_hash(cfqd, hashkey, hashval); | 1354 | kmem_cache_free(cfq_ioc_pool, __cic); |
1029 | if (!__cfqq || __cfqq == *cfqq) { | ||
1030 | __cfqq = *cfqq; | ||
1031 | hlist_add_head(&__cfqq->cfq_hash, &cfqd->cfq_hash[hashval]); | ||
1032 | __cfqq->key_type = cfqd->key_type; | ||
1033 | } else { | ||
1034 | atomic_inc(&__cfqq->ref); | ||
1035 | cic->cfqq = __cfqq; | ||
1036 | cfq_put_queue(*cfqq); | ||
1037 | *cfqq = __cfqq; | ||
1038 | } | 1355 | } |
1039 | 1356 | ||
1040 | cic->cfqq = __cfqq; | 1357 | kmem_cache_free(cfq_ioc_pool, cic); |
1041 | spin_unlock_irqrestore(cfqd->queue->queue_lock, flags); | ||
1042 | } | 1358 | } |
1043 | 1359 | ||
1044 | static void cfq_free_io_context(struct cfq_io_context *cic) | 1360 | /* |
1361 | * Called with interrupts disabled | ||
1362 | */ | ||
1363 | static void cfq_exit_single_io_context(struct cfq_io_context *cic) | ||
1045 | { | 1364 | { |
1046 | kmem_cache_free(cfq_ioc_pool, cic); | 1365 | struct cfq_data *cfqd = cic->cfqq->cfqd; |
1366 | request_queue_t *q = cfqd->queue; | ||
1367 | |||
1368 | WARN_ON(!irqs_disabled()); | ||
1369 | |||
1370 | spin_lock(q->queue_lock); | ||
1371 | |||
1372 | if (unlikely(cic->cfqq == cfqd->active_queue)) { | ||
1373 | __cfq_slice_expired(cfqd, cic->cfqq, 0); | ||
1374 | cfq_schedule_dispatch(cfqd); | ||
1375 | } | ||
1376 | |||
1377 | cfq_put_queue(cic->cfqq); | ||
1378 | cic->cfqq = NULL; | ||
1379 | spin_unlock(q->queue_lock); | ||
1047 | } | 1380 | } |
1048 | 1381 | ||
1049 | /* | 1382 | /* |
1050 | * locking hierarchy is: io_context lock -> queue locks | 1383 | * Another task may update the task cic list, if it is doing a queue lookup |
1384 | * on its behalf. cfq_cic_lock excludes such concurrent updates | ||
1051 | */ | 1385 | */ |
1052 | static void cfq_exit_io_context(struct cfq_io_context *cic) | 1386 | static void cfq_exit_io_context(struct cfq_io_context *cic) |
1053 | { | 1387 | { |
1054 | struct cfq_queue *cfqq = cic->cfqq; | 1388 | struct cfq_io_context *__cic; |
1055 | struct list_head *entry = &cic->list; | 1389 | struct list_head *entry; |
1056 | request_queue_t *q; | ||
1057 | unsigned long flags; | 1390 | unsigned long flags; |
1058 | 1391 | ||
1392 | local_irq_save(flags); | ||
1393 | |||
1059 | /* | 1394 | /* |
1060 | * put the reference this task is holding to the various queues | 1395 | * put the reference this task is holding to the various queues |
1061 | */ | 1396 | */ |
1062 | spin_lock_irqsave(&cic->ioc->lock, flags); | 1397 | list_for_each(entry, &cic->list) { |
1063 | while ((entry = cic->list.next) != &cic->list) { | ||
1064 | struct cfq_io_context *__cic; | ||
1065 | |||
1066 | __cic = list_entry(entry, struct cfq_io_context, list); | 1398 | __cic = list_entry(entry, struct cfq_io_context, list); |
1067 | list_del(entry); | 1399 | cfq_exit_single_io_context(__cic); |
1068 | |||
1069 | q = __cic->cfqq->cfqd->queue; | ||
1070 | spin_lock(q->queue_lock); | ||
1071 | cfq_put_queue(__cic->cfqq); | ||
1072 | spin_unlock(q->queue_lock); | ||
1073 | } | 1400 | } |
1074 | 1401 | ||
1075 | q = cfqq->cfqd->queue; | 1402 | cfq_exit_single_io_context(cic); |
1076 | spin_lock(q->queue_lock); | 1403 | local_irq_restore(flags); |
1077 | cfq_put_queue(cfqq); | ||
1078 | spin_unlock(q->queue_lock); | ||
1079 | |||
1080 | cic->cfqq = NULL; | ||
1081 | spin_unlock_irqrestore(&cic->ioc->lock, flags); | ||
1082 | } | 1404 | } |
1083 | 1405 | ||
1084 | static struct cfq_io_context *cfq_alloc_io_context(int gfp_flags) | 1406 | static struct cfq_io_context * |
1407 | cfq_alloc_io_context(struct cfq_data *cfqd, int gfp_mask) | ||
1085 | { | 1408 | { |
1086 | struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_flags); | 1409 | struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_mask); |
1087 | 1410 | ||
1088 | if (cic) { | 1411 | if (cic) { |
1089 | cic->dtor = cfq_free_io_context; | ||
1090 | cic->exit = cfq_exit_io_context; | ||
1091 | INIT_LIST_HEAD(&cic->list); | 1412 | INIT_LIST_HEAD(&cic->list); |
1092 | cic->cfqq = NULL; | 1413 | cic->cfqq = NULL; |
1414 | cic->key = NULL; | ||
1415 | cic->last_end_request = jiffies; | ||
1416 | cic->ttime_total = 0; | ||
1417 | cic->ttime_samples = 0; | ||
1418 | cic->ttime_mean = 0; | ||
1419 | cic->dtor = cfq_free_io_context; | ||
1420 | cic->exit = cfq_exit_io_context; | ||
1093 | } | 1421 | } |
1094 | 1422 | ||
1095 | return cic; | 1423 | return cic; |
1096 | } | 1424 | } |
1097 | 1425 | ||
1426 | static void cfq_init_prio_data(struct cfq_queue *cfqq) | ||
1427 | { | ||
1428 | struct task_struct *tsk = current; | ||
1429 | int ioprio_class; | ||
1430 | |||
1431 | if (!cfq_cfqq_prio_changed(cfqq)) | ||
1432 | return; | ||
1433 | |||
1434 | ioprio_class = IOPRIO_PRIO_CLASS(tsk->ioprio); | ||
1435 | switch (ioprio_class) { | ||
1436 | default: | ||
1437 | printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class); | ||
1438 | case IOPRIO_CLASS_NONE: | ||
1439 | /* | ||
1440 | * no prio set, place us in the middle of the BE classes | ||
1441 | */ | ||
1442 | cfqq->ioprio = task_nice_ioprio(tsk); | ||
1443 | cfqq->ioprio_class = IOPRIO_CLASS_BE; | ||
1444 | break; | ||
1445 | case IOPRIO_CLASS_RT: | ||
1446 | cfqq->ioprio = task_ioprio(tsk); | ||
1447 | cfqq->ioprio_class = IOPRIO_CLASS_RT; | ||
1448 | break; | ||
1449 | case IOPRIO_CLASS_BE: | ||
1450 | cfqq->ioprio = task_ioprio(tsk); | ||
1451 | cfqq->ioprio_class = IOPRIO_CLASS_BE; | ||
1452 | break; | ||
1453 | case IOPRIO_CLASS_IDLE: | ||
1454 | cfqq->ioprio_class = IOPRIO_CLASS_IDLE; | ||
1455 | cfqq->ioprio = 7; | ||
1456 | cfq_clear_cfqq_idle_window(cfqq); | ||
1457 | break; | ||
1458 | } | ||
1459 | |||
1460 | /* | ||
1461 | * keep track of original prio settings in case we have to temporarily | ||
1462 | * elevate the priority of this queue | ||
1463 | */ | ||
1464 | cfqq->org_ioprio = cfqq->ioprio; | ||
1465 | cfqq->org_ioprio_class = cfqq->ioprio_class; | ||
1466 | |||
1467 | if (cfq_cfqq_on_rr(cfqq)) | ||
1468 | cfq_resort_rr_list(cfqq, 0); | ||
1469 | |||
1470 | cfq_clear_cfqq_prio_changed(cfqq); | ||
1471 | } | ||
1472 | |||
1473 | static inline void changed_ioprio(struct cfq_queue *cfqq) | ||
1474 | { | ||
1475 | if (cfqq) { | ||
1476 | struct cfq_data *cfqd = cfqq->cfqd; | ||
1477 | |||
1478 | spin_lock(cfqd->queue->queue_lock); | ||
1479 | cfq_mark_cfqq_prio_changed(cfqq); | ||
1480 | cfq_init_prio_data(cfqq); | ||
1481 | spin_unlock(cfqd->queue->queue_lock); | ||
1482 | } | ||
1483 | } | ||
1484 | |||
1485 | /* | ||
1486 | * callback from sys_ioprio_set, irqs are disabled | ||
1487 | */ | ||
1488 | static int cfq_ioc_set_ioprio(struct io_context *ioc, unsigned int ioprio) | ||
1489 | { | ||
1490 | struct cfq_io_context *cic = ioc->cic; | ||
1491 | |||
1492 | changed_ioprio(cic->cfqq); | ||
1493 | |||
1494 | list_for_each_entry(cic, &cic->list, list) | ||
1495 | changed_ioprio(cic->cfqq); | ||
1496 | |||
1497 | return 0; | ||
1498 | } | ||
1499 | |||
1500 | static struct cfq_queue * | ||
1501 | cfq_get_queue(struct cfq_data *cfqd, unsigned int key, unsigned short ioprio, | ||
1502 | int gfp_mask) | ||
1503 | { | ||
1504 | const int hashval = hash_long(key, CFQ_QHASH_SHIFT); | ||
1505 | struct cfq_queue *cfqq, *new_cfqq = NULL; | ||
1506 | |||
1507 | retry: | ||
1508 | cfqq = __cfq_find_cfq_hash(cfqd, key, ioprio, hashval); | ||
1509 | |||
1510 | if (!cfqq) { | ||
1511 | if (new_cfqq) { | ||
1512 | cfqq = new_cfqq; | ||
1513 | new_cfqq = NULL; | ||
1514 | } else if (gfp_mask & __GFP_WAIT) { | ||
1515 | spin_unlock_irq(cfqd->queue->queue_lock); | ||
1516 | new_cfqq = kmem_cache_alloc(cfq_pool, gfp_mask); | ||
1517 | spin_lock_irq(cfqd->queue->queue_lock); | ||
1518 | goto retry; | ||
1519 | } else { | ||
1520 | cfqq = kmem_cache_alloc(cfq_pool, gfp_mask); | ||
1521 | if (!cfqq) | ||
1522 | goto out; | ||
1523 | } | ||
1524 | |||
1525 | memset(cfqq, 0, sizeof(*cfqq)); | ||
1526 | |||
1527 | INIT_HLIST_NODE(&cfqq->cfq_hash); | ||
1528 | INIT_LIST_HEAD(&cfqq->cfq_list); | ||
1529 | RB_CLEAR_ROOT(&cfqq->sort_list); | ||
1530 | INIT_LIST_HEAD(&cfqq->fifo); | ||
1531 | |||
1532 | cfqq->key = key; | ||
1533 | hlist_add_head(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]); | ||
1534 | atomic_set(&cfqq->ref, 0); | ||
1535 | cfqq->cfqd = cfqd; | ||
1536 | atomic_inc(&cfqd->ref); | ||
1537 | cfqq->service_last = 0; | ||
1538 | /* | ||
1539 | * set ->slice_left to allow preemption for a new process | ||
1540 | */ | ||
1541 | cfqq->slice_left = 2 * cfqd->cfq_slice_idle; | ||
1542 | cfq_mark_cfqq_idle_window(cfqq); | ||
1543 | cfq_mark_cfqq_prio_changed(cfqq); | ||
1544 | cfq_init_prio_data(cfqq); | ||
1545 | } | ||
1546 | |||
1547 | if (new_cfqq) | ||
1548 | kmem_cache_free(cfq_pool, new_cfqq); | ||
1549 | |||
1550 | atomic_inc(&cfqq->ref); | ||
1551 | out: | ||
1552 | WARN_ON((gfp_mask & __GFP_WAIT) && !cfqq); | ||
1553 | return cfqq; | ||
1554 | } | ||
1555 | |||
1098 | /* | 1556 | /* |
1099 | * Setup general io context and cfq io context. There can be several cfq | 1557 | * Setup general io context and cfq io context. There can be several cfq |
1100 | * io contexts per general io context, if this process is doing io to more | 1558 | * io contexts per general io context, if this process is doing io to more |
@@ -1102,39 +1560,39 @@ static struct cfq_io_context *cfq_alloc_io_context(int gfp_flags) | |||
1102 | * cfqq, so we don't need to worry about it disappearing | 1560 | * cfqq, so we don't need to worry about it disappearing |
1103 | */ | 1561 | */ |
1104 | static struct cfq_io_context * | 1562 | static struct cfq_io_context * |
1105 | cfq_get_io_context(struct cfq_queue **cfqq, int gfp_flags) | 1563 | cfq_get_io_context(struct cfq_data *cfqd, pid_t pid, int gfp_mask) |
1106 | { | 1564 | { |
1107 | struct cfq_data *cfqd = (*cfqq)->cfqd; | 1565 | struct io_context *ioc = NULL; |
1108 | struct cfq_queue *__cfqq = *cfqq; | ||
1109 | struct cfq_io_context *cic; | 1566 | struct cfq_io_context *cic; |
1110 | struct io_context *ioc; | ||
1111 | 1567 | ||
1112 | might_sleep_if(gfp_flags & __GFP_WAIT); | 1568 | might_sleep_if(gfp_mask & __GFP_WAIT); |
1113 | 1569 | ||
1114 | ioc = get_io_context(gfp_flags); | 1570 | ioc = get_io_context(gfp_mask); |
1115 | if (!ioc) | 1571 | if (!ioc) |
1116 | return NULL; | 1572 | return NULL; |
1117 | 1573 | ||
1118 | if ((cic = ioc->cic) == NULL) { | 1574 | if ((cic = ioc->cic) == NULL) { |
1119 | cic = cfq_alloc_io_context(gfp_flags); | 1575 | cic = cfq_alloc_io_context(cfqd, gfp_mask); |
1120 | 1576 | ||
1121 | if (cic == NULL) | 1577 | if (cic == NULL) |
1122 | goto err; | 1578 | goto err; |
1123 | 1579 | ||
1580 | /* | ||
1581 | * manually increment generic io_context usage count, it | ||
1582 | * cannot go away since we are already holding one ref to it | ||
1583 | */ | ||
1124 | ioc->cic = cic; | 1584 | ioc->cic = cic; |
1585 | ioc->set_ioprio = cfq_ioc_set_ioprio; | ||
1125 | cic->ioc = ioc; | 1586 | cic->ioc = ioc; |
1126 | cic->cfqq = __cfqq; | 1587 | cic->key = cfqd; |
1127 | atomic_inc(&__cfqq->ref); | 1588 | atomic_inc(&cfqd->ref); |
1128 | } else { | 1589 | } else { |
1129 | struct cfq_io_context *__cic; | 1590 | struct cfq_io_context *__cic; |
1130 | unsigned long flags; | ||
1131 | 1591 | ||
1132 | /* | 1592 | /* |
1133 | * since the first cic on the list is actually the head | 1593 | * the first cic on the list is actually the head itself |
1134 | * itself, need to check this here or we'll duplicate an | ||
1135 | * cic per ioc for no reason | ||
1136 | */ | 1594 | */ |
1137 | if (cic->cfqq == __cfqq) | 1595 | if (cic->key == cfqd) |
1138 | goto out; | 1596 | goto out; |
1139 | 1597 | ||
1140 | /* | 1598 | /* |
@@ -1142,152 +1600,262 @@ cfq_get_io_context(struct cfq_queue **cfqq, int gfp_flags) | |||
1142 | * should be ok here, the list will usually not be more than | 1600 | * should be ok here, the list will usually not be more than |
1143 | * 1 or a few entries long | 1601 | * 1 or a few entries long |
1144 | */ | 1602 | */ |
1145 | spin_lock_irqsave(&ioc->lock, flags); | ||
1146 | list_for_each_entry(__cic, &cic->list, list) { | 1603 | list_for_each_entry(__cic, &cic->list, list) { |
1147 | /* | 1604 | /* |
1148 | * this process is already holding a reference to | 1605 | * this process is already holding a reference to |
1149 | * this queue, so no need to get one more | 1606 | * this queue, so no need to get one more |
1150 | */ | 1607 | */ |
1151 | if (__cic->cfqq == __cfqq) { | 1608 | if (__cic->key == cfqd) { |
1152 | cic = __cic; | 1609 | cic = __cic; |
1153 | spin_unlock_irqrestore(&ioc->lock, flags); | ||
1154 | goto out; | 1610 | goto out; |
1155 | } | 1611 | } |
1156 | } | 1612 | } |
1157 | spin_unlock_irqrestore(&ioc->lock, flags); | ||
1158 | 1613 | ||
1159 | /* | 1614 | /* |
1160 | * nope, process doesn't have a cic assoicated with this | 1615 | * nope, process doesn't have a cic assoicated with this |
1161 | * cfqq yet. get a new one and add to list | 1616 | * cfqq yet. get a new one and add to list |
1162 | */ | 1617 | */ |
1163 | __cic = cfq_alloc_io_context(gfp_flags); | 1618 | __cic = cfq_alloc_io_context(cfqd, gfp_mask); |
1164 | if (__cic == NULL) | 1619 | if (__cic == NULL) |
1165 | goto err; | 1620 | goto err; |
1166 | 1621 | ||
1167 | __cic->ioc = ioc; | 1622 | __cic->ioc = ioc; |
1168 | __cic->cfqq = __cfqq; | 1623 | __cic->key = cfqd; |
1169 | atomic_inc(&__cfqq->ref); | 1624 | atomic_inc(&cfqd->ref); |
1170 | spin_lock_irqsave(&ioc->lock, flags); | ||
1171 | list_add(&__cic->list, &cic->list); | 1625 | list_add(&__cic->list, &cic->list); |
1172 | spin_unlock_irqrestore(&ioc->lock, flags); | ||
1173 | |||
1174 | cic = __cic; | 1626 | cic = __cic; |
1175 | *cfqq = __cfqq; | ||
1176 | } | 1627 | } |
1177 | 1628 | ||
1178 | out: | 1629 | out: |
1179 | /* | ||
1180 | * if key_type has been changed on the fly, we lazily rehash | ||
1181 | * each queue at lookup time | ||
1182 | */ | ||
1183 | if ((*cfqq)->key_type != cfqd->key_type) | ||
1184 | cfq_rehash_cfqq(cfqd, cfqq, cic); | ||
1185 | |||
1186 | return cic; | 1630 | return cic; |
1187 | err: | 1631 | err: |
1188 | put_io_context(ioc); | 1632 | put_io_context(ioc); |
1189 | return NULL; | 1633 | return NULL; |
1190 | } | 1634 | } |
1191 | 1635 | ||
1192 | static struct cfq_queue * | 1636 | static void |
1193 | __cfq_get_queue(struct cfq_data *cfqd, unsigned long key, int gfp_mask) | 1637 | cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_io_context *cic) |
1194 | { | 1638 | { |
1195 | const int hashval = hash_long(key, CFQ_QHASH_SHIFT); | 1639 | unsigned long elapsed, ttime; |
1196 | struct cfq_queue *cfqq, *new_cfqq = NULL; | ||
1197 | 1640 | ||
1198 | retry: | 1641 | /* |
1199 | cfqq = __cfq_find_cfq_hash(cfqd, key, hashval); | 1642 | * if this context already has stuff queued, thinktime is from |
1200 | 1643 | * last queue not last end | |
1201 | if (!cfqq) { | 1644 | */ |
1202 | if (new_cfqq) { | 1645 | #if 0 |
1203 | cfqq = new_cfqq; | 1646 | if (time_after(cic->last_end_request, cic->last_queue)) |
1204 | new_cfqq = NULL; | 1647 | elapsed = jiffies - cic->last_end_request; |
1205 | } else { | 1648 | else |
1206 | spin_unlock_irq(cfqd->queue->queue_lock); | 1649 | elapsed = jiffies - cic->last_queue; |
1207 | new_cfqq = kmem_cache_alloc(cfq_pool, gfp_mask); | 1650 | #else |
1208 | spin_lock_irq(cfqd->queue->queue_lock); | 1651 | elapsed = jiffies - cic->last_end_request; |
1652 | #endif | ||
1209 | 1653 | ||
1210 | if (!new_cfqq && !(gfp_mask & __GFP_WAIT)) | 1654 | ttime = min(elapsed, 2UL * cfqd->cfq_slice_idle); |
1211 | goto out; | ||
1212 | 1655 | ||
1213 | goto retry; | 1656 | cic->ttime_samples = (7*cic->ttime_samples + 256) / 8; |
1214 | } | 1657 | cic->ttime_total = (7*cic->ttime_total + 256*ttime) / 8; |
1658 | cic->ttime_mean = (cic->ttime_total + 128) / cic->ttime_samples; | ||
1659 | } | ||
1215 | 1660 | ||
1216 | memset(cfqq, 0, sizeof(*cfqq)); | 1661 | #define sample_valid(samples) ((samples) > 80) |
1217 | 1662 | ||
1218 | INIT_HLIST_NODE(&cfqq->cfq_hash); | 1663 | /* |
1219 | INIT_LIST_HEAD(&cfqq->cfq_list); | 1664 | * Disable idle window if the process thinks too long or seeks so much that |
1220 | RB_CLEAR_ROOT(&cfqq->sort_list); | 1665 | * it doesn't matter |
1221 | INIT_LIST_HEAD(&cfqq->fifo[0]); | 1666 | */ |
1222 | INIT_LIST_HEAD(&cfqq->fifo[1]); | 1667 | static void |
1668 | cfq_update_idle_window(struct cfq_data *cfqd, struct cfq_queue *cfqq, | ||
1669 | struct cfq_io_context *cic) | ||
1670 | { | ||
1671 | int enable_idle = cfq_cfqq_idle_window(cfqq); | ||
1223 | 1672 | ||
1224 | cfqq->key = key; | 1673 | if (!cic->ioc->task || !cfqd->cfq_slice_idle) |
1225 | hlist_add_head(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]); | 1674 | enable_idle = 0; |
1226 | atomic_set(&cfqq->ref, 0); | 1675 | else if (sample_valid(cic->ttime_samples)) { |
1227 | cfqq->cfqd = cfqd; | 1676 | if (cic->ttime_mean > cfqd->cfq_slice_idle) |
1228 | atomic_inc(&cfqd->ref); | 1677 | enable_idle = 0; |
1229 | cfqq->key_type = cfqd->key_type; | 1678 | else |
1230 | cfqq->service_start = ~0UL; | 1679 | enable_idle = 1; |
1231 | } | 1680 | } |
1232 | 1681 | ||
1233 | if (new_cfqq) | 1682 | if (enable_idle) |
1234 | kmem_cache_free(cfq_pool, new_cfqq); | 1683 | cfq_mark_cfqq_idle_window(cfqq); |
1684 | else | ||
1685 | cfq_clear_cfqq_idle_window(cfqq); | ||
1686 | } | ||
1235 | 1687 | ||
1236 | atomic_inc(&cfqq->ref); | 1688 | |
1237 | out: | 1689 | /* |
1238 | WARN_ON((gfp_mask & __GFP_WAIT) && !cfqq); | 1690 | * Check if new_cfqq should preempt the currently active queue. Return 0 for |
1239 | return cfqq; | 1691 | * no or if we aren't sure, a 1 will cause a preempt. |
1692 | */ | ||
1693 | static int | ||
1694 | cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq, | ||
1695 | struct cfq_rq *crq) | ||
1696 | { | ||
1697 | struct cfq_queue *cfqq = cfqd->active_queue; | ||
1698 | |||
1699 | if (cfq_class_idle(new_cfqq)) | ||
1700 | return 0; | ||
1701 | |||
1702 | if (!cfqq) | ||
1703 | return 1; | ||
1704 | |||
1705 | if (cfq_class_idle(cfqq)) | ||
1706 | return 1; | ||
1707 | if (!cfq_cfqq_wait_request(new_cfqq)) | ||
1708 | return 0; | ||
1709 | /* | ||
1710 | * if it doesn't have slice left, forget it | ||
1711 | */ | ||
1712 | if (new_cfqq->slice_left < cfqd->cfq_slice_idle) | ||
1713 | return 0; | ||
1714 | if (cfq_crq_is_sync(crq) && !cfq_cfqq_sync(cfqq)) | ||
1715 | return 1; | ||
1716 | |||
1717 | return 0; | ||
1718 | } | ||
1719 | |||
1720 | /* | ||
1721 | * cfqq preempts the active queue. if we allowed preempt with no slice left, | ||
1722 | * let it have half of its nominal slice. | ||
1723 | */ | ||
1724 | static void cfq_preempt_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq) | ||
1725 | { | ||
1726 | struct cfq_queue *__cfqq, *next; | ||
1727 | |||
1728 | list_for_each_entry_safe(__cfqq, next, &cfqd->cur_rr, cfq_list) | ||
1729 | cfq_resort_rr_list(__cfqq, 1); | ||
1730 | |||
1731 | if (!cfqq->slice_left) | ||
1732 | cfqq->slice_left = cfq_prio_to_slice(cfqd, cfqq) / 2; | ||
1733 | |||
1734 | cfqq->slice_end = cfqq->slice_left + jiffies; | ||
1735 | __cfq_slice_expired(cfqd, cfqq, 1); | ||
1736 | __cfq_set_active_queue(cfqd, cfqq); | ||
1737 | } | ||
1738 | |||
1739 | /* | ||
1740 | * should really be a ll_rw_blk.c helper | ||
1741 | */ | ||
1742 | static void cfq_start_queueing(struct cfq_data *cfqd, struct cfq_queue *cfqq) | ||
1743 | { | ||
1744 | request_queue_t *q = cfqd->queue; | ||
1745 | |||
1746 | if (!blk_queue_plugged(q)) | ||
1747 | q->request_fn(q); | ||
1748 | else | ||
1749 | __generic_unplug_device(q); | ||
1240 | } | 1750 | } |
1241 | 1751 | ||
1242 | static void cfq_enqueue(struct cfq_data *cfqd, struct cfq_rq *crq) | 1752 | /* |
1753 | * Called when a new fs request (crq) is added (to cfqq). Check if there's | ||
1754 | * something we should do about it | ||
1755 | */ | ||
1756 | static void | ||
1757 | cfq_crq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq, | ||
1758 | struct cfq_rq *crq) | ||
1243 | { | 1759 | { |
1244 | crq->is_sync = 0; | 1760 | const int sync = cfq_crq_is_sync(crq); |
1245 | if (rq_data_dir(crq->request) == READ || current->flags & PF_SYNCWRITE) | 1761 | |
1246 | crq->is_sync = 1; | 1762 | cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq); |
1763 | |||
1764 | if (sync) { | ||
1765 | struct cfq_io_context *cic = crq->io_context; | ||
1766 | |||
1767 | cfq_update_io_thinktime(cfqd, cic); | ||
1768 | cfq_update_idle_window(cfqd, cfqq, cic); | ||
1769 | |||
1770 | cic->last_queue = jiffies; | ||
1771 | } | ||
1772 | |||
1773 | if (cfqq == cfqd->active_queue) { | ||
1774 | /* | ||
1775 | * if we are waiting for a request for this queue, let it rip | ||
1776 | * immediately and flag that we must not expire this queue | ||
1777 | * just now | ||
1778 | */ | ||
1779 | if (cfq_cfqq_wait_request(cfqq)) { | ||
1780 | cfq_mark_cfqq_must_dispatch(cfqq); | ||
1781 | del_timer(&cfqd->idle_slice_timer); | ||
1782 | cfq_start_queueing(cfqd, cfqq); | ||
1783 | } | ||
1784 | } else if (cfq_should_preempt(cfqd, cfqq, crq)) { | ||
1785 | /* | ||
1786 | * not the active queue - expire current slice if it is | ||
1787 | * idle and has expired it's mean thinktime or this new queue | ||
1788 | * has some old slice time left and is of higher priority | ||
1789 | */ | ||
1790 | cfq_preempt_queue(cfqd, cfqq); | ||
1791 | cfq_mark_cfqq_must_dispatch(cfqq); | ||
1792 | cfq_start_queueing(cfqd, cfqq); | ||
1793 | } | ||
1794 | } | ||
1795 | |||
1796 | static void cfq_enqueue(struct cfq_data *cfqd, struct request *rq) | ||
1797 | { | ||
1798 | struct cfq_rq *crq = RQ_DATA(rq); | ||
1799 | struct cfq_queue *cfqq = crq->cfq_queue; | ||
1800 | |||
1801 | cfq_init_prio_data(cfqq); | ||
1247 | 1802 | ||
1248 | cfq_add_crq_rb(crq); | 1803 | cfq_add_crq_rb(crq); |
1249 | crq->queue_start = jiffies; | ||
1250 | 1804 | ||
1251 | list_add_tail(&crq->request->queuelist, &crq->cfq_queue->fifo[crq->is_sync]); | 1805 | list_add_tail(&rq->queuelist, &cfqq->fifo); |
1806 | |||
1807 | if (rq_mergeable(rq)) { | ||
1808 | cfq_add_crq_hash(cfqd, crq); | ||
1809 | |||
1810 | if (!cfqd->queue->last_merge) | ||
1811 | cfqd->queue->last_merge = rq; | ||
1812 | } | ||
1813 | |||
1814 | cfq_crq_enqueued(cfqd, cfqq, crq); | ||
1252 | } | 1815 | } |
1253 | 1816 | ||
1254 | static void | 1817 | static void |
1255 | cfq_insert_request(request_queue_t *q, struct request *rq, int where) | 1818 | cfq_insert_request(request_queue_t *q, struct request *rq, int where) |
1256 | { | 1819 | { |
1257 | struct cfq_data *cfqd = q->elevator->elevator_data; | 1820 | struct cfq_data *cfqd = q->elevator->elevator_data; |
1258 | struct cfq_rq *crq = RQ_DATA(rq); | ||
1259 | 1821 | ||
1260 | switch (where) { | 1822 | switch (where) { |
1261 | case ELEVATOR_INSERT_BACK: | 1823 | case ELEVATOR_INSERT_BACK: |
1262 | while (cfq_dispatch_requests(q, cfqd->cfq_quantum)) | 1824 | while (cfq_dispatch_requests(q, INT_MAX, 1)) |
1263 | ; | 1825 | ; |
1264 | list_add_tail(&rq->queuelist, &q->queue_head); | 1826 | list_add_tail(&rq->queuelist, &q->queue_head); |
1827 | /* | ||
1828 | * If we were idling with pending requests on | ||
1829 | * inactive cfqqs, force dispatching will | ||
1830 | * remove the idle timer and the queue won't | ||
1831 | * be kicked by __make_request() afterward. | ||
1832 | * Kick it here. | ||
1833 | */ | ||
1834 | cfq_schedule_dispatch(cfqd); | ||
1265 | break; | 1835 | break; |
1266 | case ELEVATOR_INSERT_FRONT: | 1836 | case ELEVATOR_INSERT_FRONT: |
1267 | list_add(&rq->queuelist, &q->queue_head); | 1837 | list_add(&rq->queuelist, &q->queue_head); |
1268 | break; | 1838 | break; |
1269 | case ELEVATOR_INSERT_SORT: | 1839 | case ELEVATOR_INSERT_SORT: |
1270 | BUG_ON(!blk_fs_request(rq)); | 1840 | BUG_ON(!blk_fs_request(rq)); |
1271 | cfq_enqueue(cfqd, crq); | 1841 | cfq_enqueue(cfqd, rq); |
1272 | break; | 1842 | break; |
1273 | default: | 1843 | default: |
1274 | printk("%s: bad insert point %d\n", __FUNCTION__,where); | 1844 | printk("%s: bad insert point %d\n", __FUNCTION__,where); |
1275 | return; | 1845 | return; |
1276 | } | 1846 | } |
1847 | } | ||
1277 | 1848 | ||
1278 | if (rq_mergeable(rq)) { | 1849 | static inline int cfq_pending_requests(struct cfq_data *cfqd) |
1279 | cfq_add_crq_hash(cfqd, crq); | 1850 | { |
1280 | 1851 | return !list_empty(&cfqd->queue->queue_head) || cfqd->busy_queues; | |
1281 | if (!q->last_merge) | ||
1282 | q->last_merge = rq; | ||
1283 | } | ||
1284 | } | 1852 | } |
1285 | 1853 | ||
1286 | static int cfq_queue_empty(request_queue_t *q) | 1854 | static int cfq_queue_empty(request_queue_t *q) |
1287 | { | 1855 | { |
1288 | struct cfq_data *cfqd = q->elevator->elevator_data; | 1856 | struct cfq_data *cfqd = q->elevator->elevator_data; |
1289 | 1857 | ||
1290 | return list_empty(&q->queue_head) && list_empty(&cfqd->rr_list); | 1858 | return !cfq_pending_requests(cfqd); |
1291 | } | 1859 | } |
1292 | 1860 | ||
1293 | static void cfq_completed_request(request_queue_t *q, struct request *rq) | 1861 | static void cfq_completed_request(request_queue_t *q, struct request *rq) |
@@ -1300,9 +1868,11 @@ static void cfq_completed_request(request_queue_t *q, struct request *rq) | |||
1300 | 1868 | ||
1301 | cfqq = crq->cfq_queue; | 1869 | cfqq = crq->cfq_queue; |
1302 | 1870 | ||
1303 | if (crq->in_flight) { | 1871 | if (cfq_crq_in_flight(crq)) { |
1304 | WARN_ON(!cfqq->in_flight); | 1872 | const int sync = cfq_crq_is_sync(crq); |
1305 | cfqq->in_flight--; | 1873 | |
1874 | WARN_ON(!cfqq->on_dispatch[sync]); | ||
1875 | cfqq->on_dispatch[sync]--; | ||
1306 | } | 1876 | } |
1307 | 1877 | ||
1308 | cfq_account_completion(cfqq, crq); | 1878 | cfq_account_completion(cfqq, crq); |
@@ -1332,51 +1902,136 @@ cfq_latter_request(request_queue_t *q, struct request *rq) | |||
1332 | return NULL; | 1902 | return NULL; |
1333 | } | 1903 | } |
1334 | 1904 | ||
1335 | static int cfq_may_queue(request_queue_t *q, int rw) | 1905 | /* |
1906 | * we temporarily boost lower priority queues if they are holding fs exclusive | ||
1907 | * resources. they are boosted to normal prio (CLASS_BE/4) | ||
1908 | */ | ||
1909 | static void cfq_prio_boost(struct cfq_queue *cfqq) | ||
1336 | { | 1910 | { |
1337 | struct cfq_data *cfqd = q->elevator->elevator_data; | 1911 | const int ioprio_class = cfqq->ioprio_class; |
1338 | struct cfq_queue *cfqq; | 1912 | const int ioprio = cfqq->ioprio; |
1339 | int ret = ELV_MQUEUE_MAY; | ||
1340 | 1913 | ||
1341 | if (current->flags & PF_MEMALLOC) | 1914 | if (has_fs_excl()) { |
1342 | return ELV_MQUEUE_MAY; | 1915 | /* |
1916 | * boost idle prio on transactions that would lock out other | ||
1917 | * users of the filesystem | ||
1918 | */ | ||
1919 | if (cfq_class_idle(cfqq)) | ||
1920 | cfqq->ioprio_class = IOPRIO_CLASS_BE; | ||
1921 | if (cfqq->ioprio > IOPRIO_NORM) | ||
1922 | cfqq->ioprio = IOPRIO_NORM; | ||
1923 | } else { | ||
1924 | /* | ||
1925 | * check if we need to unboost the queue | ||
1926 | */ | ||
1927 | if (cfqq->ioprio_class != cfqq->org_ioprio_class) | ||
1928 | cfqq->ioprio_class = cfqq->org_ioprio_class; | ||
1929 | if (cfqq->ioprio != cfqq->org_ioprio) | ||
1930 | cfqq->ioprio = cfqq->org_ioprio; | ||
1931 | } | ||
1343 | 1932 | ||
1344 | cfqq = cfq_find_cfq_hash(cfqd, cfq_hash_key(cfqd, current)); | 1933 | /* |
1345 | if (cfqq) { | 1934 | * refile between round-robin lists if we moved the priority class |
1346 | int limit = cfqd->max_queued; | 1935 | */ |
1936 | if ((ioprio_class != cfqq->ioprio_class || ioprio != cfqq->ioprio) && | ||
1937 | cfq_cfqq_on_rr(cfqq)) | ||
1938 | cfq_resort_rr_list(cfqq, 0); | ||
1939 | } | ||
1347 | 1940 | ||
1348 | if (cfqq->allocated[rw] < cfqd->cfq_queued) | 1941 | static inline pid_t cfq_queue_pid(struct task_struct *task, int rw) |
1349 | return ELV_MQUEUE_MUST; | 1942 | { |
1943 | if (rw == READ || process_sync(task)) | ||
1944 | return task->pid; | ||
1350 | 1945 | ||
1351 | if (cfqd->busy_queues) | 1946 | return CFQ_KEY_ASYNC; |
1352 | limit = q->nr_requests / cfqd->busy_queues; | 1947 | } |
1353 | 1948 | ||
1354 | if (limit < cfqd->cfq_queued) | 1949 | static inline int |
1355 | limit = cfqd->cfq_queued; | 1950 | __cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq, |
1356 | else if (limit > cfqd->max_queued) | 1951 | struct task_struct *task, int rw) |
1357 | limit = cfqd->max_queued; | 1952 | { |
1953 | #if 1 | ||
1954 | if ((cfq_cfqq_wait_request(cfqq) || cfq_cfqq_must_alloc(cfqq)) && | ||
1955 | !cfq_cfqq_must_alloc_slice) { | ||
1956 | cfq_mark_cfqq_must_alloc_slice(cfqq); | ||
1957 | return ELV_MQUEUE_MUST; | ||
1958 | } | ||
1358 | 1959 | ||
1359 | if (cfqq->allocated[rw] >= limit) { | 1960 | return ELV_MQUEUE_MAY; |
1360 | if (limit > cfqq->alloc_limit[rw]) | 1961 | #else |
1361 | cfqq->alloc_limit[rw] = limit; | 1962 | if (!cfqq || task->flags & PF_MEMALLOC) |
1963 | return ELV_MQUEUE_MAY; | ||
1964 | if (!cfqq->allocated[rw] || cfq_cfqq_must_alloc(cfqq)) { | ||
1965 | if (cfq_cfqq_wait_request(cfqq)) | ||
1966 | return ELV_MQUEUE_MUST; | ||
1362 | 1967 | ||
1363 | ret = ELV_MQUEUE_NO; | 1968 | /* |
1969 | * only allow 1 ELV_MQUEUE_MUST per slice, otherwise we | ||
1970 | * can quickly flood the queue with writes from a single task | ||
1971 | */ | ||
1972 | if (rw == READ || !cfq_cfqq_must_alloc_slice) { | ||
1973 | cfq_mark_cfqq_must_alloc_slice(cfqq); | ||
1974 | return ELV_MQUEUE_MUST; | ||
1364 | } | 1975 | } |
1976 | |||
1977 | return ELV_MQUEUE_MAY; | ||
1365 | } | 1978 | } |
1979 | if (cfq_class_idle(cfqq)) | ||
1980 | return ELV_MQUEUE_NO; | ||
1981 | if (cfqq->allocated[rw] >= cfqd->max_queued) { | ||
1982 | struct io_context *ioc = get_io_context(GFP_ATOMIC); | ||
1983 | int ret = ELV_MQUEUE_NO; | ||
1366 | 1984 | ||
1367 | return ret; | 1985 | if (ioc && ioc->nr_batch_requests) |
1986 | ret = ELV_MQUEUE_MAY; | ||
1987 | |||
1988 | put_io_context(ioc); | ||
1989 | return ret; | ||
1990 | } | ||
1991 | |||
1992 | return ELV_MQUEUE_MAY; | ||
1993 | #endif | ||
1994 | } | ||
1995 | |||
1996 | static int cfq_may_queue(request_queue_t *q, int rw, struct bio *bio) | ||
1997 | { | ||
1998 | struct cfq_data *cfqd = q->elevator->elevator_data; | ||
1999 | struct task_struct *tsk = current; | ||
2000 | struct cfq_queue *cfqq; | ||
2001 | |||
2002 | /* | ||
2003 | * don't force setup of a queue from here, as a call to may_queue | ||
2004 | * does not necessarily imply that a request actually will be queued. | ||
2005 | * so just lookup a possibly existing queue, or return 'may queue' | ||
2006 | * if that fails | ||
2007 | */ | ||
2008 | cfqq = cfq_find_cfq_hash(cfqd, cfq_queue_pid(tsk, rw), tsk->ioprio); | ||
2009 | if (cfqq) { | ||
2010 | cfq_init_prio_data(cfqq); | ||
2011 | cfq_prio_boost(cfqq); | ||
2012 | |||
2013 | return __cfq_may_queue(cfqd, cfqq, tsk, rw); | ||
2014 | } | ||
2015 | |||
2016 | return ELV_MQUEUE_MAY; | ||
1368 | } | 2017 | } |
1369 | 2018 | ||
1370 | static void cfq_check_waiters(request_queue_t *q, struct cfq_queue *cfqq) | 2019 | static void cfq_check_waiters(request_queue_t *q, struct cfq_queue *cfqq) |
1371 | { | 2020 | { |
2021 | struct cfq_data *cfqd = q->elevator->elevator_data; | ||
1372 | struct request_list *rl = &q->rq; | 2022 | struct request_list *rl = &q->rq; |
1373 | const int write = waitqueue_active(&rl->wait[WRITE]); | ||
1374 | const int read = waitqueue_active(&rl->wait[READ]); | ||
1375 | 2023 | ||
1376 | if (read && cfqq->allocated[READ] < cfqq->alloc_limit[READ]) | 2024 | if (cfqq->allocated[READ] <= cfqd->max_queued || cfqd->rq_starved) { |
1377 | wake_up(&rl->wait[READ]); | 2025 | smp_mb(); |
1378 | if (write && cfqq->allocated[WRITE] < cfqq->alloc_limit[WRITE]) | 2026 | if (waitqueue_active(&rl->wait[READ])) |
1379 | wake_up(&rl->wait[WRITE]); | 2027 | wake_up(&rl->wait[READ]); |
2028 | } | ||
2029 | |||
2030 | if (cfqq->allocated[WRITE] <= cfqd->max_queued || cfqd->rq_starved) { | ||
2031 | smp_mb(); | ||
2032 | if (waitqueue_active(&rl->wait[WRITE])) | ||
2033 | wake_up(&rl->wait[WRITE]); | ||
2034 | } | ||
1380 | } | 2035 | } |
1381 | 2036 | ||
1382 | /* | 2037 | /* |
@@ -1389,69 +2044,61 @@ static void cfq_put_request(request_queue_t *q, struct request *rq) | |||
1389 | 2044 | ||
1390 | if (crq) { | 2045 | if (crq) { |
1391 | struct cfq_queue *cfqq = crq->cfq_queue; | 2046 | struct cfq_queue *cfqq = crq->cfq_queue; |
2047 | const int rw = rq_data_dir(rq); | ||
1392 | 2048 | ||
1393 | BUG_ON(q->last_merge == rq); | 2049 | BUG_ON(!cfqq->allocated[rw]); |
1394 | BUG_ON(!hlist_unhashed(&crq->hash)); | 2050 | cfqq->allocated[rw]--; |
1395 | 2051 | ||
1396 | if (crq->io_context) | 2052 | put_io_context(crq->io_context->ioc); |
1397 | put_io_context(crq->io_context->ioc); | ||
1398 | |||
1399 | BUG_ON(!cfqq->allocated[crq->is_write]); | ||
1400 | cfqq->allocated[crq->is_write]--; | ||
1401 | 2053 | ||
1402 | mempool_free(crq, cfqd->crq_pool); | 2054 | mempool_free(crq, cfqd->crq_pool); |
1403 | rq->elevator_private = NULL; | 2055 | rq->elevator_private = NULL; |
1404 | 2056 | ||
1405 | smp_mb(); | ||
1406 | cfq_check_waiters(q, cfqq); | 2057 | cfq_check_waiters(q, cfqq); |
1407 | cfq_put_queue(cfqq); | 2058 | cfq_put_queue(cfqq); |
1408 | } | 2059 | } |
1409 | } | 2060 | } |
1410 | 2061 | ||
1411 | /* | 2062 | /* |
1412 | * Allocate cfq data structures associated with this request. A queue and | 2063 | * Allocate cfq data structures associated with this request. |
1413 | */ | 2064 | */ |
1414 | static int cfq_set_request(request_queue_t *q, struct request *rq, int gfp_mask) | 2065 | static int |
2066 | cfq_set_request(request_queue_t *q, struct request *rq, struct bio *bio, | ||
2067 | int gfp_mask) | ||
1415 | { | 2068 | { |
1416 | struct cfq_data *cfqd = q->elevator->elevator_data; | 2069 | struct cfq_data *cfqd = q->elevator->elevator_data; |
2070 | struct task_struct *tsk = current; | ||
1417 | struct cfq_io_context *cic; | 2071 | struct cfq_io_context *cic; |
1418 | const int rw = rq_data_dir(rq); | 2072 | const int rw = rq_data_dir(rq); |
1419 | struct cfq_queue *cfqq, *saved_cfqq; | 2073 | pid_t key = cfq_queue_pid(tsk, rw); |
2074 | struct cfq_queue *cfqq; | ||
1420 | struct cfq_rq *crq; | 2075 | struct cfq_rq *crq; |
1421 | unsigned long flags; | 2076 | unsigned long flags; |
1422 | 2077 | ||
1423 | might_sleep_if(gfp_mask & __GFP_WAIT); | 2078 | might_sleep_if(gfp_mask & __GFP_WAIT); |
1424 | 2079 | ||
2080 | cic = cfq_get_io_context(cfqd, key, gfp_mask); | ||
2081 | |||
1425 | spin_lock_irqsave(q->queue_lock, flags); | 2082 | spin_lock_irqsave(q->queue_lock, flags); |
1426 | 2083 | ||
1427 | cfqq = __cfq_get_queue(cfqd, cfq_hash_key(cfqd, current), gfp_mask); | 2084 | if (!cic) |
1428 | if (!cfqq) | 2085 | goto queue_fail; |
1429 | goto out_lock; | 2086 | |
2087 | if (!cic->cfqq) { | ||
2088 | cfqq = cfq_get_queue(cfqd, key, tsk->ioprio, gfp_mask); | ||
2089 | if (!cfqq) | ||
2090 | goto queue_fail; | ||
1430 | 2091 | ||
1431 | repeat: | 2092 | cic->cfqq = cfqq; |
1432 | if (cfqq->allocated[rw] >= cfqd->max_queued) | 2093 | } else |
1433 | goto out_lock; | 2094 | cfqq = cic->cfqq; |
1434 | 2095 | ||
1435 | cfqq->allocated[rw]++; | 2096 | cfqq->allocated[rw]++; |
2097 | cfq_clear_cfqq_must_alloc(cfqq); | ||
2098 | cfqd->rq_starved = 0; | ||
2099 | atomic_inc(&cfqq->ref); | ||
1436 | spin_unlock_irqrestore(q->queue_lock, flags); | 2100 | spin_unlock_irqrestore(q->queue_lock, flags); |
1437 | 2101 | ||
1438 | /* | ||
1439 | * if hashing type has changed, the cfq_queue might change here. | ||
1440 | */ | ||
1441 | saved_cfqq = cfqq; | ||
1442 | cic = cfq_get_io_context(&cfqq, gfp_mask); | ||
1443 | if (!cic) | ||
1444 | goto err; | ||
1445 | |||
1446 | /* | ||
1447 | * repeat allocation checks on queue change | ||
1448 | */ | ||
1449 | if (unlikely(saved_cfqq != cfqq)) { | ||
1450 | spin_lock_irqsave(q->queue_lock, flags); | ||
1451 | saved_cfqq->allocated[rw]--; | ||
1452 | goto repeat; | ||
1453 | } | ||
1454 | |||
1455 | crq = mempool_alloc(cfqd->crq_pool, gfp_mask); | 2102 | crq = mempool_alloc(cfqd->crq_pool, gfp_mask); |
1456 | if (crq) { | 2103 | if (crq) { |
1457 | RB_CLEAR(&crq->rb_node); | 2104 | RB_CLEAR(&crq->rb_node); |
@@ -1460,24 +2107,141 @@ repeat: | |||
1460 | INIT_HLIST_NODE(&crq->hash); | 2107 | INIT_HLIST_NODE(&crq->hash); |
1461 | crq->cfq_queue = cfqq; | 2108 | crq->cfq_queue = cfqq; |
1462 | crq->io_context = cic; | 2109 | crq->io_context = cic; |
1463 | crq->service_start = crq->queue_start = 0; | 2110 | cfq_clear_crq_in_flight(crq); |
1464 | crq->in_flight = crq->accounted = crq->is_sync = 0; | 2111 | cfq_clear_crq_in_driver(crq); |
1465 | crq->is_write = rw; | 2112 | cfq_clear_crq_requeued(crq); |
2113 | |||
2114 | if (rw == READ || process_sync(tsk)) | ||
2115 | cfq_mark_crq_is_sync(crq); | ||
2116 | else | ||
2117 | cfq_clear_crq_is_sync(crq); | ||
2118 | |||
1466 | rq->elevator_private = crq; | 2119 | rq->elevator_private = crq; |
1467 | cfqq->alloc_limit[rw] = 0; | ||
1468 | return 0; | 2120 | return 0; |
1469 | } | 2121 | } |
1470 | 2122 | ||
1471 | put_io_context(cic->ioc); | ||
1472 | err: | ||
1473 | spin_lock_irqsave(q->queue_lock, flags); | 2123 | spin_lock_irqsave(q->queue_lock, flags); |
1474 | cfqq->allocated[rw]--; | 2124 | cfqq->allocated[rw]--; |
2125 | if (!(cfqq->allocated[0] + cfqq->allocated[1])) | ||
2126 | cfq_mark_cfqq_must_alloc(cfqq); | ||
1475 | cfq_put_queue(cfqq); | 2127 | cfq_put_queue(cfqq); |
1476 | out_lock: | 2128 | queue_fail: |
2129 | if (cic) | ||
2130 | put_io_context(cic->ioc); | ||
2131 | /* | ||
2132 | * mark us rq allocation starved. we need to kickstart the process | ||
2133 | * ourselves if there are no pending requests that can do it for us. | ||
2134 | * that would be an extremely rare OOM situation | ||
2135 | */ | ||
2136 | cfqd->rq_starved = 1; | ||
2137 | cfq_schedule_dispatch(cfqd); | ||
1477 | spin_unlock_irqrestore(q->queue_lock, flags); | 2138 | spin_unlock_irqrestore(q->queue_lock, flags); |
1478 | return 1; | 2139 | return 1; |
1479 | } | 2140 | } |
1480 | 2141 | ||
2142 | static void cfq_kick_queue(void *data) | ||
2143 | { | ||
2144 | request_queue_t *q = data; | ||
2145 | struct cfq_data *cfqd = q->elevator->elevator_data; | ||
2146 | unsigned long flags; | ||
2147 | |||
2148 | spin_lock_irqsave(q->queue_lock, flags); | ||
2149 | |||
2150 | if (cfqd->rq_starved) { | ||
2151 | struct request_list *rl = &q->rq; | ||
2152 | |||
2153 | /* | ||
2154 | * we aren't guaranteed to get a request after this, but we | ||
2155 | * have to be opportunistic | ||
2156 | */ | ||
2157 | smp_mb(); | ||
2158 | if (waitqueue_active(&rl->wait[READ])) | ||
2159 | wake_up(&rl->wait[READ]); | ||
2160 | if (waitqueue_active(&rl->wait[WRITE])) | ||
2161 | wake_up(&rl->wait[WRITE]); | ||
2162 | } | ||
2163 | |||
2164 | blk_remove_plug(q); | ||
2165 | q->request_fn(q); | ||
2166 | spin_unlock_irqrestore(q->queue_lock, flags); | ||
2167 | } | ||
2168 | |||
2169 | /* | ||
2170 | * Timer running if the active_queue is currently idling inside its time slice | ||
2171 | */ | ||
2172 | static void cfq_idle_slice_timer(unsigned long data) | ||
2173 | { | ||
2174 | struct cfq_data *cfqd = (struct cfq_data *) data; | ||
2175 | struct cfq_queue *cfqq; | ||
2176 | unsigned long flags; | ||
2177 | |||
2178 | spin_lock_irqsave(cfqd->queue->queue_lock, flags); | ||
2179 | |||
2180 | if ((cfqq = cfqd->active_queue) != NULL) { | ||
2181 | unsigned long now = jiffies; | ||
2182 | |||
2183 | /* | ||
2184 | * expired | ||
2185 | */ | ||
2186 | if (time_after(now, cfqq->slice_end)) | ||
2187 | goto expire; | ||
2188 | |||
2189 | /* | ||
2190 | * only expire and reinvoke request handler, if there are | ||
2191 | * other queues with pending requests | ||
2192 | */ | ||
2193 | if (!cfq_pending_requests(cfqd)) { | ||
2194 | cfqd->idle_slice_timer.expires = min(now + cfqd->cfq_slice_idle, cfqq->slice_end); | ||
2195 | add_timer(&cfqd->idle_slice_timer); | ||
2196 | goto out_cont; | ||
2197 | } | ||
2198 | |||
2199 | /* | ||
2200 | * not expired and it has a request pending, let it dispatch | ||
2201 | */ | ||
2202 | if (!RB_EMPTY(&cfqq->sort_list)) { | ||
2203 | cfq_mark_cfqq_must_dispatch(cfqq); | ||
2204 | goto out_kick; | ||
2205 | } | ||
2206 | } | ||
2207 | expire: | ||
2208 | cfq_slice_expired(cfqd, 0); | ||
2209 | out_kick: | ||
2210 | cfq_schedule_dispatch(cfqd); | ||
2211 | out_cont: | ||
2212 | spin_unlock_irqrestore(cfqd->queue->queue_lock, flags); | ||
2213 | } | ||
2214 | |||
2215 | /* | ||
2216 | * Timer running if an idle class queue is waiting for service | ||
2217 | */ | ||
2218 | static void cfq_idle_class_timer(unsigned long data) | ||
2219 | { | ||
2220 | struct cfq_data *cfqd = (struct cfq_data *) data; | ||
2221 | unsigned long flags, end; | ||
2222 | |||
2223 | spin_lock_irqsave(cfqd->queue->queue_lock, flags); | ||
2224 | |||
2225 | /* | ||
2226 | * race with a non-idle queue, reset timer | ||
2227 | */ | ||
2228 | end = cfqd->last_end_request + CFQ_IDLE_GRACE; | ||
2229 | if (!time_after_eq(jiffies, end)) { | ||
2230 | cfqd->idle_class_timer.expires = end; | ||
2231 | add_timer(&cfqd->idle_class_timer); | ||
2232 | } else | ||
2233 | cfq_schedule_dispatch(cfqd); | ||
2234 | |||
2235 | spin_unlock_irqrestore(cfqd->queue->queue_lock, flags); | ||
2236 | } | ||
2237 | |||
2238 | static void cfq_shutdown_timer_wq(struct cfq_data *cfqd) | ||
2239 | { | ||
2240 | del_timer_sync(&cfqd->idle_slice_timer); | ||
2241 | del_timer_sync(&cfqd->idle_class_timer); | ||
2242 | blk_sync_queue(cfqd->queue); | ||
2243 | } | ||
2244 | |||
1481 | static void cfq_put_cfqd(struct cfq_data *cfqd) | 2245 | static void cfq_put_cfqd(struct cfq_data *cfqd) |
1482 | { | 2246 | { |
1483 | request_queue_t *q = cfqd->queue; | 2247 | request_queue_t *q = cfqd->queue; |
@@ -1487,6 +2251,9 @@ static void cfq_put_cfqd(struct cfq_data *cfqd) | |||
1487 | 2251 | ||
1488 | blk_put_queue(q); | 2252 | blk_put_queue(q); |
1489 | 2253 | ||
2254 | cfq_shutdown_timer_wq(cfqd); | ||
2255 | q->elevator->elevator_data = NULL; | ||
2256 | |||
1490 | mempool_destroy(cfqd->crq_pool); | 2257 | mempool_destroy(cfqd->crq_pool); |
1491 | kfree(cfqd->crq_hash); | 2258 | kfree(cfqd->crq_hash); |
1492 | kfree(cfqd->cfq_hash); | 2259 | kfree(cfqd->cfq_hash); |
@@ -1495,7 +2262,10 @@ static void cfq_put_cfqd(struct cfq_data *cfqd) | |||
1495 | 2262 | ||
1496 | static void cfq_exit_queue(elevator_t *e) | 2263 | static void cfq_exit_queue(elevator_t *e) |
1497 | { | 2264 | { |
1498 | cfq_put_cfqd(e->elevator_data); | 2265 | struct cfq_data *cfqd = e->elevator_data; |
2266 | |||
2267 | cfq_shutdown_timer_wq(cfqd); | ||
2268 | cfq_put_cfqd(cfqd); | ||
1499 | } | 2269 | } |
1500 | 2270 | ||
1501 | static int cfq_init_queue(request_queue_t *q, elevator_t *e) | 2271 | static int cfq_init_queue(request_queue_t *q, elevator_t *e) |
@@ -1508,7 +2278,13 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e) | |||
1508 | return -ENOMEM; | 2278 | return -ENOMEM; |
1509 | 2279 | ||
1510 | memset(cfqd, 0, sizeof(*cfqd)); | 2280 | memset(cfqd, 0, sizeof(*cfqd)); |
1511 | INIT_LIST_HEAD(&cfqd->rr_list); | 2281 | |
2282 | for (i = 0; i < CFQ_PRIO_LISTS; i++) | ||
2283 | INIT_LIST_HEAD(&cfqd->rr_list[i]); | ||
2284 | |||
2285 | INIT_LIST_HEAD(&cfqd->busy_rr); | ||
2286 | INIT_LIST_HEAD(&cfqd->cur_rr); | ||
2287 | INIT_LIST_HEAD(&cfqd->idle_rr); | ||
1512 | INIT_LIST_HEAD(&cfqd->empty_list); | 2288 | INIT_LIST_HEAD(&cfqd->empty_list); |
1513 | 2289 | ||
1514 | cfqd->crq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL); | 2290 | cfqd->crq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL); |
@@ -1533,24 +2309,32 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e) | |||
1533 | cfqd->queue = q; | 2309 | cfqd->queue = q; |
1534 | atomic_inc(&q->refcnt); | 2310 | atomic_inc(&q->refcnt); |
1535 | 2311 | ||
1536 | /* | 2312 | cfqd->max_queued = q->nr_requests / 4; |
1537 | * just set it to some high value, we want anyone to be able to queue | ||
1538 | * some requests. fairness is handled differently | ||
1539 | */ | ||
1540 | q->nr_requests = 1024; | ||
1541 | cfqd->max_queued = q->nr_requests / 16; | ||
1542 | q->nr_batching = cfq_queued; | 2313 | q->nr_batching = cfq_queued; |
1543 | cfqd->key_type = CFQ_KEY_TGID; | 2314 | |
1544 | cfqd->find_best_crq = 1; | 2315 | init_timer(&cfqd->idle_slice_timer); |
2316 | cfqd->idle_slice_timer.function = cfq_idle_slice_timer; | ||
2317 | cfqd->idle_slice_timer.data = (unsigned long) cfqd; | ||
2318 | |||
2319 | init_timer(&cfqd->idle_class_timer); | ||
2320 | cfqd->idle_class_timer.function = cfq_idle_class_timer; | ||
2321 | cfqd->idle_class_timer.data = (unsigned long) cfqd; | ||
2322 | |||
2323 | INIT_WORK(&cfqd->unplug_work, cfq_kick_queue, q); | ||
2324 | |||
1545 | atomic_set(&cfqd->ref, 1); | 2325 | atomic_set(&cfqd->ref, 1); |
1546 | 2326 | ||
1547 | cfqd->cfq_queued = cfq_queued; | 2327 | cfqd->cfq_queued = cfq_queued; |
1548 | cfqd->cfq_quantum = cfq_quantum; | 2328 | cfqd->cfq_quantum = cfq_quantum; |
1549 | cfqd->cfq_fifo_expire_r = cfq_fifo_expire_r; | 2329 | cfqd->cfq_fifo_expire[0] = cfq_fifo_expire[0]; |
1550 | cfqd->cfq_fifo_expire_w = cfq_fifo_expire_w; | 2330 | cfqd->cfq_fifo_expire[1] = cfq_fifo_expire[1]; |
1551 | cfqd->cfq_fifo_batch_expire = cfq_fifo_rate; | ||
1552 | cfqd->cfq_back_max = cfq_back_max; | 2331 | cfqd->cfq_back_max = cfq_back_max; |
1553 | cfqd->cfq_back_penalty = cfq_back_penalty; | 2332 | cfqd->cfq_back_penalty = cfq_back_penalty; |
2333 | cfqd->cfq_slice[0] = cfq_slice_async; | ||
2334 | cfqd->cfq_slice[1] = cfq_slice_sync; | ||
2335 | cfqd->cfq_slice_async_rq = cfq_slice_async_rq; | ||
2336 | cfqd->cfq_slice_idle = cfq_slice_idle; | ||
2337 | cfqd->cfq_max_depth = cfq_max_depth; | ||
1554 | 2338 | ||
1555 | return 0; | 2339 | return 0; |
1556 | out_crqpool: | 2340 | out_crqpool: |
@@ -1595,7 +2379,6 @@ fail: | |||
1595 | return -ENOMEM; | 2379 | return -ENOMEM; |
1596 | } | 2380 | } |
1597 | 2381 | ||
1598 | |||
1599 | /* | 2382 | /* |
1600 | * sysfs parts below --> | 2383 | * sysfs parts below --> |
1601 | */ | 2384 | */ |
@@ -1620,45 +2403,6 @@ cfq_var_store(unsigned int *var, const char *page, size_t count) | |||
1620 | return count; | 2403 | return count; |
1621 | } | 2404 | } |
1622 | 2405 | ||
1623 | static ssize_t | ||
1624 | cfq_clear_elapsed(struct cfq_data *cfqd, const char *page, size_t count) | ||
1625 | { | ||
1626 | max_elapsed_dispatch = max_elapsed_crq = 0; | ||
1627 | return count; | ||
1628 | } | ||
1629 | |||
1630 | static ssize_t | ||
1631 | cfq_set_key_type(struct cfq_data *cfqd, const char *page, size_t count) | ||
1632 | { | ||
1633 | spin_lock_irq(cfqd->queue->queue_lock); | ||
1634 | if (!strncmp(page, "pgid", 4)) | ||
1635 | cfqd->key_type = CFQ_KEY_PGID; | ||
1636 | else if (!strncmp(page, "tgid", 4)) | ||
1637 | cfqd->key_type = CFQ_KEY_TGID; | ||
1638 | else if (!strncmp(page, "uid", 3)) | ||
1639 | cfqd->key_type = CFQ_KEY_UID; | ||
1640 | else if (!strncmp(page, "gid", 3)) | ||
1641 | cfqd->key_type = CFQ_KEY_GID; | ||
1642 | spin_unlock_irq(cfqd->queue->queue_lock); | ||
1643 | return count; | ||
1644 | } | ||
1645 | |||
1646 | static ssize_t | ||
1647 | cfq_read_key_type(struct cfq_data *cfqd, char *page) | ||
1648 | { | ||
1649 | ssize_t len = 0; | ||
1650 | int i; | ||
1651 | |||
1652 | for (i = CFQ_KEY_PGID; i < CFQ_KEY_LAST; i++) { | ||
1653 | if (cfqd->key_type == i) | ||
1654 | len += sprintf(page+len, "[%s] ", cfq_key_types[i]); | ||
1655 | else | ||
1656 | len += sprintf(page+len, "%s ", cfq_key_types[i]); | ||
1657 | } | ||
1658 | len += sprintf(page+len, "\n"); | ||
1659 | return len; | ||
1660 | } | ||
1661 | |||
1662 | #define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \ | 2406 | #define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \ |
1663 | static ssize_t __FUNC(struct cfq_data *cfqd, char *page) \ | 2407 | static ssize_t __FUNC(struct cfq_data *cfqd, char *page) \ |
1664 | { \ | 2408 | { \ |
@@ -1669,12 +2413,15 @@ static ssize_t __FUNC(struct cfq_data *cfqd, char *page) \ | |||
1669 | } | 2413 | } |
1670 | SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum, 0); | 2414 | SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum, 0); |
1671 | SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued, 0); | 2415 | SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued, 0); |
1672 | SHOW_FUNCTION(cfq_fifo_expire_r_show, cfqd->cfq_fifo_expire_r, 1); | 2416 | SHOW_FUNCTION(cfq_fifo_expire_sync_show, cfqd->cfq_fifo_expire[1], 1); |
1673 | SHOW_FUNCTION(cfq_fifo_expire_w_show, cfqd->cfq_fifo_expire_w, 1); | 2417 | SHOW_FUNCTION(cfq_fifo_expire_async_show, cfqd->cfq_fifo_expire[0], 1); |
1674 | SHOW_FUNCTION(cfq_fifo_batch_expire_show, cfqd->cfq_fifo_batch_expire, 1); | ||
1675 | SHOW_FUNCTION(cfq_find_best_show, cfqd->find_best_crq, 0); | ||
1676 | SHOW_FUNCTION(cfq_back_max_show, cfqd->cfq_back_max, 0); | 2418 | SHOW_FUNCTION(cfq_back_max_show, cfqd->cfq_back_max, 0); |
1677 | SHOW_FUNCTION(cfq_back_penalty_show, cfqd->cfq_back_penalty, 0); | 2419 | SHOW_FUNCTION(cfq_back_penalty_show, cfqd->cfq_back_penalty, 0); |
2420 | SHOW_FUNCTION(cfq_slice_idle_show, cfqd->cfq_slice_idle, 1); | ||
2421 | SHOW_FUNCTION(cfq_slice_sync_show, cfqd->cfq_slice[1], 1); | ||
2422 | SHOW_FUNCTION(cfq_slice_async_show, cfqd->cfq_slice[0], 1); | ||
2423 | SHOW_FUNCTION(cfq_slice_async_rq_show, cfqd->cfq_slice_async_rq, 0); | ||
2424 | SHOW_FUNCTION(cfq_max_depth_show, cfqd->cfq_max_depth, 0); | ||
1678 | #undef SHOW_FUNCTION | 2425 | #undef SHOW_FUNCTION |
1679 | 2426 | ||
1680 | #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ | 2427 | #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ |
@@ -1694,12 +2441,15 @@ static ssize_t __FUNC(struct cfq_data *cfqd, const char *page, size_t count) \ | |||
1694 | } | 2441 | } |
1695 | STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0); | 2442 | STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0); |
1696 | STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, UINT_MAX, 0); | 2443 | STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, UINT_MAX, 0); |
1697 | STORE_FUNCTION(cfq_fifo_expire_r_store, &cfqd->cfq_fifo_expire_r, 1, UINT_MAX, 1); | 2444 | STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1, UINT_MAX, 1); |
1698 | STORE_FUNCTION(cfq_fifo_expire_w_store, &cfqd->cfq_fifo_expire_w, 1, UINT_MAX, 1); | 2445 | STORE_FUNCTION(cfq_fifo_expire_async_store, &cfqd->cfq_fifo_expire[0], 1, UINT_MAX, 1); |
1699 | STORE_FUNCTION(cfq_fifo_batch_expire_store, &cfqd->cfq_fifo_batch_expire, 0, UINT_MAX, 1); | ||
1700 | STORE_FUNCTION(cfq_find_best_store, &cfqd->find_best_crq, 0, 1, 0); | ||
1701 | STORE_FUNCTION(cfq_back_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0); | 2446 | STORE_FUNCTION(cfq_back_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0); |
1702 | STORE_FUNCTION(cfq_back_penalty_store, &cfqd->cfq_back_penalty, 1, UINT_MAX, 0); | 2447 | STORE_FUNCTION(cfq_back_penalty_store, &cfqd->cfq_back_penalty, 1, UINT_MAX, 0); |
2448 | STORE_FUNCTION(cfq_slice_idle_store, &cfqd->cfq_slice_idle, 0, UINT_MAX, 1); | ||
2449 | STORE_FUNCTION(cfq_slice_sync_store, &cfqd->cfq_slice[1], 1, UINT_MAX, 1); | ||
2450 | STORE_FUNCTION(cfq_slice_async_store, &cfqd->cfq_slice[0], 1, UINT_MAX, 1); | ||
2451 | STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1, UINT_MAX, 0); | ||
2452 | STORE_FUNCTION(cfq_max_depth_store, &cfqd->cfq_max_depth, 1, UINT_MAX, 0); | ||
1703 | #undef STORE_FUNCTION | 2453 | #undef STORE_FUNCTION |
1704 | 2454 | ||
1705 | static struct cfq_fs_entry cfq_quantum_entry = { | 2455 | static struct cfq_fs_entry cfq_quantum_entry = { |
@@ -1712,25 +2462,15 @@ static struct cfq_fs_entry cfq_queued_entry = { | |||
1712 | .show = cfq_queued_show, | 2462 | .show = cfq_queued_show, |
1713 | .store = cfq_queued_store, | 2463 | .store = cfq_queued_store, |
1714 | }; | 2464 | }; |
1715 | static struct cfq_fs_entry cfq_fifo_expire_r_entry = { | 2465 | static struct cfq_fs_entry cfq_fifo_expire_sync_entry = { |
1716 | .attr = {.name = "fifo_expire_sync", .mode = S_IRUGO | S_IWUSR }, | 2466 | .attr = {.name = "fifo_expire_sync", .mode = S_IRUGO | S_IWUSR }, |
1717 | .show = cfq_fifo_expire_r_show, | 2467 | .show = cfq_fifo_expire_sync_show, |
1718 | .store = cfq_fifo_expire_r_store, | 2468 | .store = cfq_fifo_expire_sync_store, |
1719 | }; | 2469 | }; |
1720 | static struct cfq_fs_entry cfq_fifo_expire_w_entry = { | 2470 | static struct cfq_fs_entry cfq_fifo_expire_async_entry = { |
1721 | .attr = {.name = "fifo_expire_async", .mode = S_IRUGO | S_IWUSR }, | 2471 | .attr = {.name = "fifo_expire_async", .mode = S_IRUGO | S_IWUSR }, |
1722 | .show = cfq_fifo_expire_w_show, | 2472 | .show = cfq_fifo_expire_async_show, |
1723 | .store = cfq_fifo_expire_w_store, | 2473 | .store = cfq_fifo_expire_async_store, |
1724 | }; | ||
1725 | static struct cfq_fs_entry cfq_fifo_batch_expire_entry = { | ||
1726 | .attr = {.name = "fifo_batch_expire", .mode = S_IRUGO | S_IWUSR }, | ||
1727 | .show = cfq_fifo_batch_expire_show, | ||
1728 | .store = cfq_fifo_batch_expire_store, | ||
1729 | }; | ||
1730 | static struct cfq_fs_entry cfq_find_best_entry = { | ||
1731 | .attr = {.name = "find_best_crq", .mode = S_IRUGO | S_IWUSR }, | ||
1732 | .show = cfq_find_best_show, | ||
1733 | .store = cfq_find_best_store, | ||
1734 | }; | 2474 | }; |
1735 | static struct cfq_fs_entry cfq_back_max_entry = { | 2475 | static struct cfq_fs_entry cfq_back_max_entry = { |
1736 | .attr = {.name = "back_seek_max", .mode = S_IRUGO | S_IWUSR }, | 2476 | .attr = {.name = "back_seek_max", .mode = S_IRUGO | S_IWUSR }, |
@@ -1742,27 +2482,44 @@ static struct cfq_fs_entry cfq_back_penalty_entry = { | |||
1742 | .show = cfq_back_penalty_show, | 2482 | .show = cfq_back_penalty_show, |
1743 | .store = cfq_back_penalty_store, | 2483 | .store = cfq_back_penalty_store, |
1744 | }; | 2484 | }; |
1745 | static struct cfq_fs_entry cfq_clear_elapsed_entry = { | 2485 | static struct cfq_fs_entry cfq_slice_sync_entry = { |
1746 | .attr = {.name = "clear_elapsed", .mode = S_IWUSR }, | 2486 | .attr = {.name = "slice_sync", .mode = S_IRUGO | S_IWUSR }, |
1747 | .store = cfq_clear_elapsed, | 2487 | .show = cfq_slice_sync_show, |
2488 | .store = cfq_slice_sync_store, | ||
2489 | }; | ||
2490 | static struct cfq_fs_entry cfq_slice_async_entry = { | ||
2491 | .attr = {.name = "slice_async", .mode = S_IRUGO | S_IWUSR }, | ||
2492 | .show = cfq_slice_async_show, | ||
2493 | .store = cfq_slice_async_store, | ||
1748 | }; | 2494 | }; |
1749 | static struct cfq_fs_entry cfq_key_type_entry = { | 2495 | static struct cfq_fs_entry cfq_slice_async_rq_entry = { |
1750 | .attr = {.name = "key_type", .mode = S_IRUGO | S_IWUSR }, | 2496 | .attr = {.name = "slice_async_rq", .mode = S_IRUGO | S_IWUSR }, |
1751 | .show = cfq_read_key_type, | 2497 | .show = cfq_slice_async_rq_show, |
1752 | .store = cfq_set_key_type, | 2498 | .store = cfq_slice_async_rq_store, |
2499 | }; | ||
2500 | static struct cfq_fs_entry cfq_slice_idle_entry = { | ||
2501 | .attr = {.name = "slice_idle", .mode = S_IRUGO | S_IWUSR }, | ||
2502 | .show = cfq_slice_idle_show, | ||
2503 | .store = cfq_slice_idle_store, | ||
2504 | }; | ||
2505 | static struct cfq_fs_entry cfq_max_depth_entry = { | ||
2506 | .attr = {.name = "max_depth", .mode = S_IRUGO | S_IWUSR }, | ||
2507 | .show = cfq_max_depth_show, | ||
2508 | .store = cfq_max_depth_store, | ||
1753 | }; | 2509 | }; |
1754 | 2510 | ||
1755 | static struct attribute *default_attrs[] = { | 2511 | static struct attribute *default_attrs[] = { |
1756 | &cfq_quantum_entry.attr, | 2512 | &cfq_quantum_entry.attr, |
1757 | &cfq_queued_entry.attr, | 2513 | &cfq_queued_entry.attr, |
1758 | &cfq_fifo_expire_r_entry.attr, | 2514 | &cfq_fifo_expire_sync_entry.attr, |
1759 | &cfq_fifo_expire_w_entry.attr, | 2515 | &cfq_fifo_expire_async_entry.attr, |
1760 | &cfq_fifo_batch_expire_entry.attr, | ||
1761 | &cfq_key_type_entry.attr, | ||
1762 | &cfq_find_best_entry.attr, | ||
1763 | &cfq_back_max_entry.attr, | 2516 | &cfq_back_max_entry.attr, |
1764 | &cfq_back_penalty_entry.attr, | 2517 | &cfq_back_penalty_entry.attr, |
1765 | &cfq_clear_elapsed_entry.attr, | 2518 | &cfq_slice_sync_entry.attr, |
2519 | &cfq_slice_async_entry.attr, | ||
2520 | &cfq_slice_async_rq_entry.attr, | ||
2521 | &cfq_slice_idle_entry.attr, | ||
2522 | &cfq_max_depth_entry.attr, | ||
1766 | NULL, | 2523 | NULL, |
1767 | }; | 2524 | }; |
1768 | 2525 | ||
@@ -1832,21 +2589,46 @@ static int __init cfq_init(void) | |||
1832 | { | 2589 | { |
1833 | int ret; | 2590 | int ret; |
1834 | 2591 | ||
2592 | /* | ||
2593 | * could be 0 on HZ < 1000 setups | ||
2594 | */ | ||
2595 | if (!cfq_slice_async) | ||
2596 | cfq_slice_async = 1; | ||
2597 | if (!cfq_slice_idle) | ||
2598 | cfq_slice_idle = 1; | ||
2599 | |||
1835 | if (cfq_slab_setup()) | 2600 | if (cfq_slab_setup()) |
1836 | return -ENOMEM; | 2601 | return -ENOMEM; |
1837 | 2602 | ||
1838 | ret = elv_register(&iosched_cfq); | 2603 | ret = elv_register(&iosched_cfq); |
1839 | if (!ret) { | 2604 | if (ret) |
1840 | __module_get(THIS_MODULE); | 2605 | cfq_slab_kill(); |
1841 | return 0; | ||
1842 | } | ||
1843 | 2606 | ||
1844 | cfq_slab_kill(); | ||
1845 | return ret; | 2607 | return ret; |
1846 | } | 2608 | } |
1847 | 2609 | ||
1848 | static void __exit cfq_exit(void) | 2610 | static void __exit cfq_exit(void) |
1849 | { | 2611 | { |
2612 | struct task_struct *g, *p; | ||
2613 | unsigned long flags; | ||
2614 | |||
2615 | read_lock_irqsave(&tasklist_lock, flags); | ||
2616 | |||
2617 | /* | ||
2618 | * iterate each process in the system, removing our io_context | ||
2619 | */ | ||
2620 | do_each_thread(g, p) { | ||
2621 | struct io_context *ioc = p->io_context; | ||
2622 | |||
2623 | if (ioc && ioc->cic) { | ||
2624 | ioc->cic->exit(ioc->cic); | ||
2625 | cfq_free_io_context(ioc->cic); | ||
2626 | ioc->cic = NULL; | ||
2627 | } | ||
2628 | } while_each_thread(g, p); | ||
2629 | |||
2630 | read_unlock_irqrestore(&tasklist_lock, flags); | ||
2631 | |||
1850 | cfq_slab_kill(); | 2632 | cfq_slab_kill(); |
1851 | elv_unregister(&iosched_cfq); | 2633 | elv_unregister(&iosched_cfq); |
1852 | } | 2634 | } |
diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c index 4bc2fea73273..ff5201e02153 100644 --- a/drivers/block/deadline-iosched.c +++ b/drivers/block/deadline-iosched.c | |||
@@ -760,7 +760,8 @@ static void deadline_put_request(request_queue_t *q, struct request *rq) | |||
760 | } | 760 | } |
761 | 761 | ||
762 | static int | 762 | static int |
763 | deadline_set_request(request_queue_t *q, struct request *rq, int gfp_mask) | 763 | deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio, |
764 | int gfp_mask) | ||
764 | { | 765 | { |
765 | struct deadline_data *dd = q->elevator->elevator_data; | 766 | struct deadline_data *dd = q->elevator->elevator_data; |
766 | struct deadline_rq *drq; | 767 | struct deadline_rq *drq; |
diff --git a/drivers/block/elevator.c b/drivers/block/elevator.c index f831f08f839c..98f0126a2deb 100644 --- a/drivers/block/elevator.c +++ b/drivers/block/elevator.c | |||
@@ -486,12 +486,13 @@ struct request *elv_former_request(request_queue_t *q, struct request *rq) | |||
486 | return NULL; | 486 | return NULL; |
487 | } | 487 | } |
488 | 488 | ||
489 | int elv_set_request(request_queue_t *q, struct request *rq, int gfp_mask) | 489 | int elv_set_request(request_queue_t *q, struct request *rq, struct bio *bio, |
490 | int gfp_mask) | ||
490 | { | 491 | { |
491 | elevator_t *e = q->elevator; | 492 | elevator_t *e = q->elevator; |
492 | 493 | ||
493 | if (e->ops->elevator_set_req_fn) | 494 | if (e->ops->elevator_set_req_fn) |
494 | return e->ops->elevator_set_req_fn(q, rq, gfp_mask); | 495 | return e->ops->elevator_set_req_fn(q, rq, bio, gfp_mask); |
495 | 496 | ||
496 | rq->elevator_private = NULL; | 497 | rq->elevator_private = NULL; |
497 | return 0; | 498 | return 0; |
@@ -505,12 +506,12 @@ void elv_put_request(request_queue_t *q, struct request *rq) | |||
505 | e->ops->elevator_put_req_fn(q, rq); | 506 | e->ops->elevator_put_req_fn(q, rq); |
506 | } | 507 | } |
507 | 508 | ||
508 | int elv_may_queue(request_queue_t *q, int rw) | 509 | int elv_may_queue(request_queue_t *q, int rw, struct bio *bio) |
509 | { | 510 | { |
510 | elevator_t *e = q->elevator; | 511 | elevator_t *e = q->elevator; |
511 | 512 | ||
512 | if (e->ops->elevator_may_queue_fn) | 513 | if (e->ops->elevator_may_queue_fn) |
513 | return e->ops->elevator_may_queue_fn(q, rw); | 514 | return e->ops->elevator_may_queue_fn(q, rw, bio); |
514 | 515 | ||
515 | return ELV_MQUEUE_MAY; | 516 | return ELV_MQUEUE_MAY; |
516 | } | 517 | } |
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index 60e64091de1b..234fdcfbdf01 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c | |||
@@ -276,6 +276,7 @@ static inline void rq_init(request_queue_t *q, struct request *rq) | |||
276 | rq->errors = 0; | 276 | rq->errors = 0; |
277 | rq->rq_status = RQ_ACTIVE; | 277 | rq->rq_status = RQ_ACTIVE; |
278 | rq->bio = rq->biotail = NULL; | 278 | rq->bio = rq->biotail = NULL; |
279 | rq->ioprio = 0; | ||
279 | rq->buffer = NULL; | 280 | rq->buffer = NULL; |
280 | rq->ref_count = 1; | 281 | rq->ref_count = 1; |
281 | rq->q = q; | 282 | rq->q = q; |
@@ -1442,11 +1443,7 @@ void __generic_unplug_device(request_queue_t *q) | |||
1442 | if (!blk_remove_plug(q)) | 1443 | if (!blk_remove_plug(q)) |
1443 | return; | 1444 | return; |
1444 | 1445 | ||
1445 | /* | 1446 | q->request_fn(q); |
1446 | * was plugged, fire request_fn if queue has stuff to do | ||
1447 | */ | ||
1448 | if (elv_next_request(q)) | ||
1449 | q->request_fn(q); | ||
1450 | } | 1447 | } |
1451 | EXPORT_SYMBOL(__generic_unplug_device); | 1448 | EXPORT_SYMBOL(__generic_unplug_device); |
1452 | 1449 | ||
@@ -1776,8 +1773,8 @@ static inline void blk_free_request(request_queue_t *q, struct request *rq) | |||
1776 | mempool_free(rq, q->rq.rq_pool); | 1773 | mempool_free(rq, q->rq.rq_pool); |
1777 | } | 1774 | } |
1778 | 1775 | ||
1779 | static inline struct request *blk_alloc_request(request_queue_t *q, int rw, | 1776 | static inline struct request * |
1780 | int gfp_mask) | 1777 | blk_alloc_request(request_queue_t *q, int rw, struct bio *bio, int gfp_mask) |
1781 | { | 1778 | { |
1782 | struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask); | 1779 | struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask); |
1783 | 1780 | ||
@@ -1790,7 +1787,7 @@ static inline struct request *blk_alloc_request(request_queue_t *q, int rw, | |||
1790 | */ | 1787 | */ |
1791 | rq->flags = rw; | 1788 | rq->flags = rw; |
1792 | 1789 | ||
1793 | if (!elv_set_request(q, rq, gfp_mask)) | 1790 | if (!elv_set_request(q, rq, bio, gfp_mask)) |
1794 | return rq; | 1791 | return rq; |
1795 | 1792 | ||
1796 | mempool_free(rq, q->rq.rq_pool); | 1793 | mempool_free(rq, q->rq.rq_pool); |
@@ -1872,7 +1869,8 @@ static void freed_request(request_queue_t *q, int rw) | |||
1872 | /* | 1869 | /* |
1873 | * Get a free request, queue_lock must not be held | 1870 | * Get a free request, queue_lock must not be held |
1874 | */ | 1871 | */ |
1875 | static struct request *get_request(request_queue_t *q, int rw, int gfp_mask) | 1872 | static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, |
1873 | int gfp_mask) | ||
1876 | { | 1874 | { |
1877 | struct request *rq = NULL; | 1875 | struct request *rq = NULL; |
1878 | struct request_list *rl = &q->rq; | 1876 | struct request_list *rl = &q->rq; |
@@ -1895,7 +1893,7 @@ static struct request *get_request(request_queue_t *q, int rw, int gfp_mask) | |||
1895 | } | 1893 | } |
1896 | } | 1894 | } |
1897 | 1895 | ||
1898 | switch (elv_may_queue(q, rw)) { | 1896 | switch (elv_may_queue(q, rw, bio)) { |
1899 | case ELV_MQUEUE_NO: | 1897 | case ELV_MQUEUE_NO: |
1900 | goto rq_starved; | 1898 | goto rq_starved; |
1901 | case ELV_MQUEUE_MAY: | 1899 | case ELV_MQUEUE_MAY: |
@@ -1920,7 +1918,7 @@ get_rq: | |||
1920 | set_queue_congested(q, rw); | 1918 | set_queue_congested(q, rw); |
1921 | spin_unlock_irq(q->queue_lock); | 1919 | spin_unlock_irq(q->queue_lock); |
1922 | 1920 | ||
1923 | rq = blk_alloc_request(q, rw, gfp_mask); | 1921 | rq = blk_alloc_request(q, rw, bio, gfp_mask); |
1924 | if (!rq) { | 1922 | if (!rq) { |
1925 | /* | 1923 | /* |
1926 | * Allocation failed presumably due to memory. Undo anything | 1924 | * Allocation failed presumably due to memory. Undo anything |
@@ -1961,7 +1959,8 @@ out: | |||
1961 | * No available requests for this queue, unplug the device and wait for some | 1959 | * No available requests for this queue, unplug the device and wait for some |
1962 | * requests to become available. | 1960 | * requests to become available. |
1963 | */ | 1961 | */ |
1964 | static struct request *get_request_wait(request_queue_t *q, int rw) | 1962 | static struct request *get_request_wait(request_queue_t *q, int rw, |
1963 | struct bio *bio) | ||
1965 | { | 1964 | { |
1966 | DEFINE_WAIT(wait); | 1965 | DEFINE_WAIT(wait); |
1967 | struct request *rq; | 1966 | struct request *rq; |
@@ -1972,7 +1971,7 @@ static struct request *get_request_wait(request_queue_t *q, int rw) | |||
1972 | prepare_to_wait_exclusive(&rl->wait[rw], &wait, | 1971 | prepare_to_wait_exclusive(&rl->wait[rw], &wait, |
1973 | TASK_UNINTERRUPTIBLE); | 1972 | TASK_UNINTERRUPTIBLE); |
1974 | 1973 | ||
1975 | rq = get_request(q, rw, GFP_NOIO); | 1974 | rq = get_request(q, rw, bio, GFP_NOIO); |
1976 | 1975 | ||
1977 | if (!rq) { | 1976 | if (!rq) { |
1978 | struct io_context *ioc; | 1977 | struct io_context *ioc; |
@@ -2003,9 +2002,9 @@ struct request *blk_get_request(request_queue_t *q, int rw, int gfp_mask) | |||
2003 | BUG_ON(rw != READ && rw != WRITE); | 2002 | BUG_ON(rw != READ && rw != WRITE); |
2004 | 2003 | ||
2005 | if (gfp_mask & __GFP_WAIT) | 2004 | if (gfp_mask & __GFP_WAIT) |
2006 | rq = get_request_wait(q, rw); | 2005 | rq = get_request_wait(q, rw, NULL); |
2007 | else | 2006 | else |
2008 | rq = get_request(q, rw, gfp_mask); | 2007 | rq = get_request(q, rw, NULL, gfp_mask); |
2009 | 2008 | ||
2010 | return rq; | 2009 | return rq; |
2011 | } | 2010 | } |
@@ -2333,7 +2332,6 @@ static void __blk_put_request(request_queue_t *q, struct request *req) | |||
2333 | return; | 2332 | return; |
2334 | 2333 | ||
2335 | req->rq_status = RQ_INACTIVE; | 2334 | req->rq_status = RQ_INACTIVE; |
2336 | req->q = NULL; | ||
2337 | req->rl = NULL; | 2335 | req->rl = NULL; |
2338 | 2336 | ||
2339 | /* | 2337 | /* |
@@ -2462,6 +2460,8 @@ static int attempt_merge(request_queue_t *q, struct request *req, | |||
2462 | req->rq_disk->in_flight--; | 2460 | req->rq_disk->in_flight--; |
2463 | } | 2461 | } |
2464 | 2462 | ||
2463 | req->ioprio = ioprio_best(req->ioprio, next->ioprio); | ||
2464 | |||
2465 | __blk_put_request(q, next); | 2465 | __blk_put_request(q, next); |
2466 | return 1; | 2466 | return 1; |
2467 | } | 2467 | } |
@@ -2514,11 +2514,13 @@ static int __make_request(request_queue_t *q, struct bio *bio) | |||
2514 | { | 2514 | { |
2515 | struct request *req, *freereq = NULL; | 2515 | struct request *req, *freereq = NULL; |
2516 | int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, err, sync; | 2516 | int el_ret, rw, nr_sectors, cur_nr_sectors, barrier, err, sync; |
2517 | unsigned short prio; | ||
2517 | sector_t sector; | 2518 | sector_t sector; |
2518 | 2519 | ||
2519 | sector = bio->bi_sector; | 2520 | sector = bio->bi_sector; |
2520 | nr_sectors = bio_sectors(bio); | 2521 | nr_sectors = bio_sectors(bio); |
2521 | cur_nr_sectors = bio_cur_sectors(bio); | 2522 | cur_nr_sectors = bio_cur_sectors(bio); |
2523 | prio = bio_prio(bio); | ||
2522 | 2524 | ||
2523 | rw = bio_data_dir(bio); | 2525 | rw = bio_data_dir(bio); |
2524 | sync = bio_sync(bio); | 2526 | sync = bio_sync(bio); |
@@ -2559,6 +2561,7 @@ again: | |||
2559 | req->biotail->bi_next = bio; | 2561 | req->biotail->bi_next = bio; |
2560 | req->biotail = bio; | 2562 | req->biotail = bio; |
2561 | req->nr_sectors = req->hard_nr_sectors += nr_sectors; | 2563 | req->nr_sectors = req->hard_nr_sectors += nr_sectors; |
2564 | req->ioprio = ioprio_best(req->ioprio, prio); | ||
2562 | drive_stat_acct(req, nr_sectors, 0); | 2565 | drive_stat_acct(req, nr_sectors, 0); |
2563 | if (!attempt_back_merge(q, req)) | 2566 | if (!attempt_back_merge(q, req)) |
2564 | elv_merged_request(q, req); | 2567 | elv_merged_request(q, req); |
@@ -2583,6 +2586,7 @@ again: | |||
2583 | req->hard_cur_sectors = cur_nr_sectors; | 2586 | req->hard_cur_sectors = cur_nr_sectors; |
2584 | req->sector = req->hard_sector = sector; | 2587 | req->sector = req->hard_sector = sector; |
2585 | req->nr_sectors = req->hard_nr_sectors += nr_sectors; | 2588 | req->nr_sectors = req->hard_nr_sectors += nr_sectors; |
2589 | req->ioprio = ioprio_best(req->ioprio, prio); | ||
2586 | drive_stat_acct(req, nr_sectors, 0); | 2590 | drive_stat_acct(req, nr_sectors, 0); |
2587 | if (!attempt_front_merge(q, req)) | 2591 | if (!attempt_front_merge(q, req)) |
2588 | elv_merged_request(q, req); | 2592 | elv_merged_request(q, req); |
@@ -2610,7 +2614,7 @@ get_rq: | |||
2610 | freereq = NULL; | 2614 | freereq = NULL; |
2611 | } else { | 2615 | } else { |
2612 | spin_unlock_irq(q->queue_lock); | 2616 | spin_unlock_irq(q->queue_lock); |
2613 | if ((freereq = get_request(q, rw, GFP_ATOMIC)) == NULL) { | 2617 | if ((freereq = get_request(q, rw, bio, GFP_ATOMIC)) == NULL) { |
2614 | /* | 2618 | /* |
2615 | * READA bit set | 2619 | * READA bit set |
2616 | */ | 2620 | */ |
@@ -2618,7 +2622,7 @@ get_rq: | |||
2618 | if (bio_rw_ahead(bio)) | 2622 | if (bio_rw_ahead(bio)) |
2619 | goto end_io; | 2623 | goto end_io; |
2620 | 2624 | ||
2621 | freereq = get_request_wait(q, rw); | 2625 | freereq = get_request_wait(q, rw, bio); |
2622 | } | 2626 | } |
2623 | goto again; | 2627 | goto again; |
2624 | } | 2628 | } |
@@ -2646,6 +2650,7 @@ get_rq: | |||
2646 | req->buffer = bio_data(bio); /* see ->buffer comment above */ | 2650 | req->buffer = bio_data(bio); /* see ->buffer comment above */ |
2647 | req->waiting = NULL; | 2651 | req->waiting = NULL; |
2648 | req->bio = req->biotail = bio; | 2652 | req->bio = req->biotail = bio; |
2653 | req->ioprio = prio; | ||
2649 | req->rq_disk = bio->bi_bdev->bd_disk; | 2654 | req->rq_disk = bio->bi_bdev->bd_disk; |
2650 | req->start_time = jiffies; | 2655 | req->start_time = jiffies; |
2651 | 2656 | ||
@@ -2674,7 +2679,7 @@ static inline void blk_partition_remap(struct bio *bio) | |||
2674 | if (bdev != bdev->bd_contains) { | 2679 | if (bdev != bdev->bd_contains) { |
2675 | struct hd_struct *p = bdev->bd_part; | 2680 | struct hd_struct *p = bdev->bd_part; |
2676 | 2681 | ||
2677 | switch (bio->bi_rw) { | 2682 | switch (bio_data_dir(bio)) { |
2678 | case READ: | 2683 | case READ: |
2679 | p->read_sectors += bio_sectors(bio); | 2684 | p->read_sectors += bio_sectors(bio); |
2680 | p->reads++; | 2685 | p->reads++; |
@@ -2693,6 +2698,7 @@ void blk_finish_queue_drain(request_queue_t *q) | |||
2693 | { | 2698 | { |
2694 | struct request_list *rl = &q->rq; | 2699 | struct request_list *rl = &q->rq; |
2695 | struct request *rq; | 2700 | struct request *rq; |
2701 | int requeued = 0; | ||
2696 | 2702 | ||
2697 | spin_lock_irq(q->queue_lock); | 2703 | spin_lock_irq(q->queue_lock); |
2698 | clear_bit(QUEUE_FLAG_DRAIN, &q->queue_flags); | 2704 | clear_bit(QUEUE_FLAG_DRAIN, &q->queue_flags); |
@@ -2701,9 +2707,13 @@ void blk_finish_queue_drain(request_queue_t *q) | |||
2701 | rq = list_entry_rq(q->drain_list.next); | 2707 | rq = list_entry_rq(q->drain_list.next); |
2702 | 2708 | ||
2703 | list_del_init(&rq->queuelist); | 2709 | list_del_init(&rq->queuelist); |
2704 | __elv_add_request(q, rq, ELEVATOR_INSERT_BACK, 1); | 2710 | elv_requeue_request(q, rq); |
2711 | requeued++; | ||
2705 | } | 2712 | } |
2706 | 2713 | ||
2714 | if (requeued) | ||
2715 | q->request_fn(q); | ||
2716 | |||
2707 | spin_unlock_irq(q->queue_lock); | 2717 | spin_unlock_irq(q->queue_lock); |
2708 | 2718 | ||
2709 | wake_up(&rl->wait[0]); | 2719 | wake_up(&rl->wait[0]); |
@@ -2900,7 +2910,7 @@ void submit_bio(int rw, struct bio *bio) | |||
2900 | 2910 | ||
2901 | BIO_BUG_ON(!bio->bi_size); | 2911 | BIO_BUG_ON(!bio->bi_size); |
2902 | BIO_BUG_ON(!bio->bi_io_vec); | 2912 | BIO_BUG_ON(!bio->bi_io_vec); |
2903 | bio->bi_rw = rw; | 2913 | bio->bi_rw |= rw; |
2904 | if (rw & WRITE) | 2914 | if (rw & WRITE) |
2905 | mod_page_state(pgpgout, count); | 2915 | mod_page_state(pgpgout, count); |
2906 | else | 2916 | else |
@@ -3257,8 +3267,11 @@ void exit_io_context(void) | |||
3257 | struct io_context *ioc; | 3267 | struct io_context *ioc; |
3258 | 3268 | ||
3259 | local_irq_save(flags); | 3269 | local_irq_save(flags); |
3270 | task_lock(current); | ||
3260 | ioc = current->io_context; | 3271 | ioc = current->io_context; |
3261 | current->io_context = NULL; | 3272 | current->io_context = NULL; |
3273 | ioc->task = NULL; | ||
3274 | task_unlock(current); | ||
3262 | local_irq_restore(flags); | 3275 | local_irq_restore(flags); |
3263 | 3276 | ||
3264 | if (ioc->aic && ioc->aic->exit) | 3277 | if (ioc->aic && ioc->aic->exit) |
@@ -3293,12 +3306,12 @@ struct io_context *get_io_context(int gfp_flags) | |||
3293 | ret = kmem_cache_alloc(iocontext_cachep, gfp_flags); | 3306 | ret = kmem_cache_alloc(iocontext_cachep, gfp_flags); |
3294 | if (ret) { | 3307 | if (ret) { |
3295 | atomic_set(&ret->refcount, 1); | 3308 | atomic_set(&ret->refcount, 1); |
3296 | ret->pid = tsk->pid; | 3309 | ret->task = current; |
3310 | ret->set_ioprio = NULL; | ||
3297 | ret->last_waited = jiffies; /* doesn't matter... */ | 3311 | ret->last_waited = jiffies; /* doesn't matter... */ |
3298 | ret->nr_batch_requests = 0; /* because this is 0 */ | 3312 | ret->nr_batch_requests = 0; /* because this is 0 */ |
3299 | ret->aic = NULL; | 3313 | ret->aic = NULL; |
3300 | ret->cic = NULL; | 3314 | ret->cic = NULL; |
3301 | spin_lock_init(&ret->lock); | ||
3302 | 3315 | ||
3303 | local_irq_save(flags); | 3316 | local_irq_save(flags); |
3304 | 3317 | ||
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 556264b43425..374f404e81da 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/smp_lock.h> | 21 | #include <linux/smp_lock.h> |
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/devfs_fs_kernel.h> | 23 | #include <linux/devfs_fs_kernel.h> |
24 | #include <linux/compat.h> | ||
24 | 25 | ||
25 | struct evdev { | 26 | struct evdev { |
26 | int exist; | 27 | int exist; |
@@ -145,6 +146,41 @@ static int evdev_open(struct inode * inode, struct file * file) | |||
145 | return 0; | 146 | return 0; |
146 | } | 147 | } |
147 | 148 | ||
149 | #ifdef CONFIG_COMPAT | ||
150 | struct input_event_compat { | ||
151 | struct compat_timeval time; | ||
152 | __u16 type; | ||
153 | __u16 code; | ||
154 | __s32 value; | ||
155 | }; | ||
156 | |||
157 | #ifdef CONFIG_X86_64 | ||
158 | # define COMPAT_TEST test_thread_flag(TIF_IA32) | ||
159 | #elif defined(CONFIG_IA64) | ||
160 | # define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current)) | ||
161 | #elif defined(CONFIG_ARCH_S390) | ||
162 | # define COMPAT_TEST test_thread_flag(TIF_31BIT) | ||
163 | #else | ||
164 | # define COMPAT_TEST test_thread_flag(TIF_32BIT) | ||
165 | #endif | ||
166 | |||
167 | static ssize_t evdev_write_compat(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) | ||
168 | { | ||
169 | struct evdev_list *list = file->private_data; | ||
170 | struct input_event_compat event; | ||
171 | int retval = 0; | ||
172 | |||
173 | while (retval < count) { | ||
174 | if (copy_from_user(&event, buffer + retval, sizeof(struct input_event_compat))) | ||
175 | return -EFAULT; | ||
176 | input_event(list->evdev->handle.dev, event.type, event.code, event.value); | ||
177 | retval += sizeof(struct input_event_compat); | ||
178 | } | ||
179 | |||
180 | return retval; | ||
181 | } | ||
182 | #endif | ||
183 | |||
148 | static ssize_t evdev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) | 184 | static ssize_t evdev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) |
149 | { | 185 | { |
150 | struct evdev_list *list = file->private_data; | 186 | struct evdev_list *list = file->private_data; |
@@ -153,6 +189,11 @@ static ssize_t evdev_write(struct file * file, const char __user * buffer, size_ | |||
153 | 189 | ||
154 | if (!list->evdev->exist) return -ENODEV; | 190 | if (!list->evdev->exist) return -ENODEV; |
155 | 191 | ||
192 | #ifdef CONFIG_COMPAT | ||
193 | if (COMPAT_TEST) | ||
194 | return evdev_write_compat(file, buffer, count, ppos); | ||
195 | #endif | ||
196 | |||
156 | while (retval < count) { | 197 | while (retval < count) { |
157 | 198 | ||
158 | if (copy_from_user(&event, buffer + retval, sizeof(struct input_event))) | 199 | if (copy_from_user(&event, buffer + retval, sizeof(struct input_event))) |
@@ -164,11 +205,56 @@ static ssize_t evdev_write(struct file * file, const char __user * buffer, size_ | |||
164 | return retval; | 205 | return retval; |
165 | } | 206 | } |
166 | 207 | ||
208 | #ifdef CONFIG_COMPAT | ||
209 | static ssize_t evdev_read_compat(struct file * file, char __user * buffer, size_t count, loff_t *ppos) | ||
210 | { | ||
211 | struct evdev_list *list = file->private_data; | ||
212 | int retval; | ||
213 | |||
214 | if (count < sizeof(struct input_event_compat)) | ||
215 | return -EINVAL; | ||
216 | |||
217 | if (list->head == list->tail && list->evdev->exist && (file->f_flags & O_NONBLOCK)) | ||
218 | return -EAGAIN; | ||
219 | |||
220 | retval = wait_event_interruptible(list->evdev->wait, | ||
221 | list->head != list->tail || (!list->evdev->exist)); | ||
222 | |||
223 | if (retval) | ||
224 | return retval; | ||
225 | |||
226 | if (!list->evdev->exist) | ||
227 | return -ENODEV; | ||
228 | |||
229 | while (list->head != list->tail && retval + sizeof(struct input_event_compat) <= count) { | ||
230 | struct input_event *event = (struct input_event *) list->buffer + list->tail; | ||
231 | struct input_event_compat event_compat; | ||
232 | event_compat.time.tv_sec = event->time.tv_sec; | ||
233 | event_compat.time.tv_usec = event->time.tv_usec; | ||
234 | event_compat.type = event->type; | ||
235 | event_compat.code = event->code; | ||
236 | event_compat.value = event->value; | ||
237 | |||
238 | if (copy_to_user(buffer + retval, &event_compat, | ||
239 | sizeof(struct input_event_compat))) return -EFAULT; | ||
240 | list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1); | ||
241 | retval += sizeof(struct input_event_compat); | ||
242 | } | ||
243 | |||
244 | return retval; | ||
245 | } | ||
246 | #endif | ||
247 | |||
167 | static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) | 248 | static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) |
168 | { | 249 | { |
169 | struct evdev_list *list = file->private_data; | 250 | struct evdev_list *list = file->private_data; |
170 | int retval; | 251 | int retval; |
171 | 252 | ||
253 | #ifdef CONFIG_COMPAT | ||
254 | if (COMPAT_TEST) | ||
255 | return evdev_read_compat(file, buffer, count, ppos); | ||
256 | #endif | ||
257 | |||
172 | if (count < sizeof(struct input_event)) | 258 | if (count < sizeof(struct input_event)) |
173 | return -EINVAL; | 259 | return -EINVAL; |
174 | 260 | ||
@@ -186,7 +272,7 @@ static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count | |||
186 | 272 | ||
187 | while (list->head != list->tail && retval + sizeof(struct input_event) <= count) { | 273 | while (list->head != list->tail && retval + sizeof(struct input_event) <= count) { |
188 | if (copy_to_user(buffer + retval, list->buffer + list->tail, | 274 | if (copy_to_user(buffer + retval, list->buffer + list->tail, |
189 | sizeof(struct input_event))) return -EFAULT; | 275 | sizeof(struct input_event))) return -EFAULT; |
190 | list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1); | 276 | list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1); |
191 | retval += sizeof(struct input_event); | 277 | retval += sizeof(struct input_event); |
192 | } | 278 | } |
@@ -203,7 +289,7 @@ static unsigned int evdev_poll(struct file *file, poll_table *wait) | |||
203 | (list->evdev->exist ? 0 : (POLLHUP | POLLERR)); | 289 | (list->evdev->exist ? 0 : (POLLHUP | POLLERR)); |
204 | } | 290 | } |
205 | 291 | ||
206 | static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 292 | static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
207 | { | 293 | { |
208 | struct evdev_list *list = file->private_data; | 294 | struct evdev_list *list = file->private_data; |
209 | struct evdev *evdev = list->evdev; | 295 | struct evdev *evdev = list->evdev; |
@@ -285,109 +371,267 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
285 | 371 | ||
286 | default: | 372 | default: |
287 | 373 | ||
288 | if (_IOC_TYPE(cmd) != 'E' || _IOC_DIR(cmd) != _IOC_READ) | 374 | if (_IOC_TYPE(cmd) != 'E') |
289 | return -EINVAL; | 375 | return -EINVAL; |
290 | 376 | ||
291 | if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) { | 377 | if (_IOC_DIR(cmd) == _IOC_READ) { |
292 | 378 | ||
293 | long *bits; | 379 | if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) { |
294 | int len; | 380 | |
295 | 381 | long *bits; | |
296 | switch (_IOC_NR(cmd) & EV_MAX) { | 382 | int len; |
297 | case 0: bits = dev->evbit; len = EV_MAX; break; | 383 | |
298 | case EV_KEY: bits = dev->keybit; len = KEY_MAX; break; | 384 | switch (_IOC_NR(cmd) & EV_MAX) { |
299 | case EV_REL: bits = dev->relbit; len = REL_MAX; break; | 385 | case 0: bits = dev->evbit; len = EV_MAX; break; |
300 | case EV_ABS: bits = dev->absbit; len = ABS_MAX; break; | 386 | case EV_KEY: bits = dev->keybit; len = KEY_MAX; break; |
301 | case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break; | 387 | case EV_REL: bits = dev->relbit; len = REL_MAX; break; |
302 | case EV_LED: bits = dev->ledbit; len = LED_MAX; break; | 388 | case EV_ABS: bits = dev->absbit; len = ABS_MAX; break; |
303 | case EV_SND: bits = dev->sndbit; len = SND_MAX; break; | 389 | case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break; |
304 | case EV_FF: bits = dev->ffbit; len = FF_MAX; break; | 390 | case EV_LED: bits = dev->ledbit; len = LED_MAX; break; |
305 | default: return -EINVAL; | 391 | case EV_SND: bits = dev->sndbit; len = SND_MAX; break; |
392 | case EV_FF: bits = dev->ffbit; len = FF_MAX; break; | ||
393 | default: return -EINVAL; | ||
394 | } | ||
395 | len = NBITS(len) * sizeof(long); | ||
396 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
397 | return copy_to_user(p, bits, len) ? -EFAULT : len; | ||
306 | } | 398 | } |
307 | len = NBITS(len) * sizeof(long); | ||
308 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
309 | return copy_to_user(p, bits, len) ? -EFAULT : len; | ||
310 | } | ||
311 | 399 | ||
312 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) { | 400 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) { |
313 | int len; | 401 | int len; |
314 | len = NBITS(KEY_MAX) * sizeof(long); | 402 | len = NBITS(KEY_MAX) * sizeof(long); |
315 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | 403 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); |
316 | return copy_to_user(p, dev->key, len) ? -EFAULT : len; | 404 | return copy_to_user(p, dev->key, len) ? -EFAULT : len; |
317 | } | 405 | } |
318 | 406 | ||
319 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0))) { | 407 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0))) { |
320 | int len; | 408 | int len; |
321 | len = NBITS(LED_MAX) * sizeof(long); | 409 | len = NBITS(LED_MAX) * sizeof(long); |
322 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | 410 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); |
323 | return copy_to_user(p, dev->led, len) ? -EFAULT : len; | 411 | return copy_to_user(p, dev->led, len) ? -EFAULT : len; |
324 | } | 412 | } |
325 | 413 | ||
326 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) { | 414 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) { |
327 | int len; | 415 | int len; |
328 | len = NBITS(SND_MAX) * sizeof(long); | 416 | len = NBITS(SND_MAX) * sizeof(long); |
329 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | 417 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); |
330 | return copy_to_user(p, dev->snd, len) ? -EFAULT : len; | 418 | return copy_to_user(p, dev->snd, len) ? -EFAULT : len; |
331 | } | 419 | } |
332 | 420 | ||
333 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { | 421 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { |
334 | int len; | 422 | int len; |
335 | if (!dev->name) return -ENOENT; | 423 | if (!dev->name) return -ENOENT; |
336 | len = strlen(dev->name) + 1; | 424 | len = strlen(dev->name) + 1; |
337 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | 425 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); |
338 | return copy_to_user(p, dev->name, len) ? -EFAULT : len; | 426 | return copy_to_user(p, dev->name, len) ? -EFAULT : len; |
339 | } | 427 | } |
428 | |||
429 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) { | ||
430 | int len; | ||
431 | if (!dev->phys) return -ENOENT; | ||
432 | len = strlen(dev->phys) + 1; | ||
433 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
434 | return copy_to_user(p, dev->phys, len) ? -EFAULT : len; | ||
435 | } | ||
436 | |||
437 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0))) { | ||
438 | int len; | ||
439 | if (!dev->uniq) return -ENOENT; | ||
440 | len = strlen(dev->uniq) + 1; | ||
441 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
442 | return copy_to_user(p, dev->uniq, len) ? -EFAULT : len; | ||
443 | } | ||
444 | |||
445 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { | ||
446 | |||
447 | int t = _IOC_NR(cmd) & ABS_MAX; | ||
448 | |||
449 | abs.value = dev->abs[t]; | ||
450 | abs.minimum = dev->absmin[t]; | ||
451 | abs.maximum = dev->absmax[t]; | ||
452 | abs.fuzz = dev->absfuzz[t]; | ||
453 | abs.flat = dev->absflat[t]; | ||
454 | |||
455 | if (copy_to_user(p, &abs, sizeof(struct input_absinfo))) | ||
456 | return -EFAULT; | ||
457 | |||
458 | return 0; | ||
459 | } | ||
340 | 460 | ||
341 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) { | ||
342 | int len; | ||
343 | if (!dev->phys) return -ENOENT; | ||
344 | len = strlen(dev->phys) + 1; | ||
345 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
346 | return copy_to_user(p, dev->phys, len) ? -EFAULT : len; | ||
347 | } | 461 | } |
348 | 462 | ||
349 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0))) { | 463 | if (_IOC_DIR(cmd) == _IOC_WRITE) { |
350 | int len; | 464 | |
351 | if (!dev->uniq) return -ENOENT; | 465 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { |
352 | len = strlen(dev->uniq) + 1; | 466 | |
353 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | 467 | int t = _IOC_NR(cmd) & ABS_MAX; |
354 | return copy_to_user(p, dev->uniq, len) ? -EFAULT : len; | 468 | |
469 | if (copy_from_user(&abs, p, sizeof(struct input_absinfo))) | ||
470 | return -EFAULT; | ||
471 | |||
472 | dev->abs[t] = abs.value; | ||
473 | dev->absmin[t] = abs.minimum; | ||
474 | dev->absmax[t] = abs.maximum; | ||
475 | dev->absfuzz[t] = abs.fuzz; | ||
476 | dev->absflat[t] = abs.flat; | ||
477 | |||
478 | return 0; | ||
479 | } | ||
355 | } | 480 | } |
481 | } | ||
482 | return -EINVAL; | ||
483 | } | ||
356 | 484 | ||
357 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { | 485 | #ifdef CONFIG_COMPAT |
486 | |||
487 | #define BITS_PER_LONG_COMPAT (sizeof(compat_long_t) * 8) | ||
488 | #define NBITS_COMPAT(x) ((((x)-1)/BITS_PER_LONG_COMPAT)+1) | ||
489 | #define OFF_COMPAT(x) ((x)%BITS_PER_LONG_COMPAT) | ||
490 | #define BIT_COMPAT(x) (1UL<<OFF_COMPAT(x)) | ||
491 | #define LONG_COMPAT(x) ((x)/BITS_PER_LONG_COMPAT) | ||
492 | #define test_bit_compat(bit, array) ((array[LONG_COMPAT(bit)] >> OFF_COMPAT(bit)) & 1) | ||
493 | |||
494 | #ifdef __BIG_ENDIAN | ||
495 | #define bit_to_user(bit, max) \ | ||
496 | do { \ | ||
497 | int i; \ | ||
498 | int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ | ||
499 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ | ||
500 | for (i = 0; i < len / sizeof(compat_long_t); i++) \ | ||
501 | if (copy_to_user((compat_long_t*) p + i, \ | ||
502 | (compat_long_t*) (bit) + i + 1 - ((i % 2) << 1), \ | ||
503 | sizeof(compat_long_t))) \ | ||
504 | return -EFAULT; \ | ||
505 | return len; \ | ||
506 | } while (0) | ||
507 | #else | ||
508 | #define bit_to_user(bit, max) \ | ||
509 | do { \ | ||
510 | int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ | ||
511 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ | ||
512 | return copy_to_user(p, (bit), len) ? -EFAULT : len; \ | ||
513 | } while (0) | ||
514 | #endif | ||
515 | |||
516 | static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) | ||
517 | { | ||
518 | struct evdev_list *list = file->private_data; | ||
519 | struct evdev *evdev = list->evdev; | ||
520 | struct input_dev *dev = evdev->handle.dev; | ||
521 | struct input_absinfo abs; | ||
522 | void __user *p = compat_ptr(arg); | ||
358 | 523 | ||
359 | int t = _IOC_NR(cmd) & ABS_MAX; | 524 | if (!evdev->exist) return -ENODEV; |
360 | 525 | ||
361 | abs.value = dev->abs[t]; | 526 | switch (cmd) { |
362 | abs.minimum = dev->absmin[t]; | ||
363 | abs.maximum = dev->absmax[t]; | ||
364 | abs.fuzz = dev->absfuzz[t]; | ||
365 | abs.flat = dev->absflat[t]; | ||
366 | 527 | ||
367 | if (copy_to_user(p, &abs, sizeof(struct input_absinfo))) | 528 | case EVIOCGVERSION: |
368 | return -EFAULT; | 529 | case EVIOCGID: |
530 | case EVIOCGKEYCODE: | ||
531 | case EVIOCSKEYCODE: | ||
532 | case EVIOCSFF: | ||
533 | case EVIOCRMFF: | ||
534 | case EVIOCGEFFECTS: | ||
535 | case EVIOCGRAB: | ||
536 | return evdev_ioctl(file, cmd, (unsigned long) p); | ||
369 | 537 | ||
370 | return 0; | 538 | default: |
539 | |||
540 | if (_IOC_TYPE(cmd) != 'E') | ||
541 | return -EINVAL; | ||
542 | |||
543 | if (_IOC_DIR(cmd) == _IOC_READ) { | ||
544 | |||
545 | if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) { | ||
546 | long *bits; | ||
547 | int max; | ||
548 | |||
549 | switch (_IOC_NR(cmd) & EV_MAX) { | ||
550 | case 0: bits = dev->evbit; max = EV_MAX; break; | ||
551 | case EV_KEY: bits = dev->keybit; max = KEY_MAX; break; | ||
552 | case EV_REL: bits = dev->relbit; max = REL_MAX; break; | ||
553 | case EV_ABS: bits = dev->absbit; max = ABS_MAX; break; | ||
554 | case EV_MSC: bits = dev->mscbit; max = MSC_MAX; break; | ||
555 | case EV_LED: bits = dev->ledbit; max = LED_MAX; break; | ||
556 | case EV_SND: bits = dev->sndbit; max = SND_MAX; break; | ||
557 | case EV_FF: bits = dev->ffbit; max = FF_MAX; break; | ||
558 | default: return -EINVAL; | ||
559 | } | ||
560 | bit_to_user(bits, max); | ||
561 | } | ||
562 | |||
563 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) | ||
564 | bit_to_user(dev->key, KEY_MAX); | ||
565 | |||
566 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0))) | ||
567 | bit_to_user(dev->led, LED_MAX); | ||
568 | |||
569 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) | ||
570 | bit_to_user(dev->snd, SND_MAX); | ||
571 | |||
572 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { | ||
573 | int len; | ||
574 | if (!dev->name) return -ENOENT; | ||
575 | len = strlen(dev->name) + 1; | ||
576 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
577 | return copy_to_user(p, dev->name, len) ? -EFAULT : len; | ||
578 | } | ||
579 | |||
580 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) { | ||
581 | int len; | ||
582 | if (!dev->phys) return -ENOENT; | ||
583 | len = strlen(dev->phys) + 1; | ||
584 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
585 | return copy_to_user(p, dev->phys, len) ? -EFAULT : len; | ||
586 | } | ||
587 | |||
588 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0))) { | ||
589 | int len; | ||
590 | if (!dev->uniq) return -ENOENT; | ||
591 | len = strlen(dev->uniq) + 1; | ||
592 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
593 | return copy_to_user(p, dev->uniq, len) ? -EFAULT : len; | ||
594 | } | ||
595 | |||
596 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { | ||
597 | |||
598 | int t = _IOC_NR(cmd) & ABS_MAX; | ||
599 | |||
600 | abs.value = dev->abs[t]; | ||
601 | abs.minimum = dev->absmin[t]; | ||
602 | abs.maximum = dev->absmax[t]; | ||
603 | abs.fuzz = dev->absfuzz[t]; | ||
604 | abs.flat = dev->absflat[t]; | ||
605 | |||
606 | if (copy_to_user(p, &abs, sizeof(struct input_absinfo))) | ||
607 | return -EFAULT; | ||
608 | |||
609 | return 0; | ||
610 | } | ||
371 | } | 611 | } |
372 | 612 | ||
373 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { | 613 | if (_IOC_DIR(cmd) == _IOC_WRITE) { |
374 | 614 | ||
375 | int t = _IOC_NR(cmd) & ABS_MAX; | 615 | if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { |
376 | 616 | ||
377 | if (copy_from_user(&abs, p, sizeof(struct input_absinfo))) | 617 | int t = _IOC_NR(cmd) & ABS_MAX; |
378 | return -EFAULT; | ||
379 | 618 | ||
380 | dev->abs[t] = abs.value; | 619 | if (copy_from_user(&abs, p, sizeof(struct input_absinfo))) |
381 | dev->absmin[t] = abs.minimum; | 620 | return -EFAULT; |
382 | dev->absmax[t] = abs.maximum; | ||
383 | dev->absfuzz[t] = abs.fuzz; | ||
384 | dev->absflat[t] = abs.flat; | ||
385 | 621 | ||
386 | return 0; | 622 | dev->abs[t] = abs.value; |
623 | dev->absmin[t] = abs.minimum; | ||
624 | dev->absmax[t] = abs.maximum; | ||
625 | dev->absfuzz[t] = abs.fuzz; | ||
626 | dev->absflat[t] = abs.flat; | ||
627 | |||
628 | return 0; | ||
629 | } | ||
387 | } | 630 | } |
388 | } | 631 | } |
389 | return -EINVAL; | 632 | return -EINVAL; |
390 | } | 633 | } |
634 | #endif | ||
391 | 635 | ||
392 | static struct file_operations evdev_fops = { | 636 | static struct file_operations evdev_fops = { |
393 | .owner = THIS_MODULE, | 637 | .owner = THIS_MODULE, |
@@ -396,7 +640,10 @@ static struct file_operations evdev_fops = { | |||
396 | .poll = evdev_poll, | 640 | .poll = evdev_poll, |
397 | .open = evdev_open, | 641 | .open = evdev_open, |
398 | .release = evdev_release, | 642 | .release = evdev_release, |
399 | .ioctl = evdev_ioctl, | 643 | .unlocked_ioctl = evdev_ioctl, |
644 | #ifdef CONFIG_COMPAT | ||
645 | .compat_ioctl = evdev_ioctl_compat, | ||
646 | #endif | ||
400 | .fasync = evdev_fasync, | 647 | .fasync = evdev_fasync, |
401 | .flush = evdev_flush | 648 | .flush = evdev_flush |
402 | }; | 649 | }; |
diff --git a/drivers/input/gameport/Kconfig b/drivers/input/gameport/Kconfig index 1d93f5092904..7524bd7d8b8f 100644 --- a/drivers/input/gameport/Kconfig +++ b/drivers/input/gameport/Kconfig | |||
@@ -49,22 +49,8 @@ config GAMEPORT_EMU10K1 | |||
49 | To compile this driver as a module, choose M here: the | 49 | To compile this driver as a module, choose M here: the |
50 | module will be called emu10k1-gp. | 50 | module will be called emu10k1-gp. |
51 | 51 | ||
52 | config GAMEPORT_VORTEX | ||
53 | tristate "Aureal Vortex, Vortex 2 gameport support" | ||
54 | depends on PCI | ||
55 | help | ||
56 | Say Y here if you have an Aureal Vortex 1 or 2 card and want | ||
57 | to use its gameport. | ||
58 | |||
59 | To compile this driver as a module, choose M here: the | ||
60 | module will be called vortex. | ||
61 | |||
62 | config GAMEPORT_FM801 | 52 | config GAMEPORT_FM801 |
63 | tristate "ForteMedia FM801 gameport support" | 53 | tristate "ForteMedia FM801 gameport support" |
64 | depends on PCI | 54 | depends on PCI |
65 | 55 | ||
66 | config GAMEPORT_CS461X | ||
67 | tristate "Crystal SoundFusion gameport support" | ||
68 | depends on PCI | ||
69 | |||
70 | endif | 56 | endif |
diff --git a/drivers/input/gameport/Makefile b/drivers/input/gameport/Makefile index 5367b4267adf..b6f6097bd8c4 100644 --- a/drivers/input/gameport/Makefile +++ b/drivers/input/gameport/Makefile | |||
@@ -5,9 +5,7 @@ | |||
5 | # Each configuration option enables a list of files. | 5 | # Each configuration option enables a list of files. |
6 | 6 | ||
7 | obj-$(CONFIG_GAMEPORT) += gameport.o | 7 | obj-$(CONFIG_GAMEPORT) += gameport.o |
8 | obj-$(CONFIG_GAMEPORT_CS461X) += cs461x.o | ||
9 | obj-$(CONFIG_GAMEPORT_EMU10K1) += emu10k1-gp.o | 8 | obj-$(CONFIG_GAMEPORT_EMU10K1) += emu10k1-gp.o |
10 | obj-$(CONFIG_GAMEPORT_FM801) += fm801-gp.o | 9 | obj-$(CONFIG_GAMEPORT_FM801) += fm801-gp.o |
11 | obj-$(CONFIG_GAMEPORT_L4) += lightning.o | 10 | obj-$(CONFIG_GAMEPORT_L4) += lightning.o |
12 | obj-$(CONFIG_GAMEPORT_NS558) += ns558.o | 11 | obj-$(CONFIG_GAMEPORT_NS558) += ns558.o |
13 | obj-$(CONFIG_GAMEPORT_VORTEX) += vortex.o | ||
diff --git a/drivers/input/gameport/cs461x.c b/drivers/input/gameport/cs461x.c deleted file mode 100644 index d4013ff98623..000000000000 --- a/drivers/input/gameport/cs461x.c +++ /dev/null | |||
@@ -1,322 +0,0 @@ | |||
1 | /* | ||
2 | The all defines and part of code (such as cs461x_*) are | ||
3 | contributed from ALSA 0.5.8 sources. | ||
4 | See http://www.alsa-project.org/ for sources | ||
5 | |||
6 | Tested on Linux 686 2.4.0-test9, ALSA 0.5.8a and CS4610 | ||
7 | */ | ||
8 | |||
9 | #include <asm/io.h> | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/ioport.h> | ||
13 | #include <linux/config.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/gameport.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/pci.h> | ||
18 | |||
19 | MODULE_AUTHOR("Victor Krapivin"); | ||
20 | MODULE_LICENSE("GPL"); | ||
21 | |||
22 | /* | ||
23 | These options are experimental | ||
24 | |||
25 | #define CS461X_FULL_MAP | ||
26 | */ | ||
27 | |||
28 | |||
29 | #ifndef PCI_VENDOR_ID_CIRRUS | ||
30 | #define PCI_VENDOR_ID_CIRRUS 0x1013 | ||
31 | #endif | ||
32 | #ifndef PCI_DEVICE_ID_CIRRUS_4610 | ||
33 | #define PCI_DEVICE_ID_CIRRUS_4610 0x6001 | ||
34 | #endif | ||
35 | #ifndef PCI_DEVICE_ID_CIRRUS_4612 | ||
36 | #define PCI_DEVICE_ID_CIRRUS_4612 0x6003 | ||
37 | #endif | ||
38 | #ifndef PCI_DEVICE_ID_CIRRUS_4615 | ||
39 | #define PCI_DEVICE_ID_CIRRUS_4615 0x6004 | ||
40 | #endif | ||
41 | |||
42 | /* Registers */ | ||
43 | |||
44 | #define BA0_JSPT 0x00000480 | ||
45 | #define BA0_JSCTL 0x00000484 | ||
46 | #define BA0_JSC1 0x00000488 | ||
47 | #define BA0_JSC2 0x0000048C | ||
48 | #define BA0_JSIO 0x000004A0 | ||
49 | |||
50 | /* Bits for JSPT */ | ||
51 | |||
52 | #define JSPT_CAX 0x00000001 | ||
53 | #define JSPT_CAY 0x00000002 | ||
54 | #define JSPT_CBX 0x00000004 | ||
55 | #define JSPT_CBY 0x00000008 | ||
56 | #define JSPT_BA1 0x00000010 | ||
57 | #define JSPT_BA2 0x00000020 | ||
58 | #define JSPT_BB1 0x00000040 | ||
59 | #define JSPT_BB2 0x00000080 | ||
60 | |||
61 | /* Bits for JSCTL */ | ||
62 | |||
63 | #define JSCTL_SP_MASK 0x00000003 | ||
64 | #define JSCTL_SP_SLOW 0x00000000 | ||
65 | #define JSCTL_SP_MEDIUM_SLOW 0x00000001 | ||
66 | #define JSCTL_SP_MEDIUM_FAST 0x00000002 | ||
67 | #define JSCTL_SP_FAST 0x00000003 | ||
68 | #define JSCTL_ARE 0x00000004 | ||
69 | |||
70 | /* Data register pairs masks */ | ||
71 | |||
72 | #define JSC1_Y1V_MASK 0x0000FFFF | ||
73 | #define JSC1_X1V_MASK 0xFFFF0000 | ||
74 | #define JSC1_Y1V_SHIFT 0 | ||
75 | #define JSC1_X1V_SHIFT 16 | ||
76 | #define JSC2_Y2V_MASK 0x0000FFFF | ||
77 | #define JSC2_X2V_MASK 0xFFFF0000 | ||
78 | #define JSC2_Y2V_SHIFT 0 | ||
79 | #define JSC2_X2V_SHIFT 16 | ||
80 | |||
81 | /* JS GPIO */ | ||
82 | |||
83 | #define JSIO_DAX 0x00000001 | ||
84 | #define JSIO_DAY 0x00000002 | ||
85 | #define JSIO_DBX 0x00000004 | ||
86 | #define JSIO_DBY 0x00000008 | ||
87 | #define JSIO_AXOE 0x00000010 | ||
88 | #define JSIO_AYOE 0x00000020 | ||
89 | #define JSIO_BXOE 0x00000040 | ||
90 | #define JSIO_BYOE 0x00000080 | ||
91 | |||
92 | /* | ||
93 | The card initialization code is obfuscated; the module cs461x | ||
94 | need to be loaded after ALSA modules initialized and something | ||
95 | played on the CS 4610 chip (see sources for details of CS4610 | ||
96 | initialization code from ALSA) | ||
97 | */ | ||
98 | |||
99 | /* Card specific definitions */ | ||
100 | |||
101 | #define CS461X_BA0_SIZE 0x2000 | ||
102 | #define CS461X_BA1_DATA0_SIZE 0x3000 | ||
103 | #define CS461X_BA1_DATA1_SIZE 0x3800 | ||
104 | #define CS461X_BA1_PRG_SIZE 0x7000 | ||
105 | #define CS461X_BA1_REG_SIZE 0x0100 | ||
106 | |||
107 | #define BA1_SP_DMEM0 0x00000000 | ||
108 | #define BA1_SP_DMEM1 0x00010000 | ||
109 | #define BA1_SP_PMEM 0x00020000 | ||
110 | #define BA1_SP_REG 0x00030000 | ||
111 | |||
112 | #define BA1_DWORD_SIZE (13 * 1024 + 512) | ||
113 | #define BA1_MEMORY_COUNT 3 | ||
114 | |||
115 | /* | ||
116 | Only one CS461x card is still suppoted; the code requires | ||
117 | redesign to avoid this limitatuion. | ||
118 | */ | ||
119 | |||
120 | static unsigned long ba0_addr; | ||
121 | static unsigned int __iomem *ba0; | ||
122 | |||
123 | #ifdef CS461X_FULL_MAP | ||
124 | static unsigned long ba1_addr; | ||
125 | static union ba1_t { | ||
126 | struct { | ||
127 | unsigned int __iomem *data0; | ||
128 | unsigned int __iomem *data1; | ||
129 | unsigned int __iomem *pmem; | ||
130 | unsigned int __iomem *reg; | ||
131 | } name; | ||
132 | unsigned int __iomem *idx[4]; | ||
133 | } ba1; | ||
134 | |||
135 | static void cs461x_poke(unsigned long reg, unsigned int val) | ||
136 | { | ||
137 | writel(val, &ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff]); | ||
138 | } | ||
139 | |||
140 | static unsigned int cs461x_peek(unsigned long reg) | ||
141 | { | ||
142 | return readl(&ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff]); | ||
143 | } | ||
144 | |||
145 | #endif | ||
146 | |||
147 | static void cs461x_pokeBA0(unsigned long reg, unsigned int val) | ||
148 | { | ||
149 | writel(val, &ba0[reg >> 2]); | ||
150 | } | ||
151 | |||
152 | static unsigned int cs461x_peekBA0(unsigned long reg) | ||
153 | { | ||
154 | return readl(&ba0[reg >> 2]); | ||
155 | } | ||
156 | |||
157 | static int cs461x_free(struct pci_dev *pdev) | ||
158 | { | ||
159 | struct gameport *port = pci_get_drvdata(pdev); | ||
160 | |||
161 | if (port) | ||
162 | gameport_unregister_port(port); | ||
163 | |||
164 | if (ba0) iounmap(ba0); | ||
165 | #ifdef CS461X_FULL_MAP | ||
166 | if (ba1.name.data0) iounmap(ba1.name.data0); | ||
167 | if (ba1.name.data1) iounmap(ba1.name.data1); | ||
168 | if (ba1.name.pmem) iounmap(ba1.name.pmem); | ||
169 | if (ba1.name.reg) iounmap(ba1.name.reg); | ||
170 | #endif | ||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static void cs461x_gameport_trigger(struct gameport *gameport) | ||
175 | { | ||
176 | cs461x_pokeBA0(BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); | ||
177 | } | ||
178 | |||
179 | static unsigned char cs461x_gameport_read(struct gameport *gameport) | ||
180 | { | ||
181 | return cs461x_peekBA0(BA0_JSPT); //inb(gameport->io); | ||
182 | } | ||
183 | |||
184 | static int cs461x_gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons) | ||
185 | { | ||
186 | unsigned js1, js2, jst; | ||
187 | |||
188 | js1 = cs461x_peekBA0(BA0_JSC1); | ||
189 | js2 = cs461x_peekBA0(BA0_JSC2); | ||
190 | jst = cs461x_peekBA0(BA0_JSPT); | ||
191 | |||
192 | *buttons = (~jst >> 4) & 0x0F; | ||
193 | |||
194 | axes[0] = ((js1 & JSC1_Y1V_MASK) >> JSC1_Y1V_SHIFT) & 0xFFFF; | ||
195 | axes[1] = ((js1 & JSC1_X1V_MASK) >> JSC1_X1V_SHIFT) & 0xFFFF; | ||
196 | axes[2] = ((js2 & JSC2_Y2V_MASK) >> JSC2_Y2V_SHIFT) & 0xFFFF; | ||
197 | axes[3] = ((js2 & JSC2_X2V_MASK) >> JSC2_X2V_SHIFT) & 0xFFFF; | ||
198 | |||
199 | for(jst=0;jst<4;++jst) | ||
200 | if(axes[jst]==0xFFFF) axes[jst] = -1; | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static int cs461x_gameport_open(struct gameport *gameport, int mode) | ||
205 | { | ||
206 | switch (mode) { | ||
207 | case GAMEPORT_MODE_COOKED: | ||
208 | case GAMEPORT_MODE_RAW: | ||
209 | return 0; | ||
210 | default: | ||
211 | return -1; | ||
212 | } | ||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | static struct pci_device_id cs461x_pci_tbl[] = { | ||
217 | { PCI_VENDOR_ID_CIRRUS, 0x6001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Cirrus CS4610 */ | ||
218 | { PCI_VENDOR_ID_CIRRUS, 0x6003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Cirrus CS4612 */ | ||
219 | { PCI_VENDOR_ID_CIRRUS, 0x6005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Cirrus CS4615 */ | ||
220 | { 0, } | ||
221 | }; | ||
222 | MODULE_DEVICE_TABLE(pci, cs461x_pci_tbl); | ||
223 | |||
224 | static int __devinit cs461x_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | ||
225 | { | ||
226 | int rc; | ||
227 | struct gameport* port; | ||
228 | |||
229 | rc = pci_enable_device(pdev); | ||
230 | if (rc) { | ||
231 | printk(KERN_ERR "cs461x: Cannot enable PCI gameport (bus %d, devfn %d) error=%d\n", | ||
232 | pdev->bus->number, pdev->devfn, rc); | ||
233 | return rc; | ||
234 | } | ||
235 | |||
236 | ba0_addr = pci_resource_start(pdev, 0); | ||
237 | #ifdef CS461X_FULL_MAP | ||
238 | ba1_addr = pci_resource_start(pdev, 1); | ||
239 | #endif | ||
240 | if (ba0_addr == 0 || ba0_addr == ~0 | ||
241 | #ifdef CS461X_FULL_MAP | ||
242 | || ba1_addr == 0 || ba1_addr == ~0 | ||
243 | #endif | ||
244 | ) { | ||
245 | printk(KERN_ERR "cs461x: wrong address - ba0 = 0x%lx\n", ba0_addr); | ||
246 | #ifdef CS461X_FULL_MAP | ||
247 | printk(KERN_ERR "cs461x: wrong address - ba1 = 0x%lx\n", ba1_addr); | ||
248 | #endif | ||
249 | cs461x_free(pdev); | ||
250 | return -ENOMEM; | ||
251 | } | ||
252 | |||
253 | ba0 = ioremap(ba0_addr, CS461X_BA0_SIZE); | ||
254 | #ifdef CS461X_FULL_MAP | ||
255 | ba1.name.data0 = ioremap(ba1_addr + BA1_SP_DMEM0, CS461X_BA1_DATA0_SIZE); | ||
256 | ba1.name.data1 = ioremap(ba1_addr + BA1_SP_DMEM1, CS461X_BA1_DATA1_SIZE); | ||
257 | ba1.name.pmem = ioremap(ba1_addr + BA1_SP_PMEM, CS461X_BA1_PRG_SIZE); | ||
258 | ba1.name.reg = ioremap(ba1_addr + BA1_SP_REG, CS461X_BA1_REG_SIZE); | ||
259 | |||
260 | if (ba0 == NULL || ba1.name.data0 == NULL || | ||
261 | ba1.name.data1 == NULL || ba1.name.pmem == NULL || | ||
262 | ba1.name.reg == NULL) { | ||
263 | cs461x_free(pdev); | ||
264 | return -ENOMEM; | ||
265 | } | ||
266 | #else | ||
267 | if (ba0 == NULL) { | ||
268 | cs461x_free(pdev); | ||
269 | return -ENOMEM; | ||
270 | } | ||
271 | #endif | ||
272 | |||
273 | if (!(port = gameport_allocate_port())) { | ||
274 | printk(KERN_ERR "cs461x: Memory allocation failed\n"); | ||
275 | cs461x_free(pdev); | ||
276 | return -ENOMEM; | ||
277 | } | ||
278 | |||
279 | pci_set_drvdata(pdev, port); | ||
280 | |||
281 | port->open = cs461x_gameport_open; | ||
282 | port->trigger = cs461x_gameport_trigger; | ||
283 | port->read = cs461x_gameport_read; | ||
284 | port->cooked_read = cs461x_gameport_cooked_read; | ||
285 | |||
286 | gameport_set_name(port, "CS416x"); | ||
287 | gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev)); | ||
288 | port->dev.parent = &pdev->dev; | ||
289 | |||
290 | cs461x_pokeBA0(BA0_JSIO, 0xFF); // ? | ||
291 | cs461x_pokeBA0(BA0_JSCTL, JSCTL_SP_MEDIUM_SLOW); | ||
292 | |||
293 | gameport_register_port(port); | ||
294 | |||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | static void __devexit cs461x_pci_remove(struct pci_dev *pdev) | ||
299 | { | ||
300 | cs461x_free(pdev); | ||
301 | } | ||
302 | |||
303 | static struct pci_driver cs461x_pci_driver = { | ||
304 | .name = "CS461x_gameport", | ||
305 | .id_table = cs461x_pci_tbl, | ||
306 | .probe = cs461x_pci_probe, | ||
307 | .remove = __devexit_p(cs461x_pci_remove), | ||
308 | }; | ||
309 | |||
310 | static int __init cs461x_init(void) | ||
311 | { | ||
312 | return pci_register_driver(&cs461x_pci_driver); | ||
313 | } | ||
314 | |||
315 | static void __exit cs461x_exit(void) | ||
316 | { | ||
317 | pci_unregister_driver(&cs461x_pci_driver); | ||
318 | } | ||
319 | |||
320 | module_init(cs461x_init); | ||
321 | module_exit(cs461x_exit); | ||
322 | |||
diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c index 7c5c6318eeb9..1ab5f2dc8a2a 100644 --- a/drivers/input/gameport/ns558.c +++ b/drivers/input/gameport/ns558.c | |||
@@ -258,18 +258,18 @@ static int __init ns558_init(void) | |||
258 | { | 258 | { |
259 | int i = 0; | 259 | int i = 0; |
260 | 260 | ||
261 | if (pnp_register_driver(&ns558_pnp_driver) >= 0) | ||
262 | pnp_registered = 1; | ||
263 | |||
261 | /* | 264 | /* |
262 | * Probe ISA ports first so that PnP gets to choose free port addresses | 265 | * Probe ISA ports after PnP, so that PnP ports that are already |
263 | * not occupied by the ISA ports. | 266 | * enabled get detected as PnP. This may be suboptimal in multi-device |
267 | * configurations, but saves hassle with simple setups. | ||
264 | */ | 268 | */ |
265 | 269 | ||
266 | while (ns558_isa_portlist[i]) | 270 | while (ns558_isa_portlist[i]) |
267 | ns558_isa_probe(ns558_isa_portlist[i++]); | 271 | ns558_isa_probe(ns558_isa_portlist[i++]); |
268 | 272 | ||
269 | if (pnp_register_driver(&ns558_pnp_driver) >= 0) | ||
270 | pnp_registered = 1; | ||
271 | |||
272 | |||
273 | return (list_empty(&ns558_list) && !pnp_registered) ? -ENODEV : 0; | 273 | return (list_empty(&ns558_list) && !pnp_registered) ? -ENODEV : 0; |
274 | } | 274 | } |
275 | 275 | ||
diff --git a/drivers/input/gameport/vortex.c b/drivers/input/gameport/vortex.c deleted file mode 100644 index 36b0309c8bf6..000000000000 --- a/drivers/input/gameport/vortex.c +++ /dev/null | |||
@@ -1,186 +0,0 @@ | |||
1 | /* | ||
2 | * $Id: vortex.c,v 1.5 2002/07/01 15:39:30 vojtech Exp $ | ||
3 | * | ||
4 | * Copyright (c) 2000-2001 Vojtech Pavlik | ||
5 | * | ||
6 | * Based on the work of: | ||
7 | * Raymond Ingles | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * Trident 4DWave and Aureal Vortex gameport driver for Linux | ||
12 | */ | ||
13 | |||
14 | /* | ||
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or | ||
18 | * (at your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
28 | * | ||
29 | * Should you need to contact me, the author, you can do so either by | ||
30 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: | ||
31 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | ||
32 | */ | ||
33 | |||
34 | #include <asm/io.h> | ||
35 | #include <linux/delay.h> | ||
36 | #include <linux/errno.h> | ||
37 | #include <linux/ioport.h> | ||
38 | #include <linux/kernel.h> | ||
39 | #include <linux/module.h> | ||
40 | #include <linux/pci.h> | ||
41 | #include <linux/init.h> | ||
42 | #include <linux/slab.h> | ||
43 | #include <linux/delay.h> | ||
44 | #include <linux/gameport.h> | ||
45 | |||
46 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | ||
47 | MODULE_DESCRIPTION("Aureal Vortex and Vortex2 gameport driver"); | ||
48 | MODULE_LICENSE("GPL"); | ||
49 | |||
50 | #define VORTEX_GCR 0x0c /* Gameport control register */ | ||
51 | #define VORTEX_LEG 0x08 /* Legacy port location */ | ||
52 | #define VORTEX_AXD 0x10 /* Axes start */ | ||
53 | #define VORTEX_DATA_WAIT 20 /* 20 ms */ | ||
54 | |||
55 | struct vortex { | ||
56 | struct gameport *gameport; | ||
57 | struct pci_dev *dev; | ||
58 | unsigned char __iomem *base; | ||
59 | unsigned char __iomem *io; | ||
60 | }; | ||
61 | |||
62 | static unsigned char vortex_read(struct gameport *gameport) | ||
63 | { | ||
64 | struct vortex *vortex = gameport->port_data; | ||
65 | return readb(vortex->io + VORTEX_LEG); | ||
66 | } | ||
67 | |||
68 | static void vortex_trigger(struct gameport *gameport) | ||
69 | { | ||
70 | struct vortex *vortex = gameport->port_data; | ||
71 | writeb(0xff, vortex->io + VORTEX_LEG); | ||
72 | } | ||
73 | |||
74 | static int vortex_cooked_read(struct gameport *gameport, int *axes, int *buttons) | ||
75 | { | ||
76 | struct vortex *vortex = gameport->port_data; | ||
77 | int i; | ||
78 | |||
79 | *buttons = (~readb(vortex->base + VORTEX_LEG) >> 4) & 0xf; | ||
80 | |||
81 | for (i = 0; i < 4; i++) { | ||
82 | axes[i] = readw(vortex->io + VORTEX_AXD + i * sizeof(u32)); | ||
83 | if (axes[i] == 0x1fff) axes[i] = -1; | ||
84 | } | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static int vortex_open(struct gameport *gameport, int mode) | ||
90 | { | ||
91 | struct vortex *vortex = gameport->port_data; | ||
92 | |||
93 | switch (mode) { | ||
94 | case GAMEPORT_MODE_COOKED: | ||
95 | writeb(0x40, vortex->io + VORTEX_GCR); | ||
96 | msleep(VORTEX_DATA_WAIT); | ||
97 | return 0; | ||
98 | case GAMEPORT_MODE_RAW: | ||
99 | writeb(0x00, vortex->io + VORTEX_GCR); | ||
100 | return 0; | ||
101 | default: | ||
102 | return -1; | ||
103 | } | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static int __devinit vortex_probe(struct pci_dev *dev, const struct pci_device_id *id) | ||
109 | { | ||
110 | struct vortex *vortex; | ||
111 | struct gameport *port; | ||
112 | int i; | ||
113 | |||
114 | vortex = kcalloc(1, sizeof(struct vortex), GFP_KERNEL); | ||
115 | port = gameport_allocate_port(); | ||
116 | if (!vortex || !port) { | ||
117 | printk(KERN_ERR "vortex: Memory allocation failed.\n"); | ||
118 | kfree(vortex); | ||
119 | gameport_free_port(port); | ||
120 | return -ENOMEM; | ||
121 | } | ||
122 | |||
123 | for (i = 0; i < 6; i++) | ||
124 | if (~pci_resource_flags(dev, i) & IORESOURCE_IO) | ||
125 | break; | ||
126 | |||
127 | pci_enable_device(dev); | ||
128 | |||
129 | vortex->dev = dev; | ||
130 | vortex->gameport = port; | ||
131 | vortex->base = ioremap(pci_resource_start(vortex->dev, i), | ||
132 | pci_resource_len(vortex->dev, i)); | ||
133 | vortex->io = vortex->base + id->driver_data; | ||
134 | |||
135 | pci_set_drvdata(dev, vortex); | ||
136 | |||
137 | port->port_data = vortex; | ||
138 | port->fuzz = 64; | ||
139 | |||
140 | gameport_set_name(port, "AU88x0"); | ||
141 | gameport_set_phys(port, "pci%s/gameport0", pci_name(dev)); | ||
142 | port->dev.parent = &dev->dev; | ||
143 | port->read = vortex_read; | ||
144 | port->trigger = vortex_trigger; | ||
145 | port->cooked_read = vortex_cooked_read; | ||
146 | port->open = vortex_open; | ||
147 | |||
148 | gameport_register_port(port); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static void __devexit vortex_remove(struct pci_dev *dev) | ||
154 | { | ||
155 | struct vortex *vortex = pci_get_drvdata(dev); | ||
156 | |||
157 | gameport_unregister_port(vortex->gameport); | ||
158 | iounmap(vortex->base); | ||
159 | kfree(vortex); | ||
160 | } | ||
161 | |||
162 | static struct pci_device_id vortex_id_table[] = { | ||
163 | { 0x12eb, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x11000 }, | ||
164 | { 0x12eb, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x28800 }, | ||
165 | { 0 } | ||
166 | }; | ||
167 | |||
168 | static struct pci_driver vortex_driver = { | ||
169 | .name = "vortex_gameport", | ||
170 | .id_table = vortex_id_table, | ||
171 | .probe = vortex_probe, | ||
172 | .remove = __devexit_p(vortex_remove), | ||
173 | }; | ||
174 | |||
175 | static int __init vortex_init(void) | ||
176 | { | ||
177 | return pci_register_driver(&vortex_driver); | ||
178 | } | ||
179 | |||
180 | static void __exit vortex_exit(void) | ||
181 | { | ||
182 | pci_unregister_driver(&vortex_driver); | ||
183 | } | ||
184 | |||
185 | module_init(vortex_init); | ||
186 | module_exit(vortex_exit); | ||
diff --git a/drivers/input/input.c b/drivers/input/input.c index 83c77c990dda..7c4b4d37b3e6 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -219,10 +219,24 @@ void input_release_device(struct input_handle *handle) | |||
219 | 219 | ||
220 | int input_open_device(struct input_handle *handle) | 220 | int input_open_device(struct input_handle *handle) |
221 | { | 221 | { |
222 | struct input_dev *dev = handle->dev; | ||
223 | int err; | ||
224 | |||
225 | err = down_interruptible(&dev->sem); | ||
226 | if (err) | ||
227 | return err; | ||
228 | |||
222 | handle->open++; | 229 | handle->open++; |
223 | if (handle->dev->open) | 230 | |
224 | return handle->dev->open(handle->dev); | 231 | if (!dev->users++ && dev->open) |
225 | return 0; | 232 | err = dev->open(dev); |
233 | |||
234 | if (err) | ||
235 | handle->open--; | ||
236 | |||
237 | up(&dev->sem); | ||
238 | |||
239 | return err; | ||
226 | } | 240 | } |
227 | 241 | ||
228 | int input_flush_device(struct input_handle* handle, struct file* file) | 242 | int input_flush_device(struct input_handle* handle, struct file* file) |
@@ -235,10 +249,17 @@ int input_flush_device(struct input_handle* handle, struct file* file) | |||
235 | 249 | ||
236 | void input_close_device(struct input_handle *handle) | 250 | void input_close_device(struct input_handle *handle) |
237 | { | 251 | { |
252 | struct input_dev *dev = handle->dev; | ||
253 | |||
238 | input_release_device(handle); | 254 | input_release_device(handle); |
239 | if (handle->dev->close) | 255 | |
240 | handle->dev->close(handle->dev); | 256 | down(&dev->sem); |
257 | |||
258 | if (!--dev->users && dev->close) | ||
259 | dev->close(dev); | ||
241 | handle->open--; | 260 | handle->open--; |
261 | |||
262 | up(&dev->sem); | ||
242 | } | 263 | } |
243 | 264 | ||
244 | static void input_link_handle(struct input_handle *handle) | 265 | static void input_link_handle(struct input_handle *handle) |
@@ -415,6 +436,8 @@ void input_register_device(struct input_dev *dev) | |||
415 | 436 | ||
416 | set_bit(EV_SYN, dev->evbit); | 437 | set_bit(EV_SYN, dev->evbit); |
417 | 438 | ||
439 | init_MUTEX(&dev->sem); | ||
440 | |||
418 | /* | 441 | /* |
419 | * If delay and period are pre-set by the driver, then autorepeating | 442 | * If delay and period are pre-set by the driver, then autorepeating |
420 | * is handled by the driver itself and we don't do it in input.c. | 443 | * is handled by the driver itself and we don't do it in input.c. |
@@ -674,6 +697,8 @@ static int input_handlers_read(char *buf, char **start, off_t pos, int count, in | |||
674 | return (count > cnt) ? cnt : count; | 697 | return (count > cnt) ? cnt : count; |
675 | } | 698 | } |
676 | 699 | ||
700 | static struct file_operations input_fileops; | ||
701 | |||
677 | static int __init input_proc_init(void) | 702 | static int __init input_proc_init(void) |
678 | { | 703 | { |
679 | struct proc_dir_entry *entry; | 704 | struct proc_dir_entry *entry; |
@@ -688,6 +713,8 @@ static int __init input_proc_init(void) | |||
688 | return -ENOMEM; | 713 | return -ENOMEM; |
689 | } | 714 | } |
690 | entry->owner = THIS_MODULE; | 715 | entry->owner = THIS_MODULE; |
716 | input_fileops = *entry->proc_fops; | ||
717 | entry->proc_fops = &input_fileops; | ||
691 | entry->proc_fops->poll = input_devices_poll; | 718 | entry->proc_fops->poll = input_devices_poll; |
692 | entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL); | 719 | entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL); |
693 | if (entry == NULL) { | 720 | if (entry == NULL) { |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 39775fc380c7..ff8e1bbd0e13 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -285,48 +285,33 @@ static unsigned int joydev_poll(struct file *file, poll_table *wait) | |||
285 | (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); | 285 | (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); |
286 | } | 286 | } |
287 | 287 | ||
288 | static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 288 | static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp) |
289 | { | 289 | { |
290 | struct joydev_list *list = file->private_data; | ||
291 | struct joydev *joydev = list->joydev; | ||
292 | struct input_dev *dev = joydev->handle.dev; | 290 | struct input_dev *dev = joydev->handle.dev; |
293 | void __user *argp = (void __user *)arg; | ||
294 | int i, j; | 291 | int i, j; |
295 | 292 | ||
296 | if (!joydev->exist) return -ENODEV; | ||
297 | |||
298 | switch (cmd) { | 293 | switch (cmd) { |
299 | 294 | ||
300 | case JS_SET_CAL: | 295 | case JS_SET_CAL: |
301 | return copy_from_user(&joydev->glue.JS_CORR, argp, | 296 | return copy_from_user(&joydev->glue.JS_CORR, argp, |
302 | sizeof(struct JS_DATA_TYPE)) ? -EFAULT : 0; | 297 | sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; |
303 | case JS_GET_CAL: | 298 | case JS_GET_CAL: |
304 | return copy_to_user(argp, &joydev->glue.JS_CORR, | 299 | return copy_to_user(argp, &joydev->glue.JS_CORR, |
305 | sizeof(struct JS_DATA_TYPE)) ? -EFAULT : 0; | 300 | sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; |
306 | case JS_SET_TIMEOUT: | 301 | case JS_SET_TIMEOUT: |
307 | return get_user(joydev->glue.JS_TIMEOUT, (int __user *) arg); | 302 | return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); |
308 | case JS_GET_TIMEOUT: | 303 | case JS_GET_TIMEOUT: |
309 | return put_user(joydev->glue.JS_TIMEOUT, (int __user *) arg); | 304 | return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); |
310 | case JS_SET_TIMELIMIT: | ||
311 | return get_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); | ||
312 | case JS_GET_TIMELIMIT: | ||
313 | return put_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); | ||
314 | case JS_SET_ALL: | ||
315 | return copy_from_user(&joydev->glue, argp, | ||
316 | sizeof(struct JS_DATA_SAVE_TYPE)) ? -EFAULT : 0; | ||
317 | case JS_GET_ALL: | ||
318 | return copy_to_user(argp, &joydev->glue, | ||
319 | sizeof(struct JS_DATA_SAVE_TYPE)) ? -EFAULT : 0; | ||
320 | 305 | ||
321 | case JSIOCGVERSION: | 306 | case JSIOCGVERSION: |
322 | return put_user(JS_VERSION, (__u32 __user *) arg); | 307 | return put_user(JS_VERSION, (__u32 __user *) argp); |
323 | case JSIOCGAXES: | 308 | case JSIOCGAXES: |
324 | return put_user(joydev->nabs, (__u8 __user *) arg); | 309 | return put_user(joydev->nabs, (__u8 __user *) argp); |
325 | case JSIOCGBUTTONS: | 310 | case JSIOCGBUTTONS: |
326 | return put_user(joydev->nkey, (__u8 __user *) arg); | 311 | return put_user(joydev->nkey, (__u8 __user *) argp); |
327 | case JSIOCSCORR: | 312 | case JSIOCSCORR: |
328 | if (copy_from_user(joydev->corr, argp, | 313 | if (copy_from_user(joydev->corr, argp, |
329 | sizeof(struct js_corr) * joydev->nabs)) | 314 | sizeof(joydev->corr[0]) * joydev->nabs)) |
330 | return -EFAULT; | 315 | return -EFAULT; |
331 | for (i = 0; i < joydev->nabs; i++) { | 316 | for (i = 0; i < joydev->nabs; i++) { |
332 | j = joydev->abspam[i]; | 317 | j = joydev->abspam[i]; |
@@ -335,7 +320,7 @@ static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
335 | return 0; | 320 | return 0; |
336 | case JSIOCGCORR: | 321 | case JSIOCGCORR: |
337 | return copy_to_user(argp, joydev->corr, | 322 | return copy_to_user(argp, joydev->corr, |
338 | sizeof(struct js_corr) * joydev->nabs) ? -EFAULT : 0; | 323 | sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0; |
339 | case JSIOCSAXMAP: | 324 | case JSIOCSAXMAP: |
340 | if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1))) | 325 | if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1))) |
341 | return -EFAULT; | 326 | return -EFAULT; |
@@ -371,6 +356,84 @@ static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
371 | return -EINVAL; | 356 | return -EINVAL; |
372 | } | 357 | } |
373 | 358 | ||
359 | #ifdef CONFIG_COMPAT | ||
360 | static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
361 | { | ||
362 | struct joydev_list *list = file->private_data; | ||
363 | struct joydev *joydev = list->joydev; | ||
364 | void __user *argp = (void __user *)arg; | ||
365 | s32 tmp32; | ||
366 | struct JS_DATA_SAVE_TYPE_32 ds32; | ||
367 | int err; | ||
368 | |||
369 | if (!joydev->exist) return -ENODEV; | ||
370 | switch(cmd) { | ||
371 | case JS_SET_TIMELIMIT: | ||
372 | err = get_user(tmp32, (s32 __user *) arg); | ||
373 | if (err == 0) | ||
374 | joydev->glue.JS_TIMELIMIT = tmp32; | ||
375 | break; | ||
376 | case JS_GET_TIMELIMIT: | ||
377 | tmp32 = joydev->glue.JS_TIMELIMIT; | ||
378 | err = put_user(tmp32, (s32 __user *) arg); | ||
379 | break; | ||
380 | |||
381 | case JS_SET_ALL: | ||
382 | err = copy_from_user(&ds32, argp, | ||
383 | sizeof(ds32)) ? -EFAULT : 0; | ||
384 | if (err == 0) { | ||
385 | joydev->glue.JS_TIMEOUT = ds32.JS_TIMEOUT; | ||
386 | joydev->glue.BUSY = ds32.BUSY; | ||
387 | joydev->glue.JS_EXPIRETIME = ds32.JS_EXPIRETIME; | ||
388 | joydev->glue.JS_TIMELIMIT = ds32.JS_TIMELIMIT; | ||
389 | joydev->glue.JS_SAVE = ds32.JS_SAVE; | ||
390 | joydev->glue.JS_CORR = ds32.JS_CORR; | ||
391 | } | ||
392 | break; | ||
393 | |||
394 | case JS_GET_ALL: | ||
395 | ds32.JS_TIMEOUT = joydev->glue.JS_TIMEOUT; | ||
396 | ds32.BUSY = joydev->glue.BUSY; | ||
397 | ds32.JS_EXPIRETIME = joydev->glue.JS_EXPIRETIME; | ||
398 | ds32.JS_TIMELIMIT = joydev->glue.JS_TIMELIMIT; | ||
399 | ds32.JS_SAVE = joydev->glue.JS_SAVE; | ||
400 | ds32.JS_CORR = joydev->glue.JS_CORR; | ||
401 | |||
402 | err = copy_to_user(argp, &ds32, | ||
403 | sizeof(ds32)) ? -EFAULT : 0; | ||
404 | break; | ||
405 | |||
406 | default: | ||
407 | err = joydev_ioctl_common(joydev, cmd, argp); | ||
408 | } | ||
409 | return err; | ||
410 | } | ||
411 | #endif /* CONFIG_COMPAT */ | ||
412 | |||
413 | static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | ||
414 | { | ||
415 | struct joydev_list *list = file->private_data; | ||
416 | struct joydev *joydev = list->joydev; | ||
417 | void __user *argp = (void __user *)arg; | ||
418 | |||
419 | if (!joydev->exist) return -ENODEV; | ||
420 | |||
421 | switch(cmd) { | ||
422 | case JS_SET_TIMELIMIT: | ||
423 | return get_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); | ||
424 | case JS_GET_TIMELIMIT: | ||
425 | return put_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); | ||
426 | case JS_SET_ALL: | ||
427 | return copy_from_user(&joydev->glue, argp, | ||
428 | sizeof(joydev->glue)) ? -EFAULT : 0; | ||
429 | case JS_GET_ALL: | ||
430 | return copy_to_user(argp, &joydev->glue, | ||
431 | sizeof(joydev->glue)) ? -EFAULT : 0; | ||
432 | default: | ||
433 | return joydev_ioctl_common(joydev, cmd, argp); | ||
434 | } | ||
435 | } | ||
436 | |||
374 | static struct file_operations joydev_fops = { | 437 | static struct file_operations joydev_fops = { |
375 | .owner = THIS_MODULE, | 438 | .owner = THIS_MODULE, |
376 | .read = joydev_read, | 439 | .read = joydev_read, |
@@ -379,6 +442,9 @@ static struct file_operations joydev_fops = { | |||
379 | .open = joydev_open, | 442 | .open = joydev_open, |
380 | .release = joydev_release, | 443 | .release = joydev_release, |
381 | .ioctl = joydev_ioctl, | 444 | .ioctl = joydev_ioctl, |
445 | #ifdef CONFIG_COMPAT | ||
446 | .compat_ioctl = joydev_compat_ioctl, | ||
447 | #endif | ||
382 | .fasync = joydev_fasync, | 448 | .fasync = joydev_fasync, |
383 | }; | 449 | }; |
384 | 450 | ||
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index ad39fe4bf35f..bf34f75b9467 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c | |||
@@ -185,7 +185,7 @@ static void a3d_poll(struct gameport *gameport) | |||
185 | a3d->reads++; | 185 | a3d->reads++; |
186 | if (a3d_read_packet(a3d->gameport, a3d->length, data) != a3d->length || | 186 | if (a3d_read_packet(a3d->gameport, a3d->length, data) != a3d->length || |
187 | data[0] != a3d->mode || a3d_csum(data, a3d->length)) | 187 | data[0] != a3d->mode || a3d_csum(data, a3d->length)) |
188 | a3d->bads++; | 188 | a3d->bads++; |
189 | else | 189 | else |
190 | a3d_read(a3d, data); | 190 | a3d_read(a3d, data); |
191 | } | 191 | } |
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c index 83f6dafc1716..265962956c63 100644 --- a/drivers/input/joystick/adi.c +++ b/drivers/input/joystick/adi.c | |||
@@ -82,7 +82,7 @@ static char adi_cm2_abs[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; | |||
82 | static char adi_wmf_abs[] = { ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y }; | 82 | static char adi_wmf_abs[] = { ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y }; |
83 | 83 | ||
84 | static short adi_wmgpe_key[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE, BTN_SELECT }; | 84 | static short adi_wmgpe_key[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE, BTN_SELECT }; |
85 | static short adi_wmi_key[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_EXTRA }; | 85 | static short adi_wmi_key[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_EXTRA }; |
86 | static short adi_wmed3d_key[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2 }; | 86 | static short adi_wmed3d_key[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2 }; |
87 | static short adi_cm2_key[] = { BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 }; | 87 | static short adi_cm2_key[] = { BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 }; |
88 | 88 | ||
@@ -183,7 +183,7 @@ static void adi_move_bits(struct adi_port *port, int length) | |||
183 | int i; | 183 | int i; |
184 | struct adi *adi = port->adi; | 184 | struct adi *adi = port->adi; |
185 | 185 | ||
186 | adi[0].idx = adi[1].idx = 0; | 186 | adi[0].idx = adi[1].idx = 0; |
187 | 187 | ||
188 | if (adi[0].ret <= 0 || adi[1].ret <= 0) return; | 188 | if (adi[0].ret <= 0 || adi[1].ret <= 0) return; |
189 | if (adi[0].data[0] & 0x20 || ~adi[1].data[0] & 0x20) return; | 189 | if (adi[0].data[0] & 0x20 || ~adi[1].data[0] & 0x20) return; |
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c index cf36ca9b92f3..033456bb9fe0 100644 --- a/drivers/input/joystick/amijoy.c +++ b/drivers/input/joystick/amijoy.c | |||
@@ -51,7 +51,8 @@ MODULE_PARM_DESC(map, "Map of attached joysticks in form of <a>,<b> (default is | |||
51 | 51 | ||
52 | __obsolete_setup("amijoy="); | 52 | __obsolete_setup("amijoy="); |
53 | 53 | ||
54 | static int amijoy_used[2] = { 0, 0 }; | 54 | static int amijoy_used; |
55 | static DECLARE_MUTEX(amijoy_sem); | ||
55 | static struct input_dev amijoy_dev[2]; | 56 | static struct input_dev amijoy_dev[2]; |
56 | static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; | 57 | static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; |
57 | 58 | ||
@@ -84,26 +85,30 @@ static irqreturn_t amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp) | |||
84 | 85 | ||
85 | static int amijoy_open(struct input_dev *dev) | 86 | static int amijoy_open(struct input_dev *dev) |
86 | { | 87 | { |
87 | int *used = dev->private; | 88 | int err; |
88 | 89 | ||
89 | if ((*used)++) | 90 | err = down_interruptible(&amijoy_sem); |
90 | return 0; | 91 | if (err) |
92 | return err; | ||
91 | 93 | ||
92 | if (request_irq(IRQ_AMIGA_VERTB, amijoy_interrupt, 0, "amijoy", amijoy_interrupt)) { | 94 | if (!amijoy_used && request_irq(IRQ_AMIGA_VERTB, amijoy_interrupt, 0, "amijoy", amijoy_interrupt)) { |
93 | (*used)--; | ||
94 | printk(KERN_ERR "amijoy.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); | 95 | printk(KERN_ERR "amijoy.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); |
95 | return -EBUSY; | 96 | err = -EBUSY; |
97 | goto out; | ||
96 | } | 98 | } |
97 | 99 | ||
98 | return 0; | 100 | amijoy_used++; |
101 | out: | ||
102 | up(&amijoy_sem); | ||
103 | return err; | ||
99 | } | 104 | } |
100 | 105 | ||
101 | static void amijoy_close(struct input_dev *dev) | 106 | static void amijoy_close(struct input_dev *dev) |
102 | { | 107 | { |
103 | int *used = dev->private; | 108 | down(&amijoysem); |
104 | 109 | if (!--amijoy_used) | |
105 | if (!--(*used)) | ||
106 | free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt); | 110 | free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt); |
111 | up(&amijoy_sem); | ||
107 | } | 112 | } |
108 | 113 | ||
109 | static int __init amijoy_init(void) | 114 | static int __init amijoy_init(void) |
@@ -138,8 +143,6 @@ static int __init amijoy_init(void) | |||
138 | amijoy_dev[i].id.product = 0x0003; | 143 | amijoy_dev[i].id.product = 0x0003; |
139 | amijoy_dev[i].id.version = 0x0100; | 144 | amijoy_dev[i].id.version = 0x0100; |
140 | 145 | ||
141 | amijoy_dev[i].private = amijoy_used + i; | ||
142 | |||
143 | input_register_device(amijoy_dev + i); | 146 | input_register_device(amijoy_dev + i); |
144 | printk(KERN_INFO "input: %s at joy%ddat\n", amijoy_name, i); | 147 | printk(KERN_INFO "input: %s at joy%ddat\n", amijoy_name, i); |
145 | } | 148 | } |
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index cfdd3acf06a1..fbd3eed07f90 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c | |||
@@ -87,7 +87,7 @@ __obsolete_setup("db9_3="); | |||
87 | #define DB9_NORMAL 0x0a | 87 | #define DB9_NORMAL 0x0a |
88 | #define DB9_NOSELECT 0x08 | 88 | #define DB9_NOSELECT 0x08 |
89 | 89 | ||
90 | #define DB9_MAX_DEVICES 2 | 90 | #define DB9_MAX_DEVICES 2 |
91 | 91 | ||
92 | #define DB9_GENESIS6_DELAY 14 | 92 | #define DB9_GENESIS6_DELAY 14 |
93 | #define DB9_REFRESH_TIME HZ/100 | 93 | #define DB9_REFRESH_TIME HZ/100 |
@@ -98,6 +98,7 @@ struct db9 { | |||
98 | struct pardevice *pd; | 98 | struct pardevice *pd; |
99 | int mode; | 99 | int mode; |
100 | int used; | 100 | int used; |
101 | struct semaphore sem; | ||
101 | char phys[2][32]; | 102 | char phys[2][32]; |
102 | }; | 103 | }; |
103 | 104 | ||
@@ -503,6 +504,11 @@ static int db9_open(struct input_dev *dev) | |||
503 | { | 504 | { |
504 | struct db9 *db9 = dev->private; | 505 | struct db9 *db9 = dev->private; |
505 | struct parport *port = db9->pd->port; | 506 | struct parport *port = db9->pd->port; |
507 | int err; | ||
508 | |||
509 | err = down_interruptible(&db9->sem); | ||
510 | if (err) | ||
511 | return err; | ||
506 | 512 | ||
507 | if (!db9->used++) { | 513 | if (!db9->used++) { |
508 | parport_claim(db9->pd); | 514 | parport_claim(db9->pd); |
@@ -514,6 +520,7 @@ static int db9_open(struct input_dev *dev) | |||
514 | mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME); | 520 | mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME); |
515 | } | 521 | } |
516 | 522 | ||
523 | up(&db9->sem); | ||
517 | return 0; | 524 | return 0; |
518 | } | 525 | } |
519 | 526 | ||
@@ -522,12 +529,14 @@ static void db9_close(struct input_dev *dev) | |||
522 | struct db9 *db9 = dev->private; | 529 | struct db9 *db9 = dev->private; |
523 | struct parport *port = db9->pd->port; | 530 | struct parport *port = db9->pd->port; |
524 | 531 | ||
532 | down(&db9->sem); | ||
525 | if (!--db9->used) { | 533 | if (!--db9->used) { |
526 | del_timer(&db9->timer); | 534 | del_timer_sync(&db9->timer); |
527 | parport_write_control(port, 0x00); | 535 | parport_write_control(port, 0x00); |
528 | parport_data_forward(port); | 536 | parport_data_forward(port); |
529 | parport_release(db9->pd); | 537 | parport_release(db9->pd); |
530 | } | 538 | } |
539 | up(&db9->sem); | ||
531 | } | 540 | } |
532 | 541 | ||
533 | static struct db9 __init *db9_probe(int *config, int nargs) | 542 | static struct db9 __init *db9_probe(int *config, int nargs) |
@@ -563,12 +572,12 @@ static struct db9 __init *db9_probe(int *config, int nargs) | |||
563 | } | 572 | } |
564 | } | 573 | } |
565 | 574 | ||
566 | if (!(db9 = kmalloc(sizeof(struct db9), GFP_KERNEL))) { | 575 | if (!(db9 = kcalloc(1, sizeof(struct db9), GFP_KERNEL))) { |
567 | parport_put_port(pp); | 576 | parport_put_port(pp); |
568 | return NULL; | 577 | return NULL; |
569 | } | 578 | } |
570 | memset(db9, 0, sizeof(struct db9)); | ||
571 | 579 | ||
580 | init_MUTEX(&db9->sem); | ||
572 | db9->mode = config[1]; | 581 | db9->mode = config[1]; |
573 | init_timer(&db9->timer); | 582 | init_timer(&db9->timer); |
574 | db9->timer.data = (long) db9; | 583 | db9->timer.data = (long) db9; |
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index 8732f52bdd08..95bbdd302aad 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c | |||
@@ -1,12 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | * NES, SNES, N64, MultiSystem, PSX gamepad driver for Linux | 2 | * NES, SNES, N64, MultiSystem, PSX gamepad driver for Linux |
3 | * | 3 | * |
4 | * Copyright (c) 1999-2004 Vojtech Pavlik <vojtech@suse.cz> | 4 | * Copyright (c) 1999-2004 Vojtech Pavlik <vojtech@suse.cz> |
5 | * Copyright (c) 2004 Peter Nelson <rufus-kernel@hackish.org> | 5 | * Copyright (c) 2004 Peter Nelson <rufus-kernel@hackish.org> |
6 | * | 6 | * |
7 | * Based on the work of: | 7 | * Based on the work of: |
8 | * Andree Borrmann John Dahlstrom | 8 | * Andree Borrmann John Dahlstrom |
9 | * David Kuder Nathan Hand | 9 | * David Kuder Nathan Hand |
10 | */ | 10 | */ |
11 | 11 | ||
12 | /* | 12 | /* |
@@ -81,6 +81,7 @@ struct gc { | |||
81 | struct timer_list timer; | 81 | struct timer_list timer; |
82 | unsigned char pads[GC_MAX + 1]; | 82 | unsigned char pads[GC_MAX + 1]; |
83 | int used; | 83 | int used; |
84 | struct semaphore sem; | ||
84 | char phys[5][32]; | 85 | char phys[5][32]; |
85 | }; | 86 | }; |
86 | 87 | ||
@@ -433,7 +434,7 @@ static void gc_timer(unsigned long private) | |||
433 | gc_psx_read_packet(gc, data_psx, data); | 434 | gc_psx_read_packet(gc, data_psx, data); |
434 | 435 | ||
435 | for (i = 0; i < 5; i++) { | 436 | for (i = 0; i < 5; i++) { |
436 | switch (data[i]) { | 437 | switch (data[i]) { |
437 | 438 | ||
438 | case GC_PSX_RUMBLE: | 439 | case GC_PSX_RUMBLE: |
439 | 440 | ||
@@ -503,22 +504,33 @@ static void gc_timer(unsigned long private) | |||
503 | static int gc_open(struct input_dev *dev) | 504 | static int gc_open(struct input_dev *dev) |
504 | { | 505 | { |
505 | struct gc *gc = dev->private; | 506 | struct gc *gc = dev->private; |
507 | int err; | ||
508 | |||
509 | err = down_interruptible(&gc->sem); | ||
510 | if (err) | ||
511 | return err; | ||
512 | |||
506 | if (!gc->used++) { | 513 | if (!gc->used++) { |
507 | parport_claim(gc->pd); | 514 | parport_claim(gc->pd); |
508 | parport_write_control(gc->pd->port, 0x04); | 515 | parport_write_control(gc->pd->port, 0x04); |
509 | mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); | 516 | mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); |
510 | } | 517 | } |
518 | |||
519 | up(&gc->sem); | ||
511 | return 0; | 520 | return 0; |
512 | } | 521 | } |
513 | 522 | ||
514 | static void gc_close(struct input_dev *dev) | 523 | static void gc_close(struct input_dev *dev) |
515 | { | 524 | { |
516 | struct gc *gc = dev->private; | 525 | struct gc *gc = dev->private; |
526 | |||
527 | down(&gc->sem); | ||
517 | if (!--gc->used) { | 528 | if (!--gc->used) { |
518 | del_timer(&gc->timer); | 529 | del_timer_sync(&gc->timer); |
519 | parport_write_control(gc->pd->port, 0x00); | 530 | parport_write_control(gc->pd->port, 0x00); |
520 | parport_release(gc->pd); | 531 | parport_release(gc->pd); |
521 | } | 532 | } |
533 | up(&gc->sem); | ||
522 | } | 534 | } |
523 | 535 | ||
524 | static struct gc __init *gc_probe(int *config, int nargs) | 536 | static struct gc __init *gc_probe(int *config, int nargs) |
@@ -542,11 +554,12 @@ static struct gc __init *gc_probe(int *config, int nargs) | |||
542 | return NULL; | 554 | return NULL; |
543 | } | 555 | } |
544 | 556 | ||
545 | if (!(gc = kmalloc(sizeof(struct gc), GFP_KERNEL))) { | 557 | if (!(gc = kcalloc(1, sizeof(struct gc), GFP_KERNEL))) { |
546 | parport_put_port(pp); | 558 | parport_put_port(pp); |
547 | return NULL; | 559 | return NULL; |
548 | } | 560 | } |
549 | memset(gc, 0, sizeof(struct gc)); | 561 | |
562 | init_MUTEX(&gc->sem); | ||
550 | 563 | ||
551 | gc->pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); | 564 | gc->pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); |
552 | 565 | ||
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c index ad13f09a4e71..7d969420066c 100644 --- a/drivers/input/joystick/gf2k.c +++ b/drivers/input/joystick/gf2k.c | |||
@@ -329,7 +329,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
329 | 329 | ||
330 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) { | 330 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) { |
331 | gf2k->dev.absmax[gf2k_abs[i]] = (i < 2) ? gf2k->dev.abs[gf2k_abs[i]] * 2 - 32 : | 331 | gf2k->dev.absmax[gf2k_abs[i]] = (i < 2) ? gf2k->dev.abs[gf2k_abs[i]] * 2 - 32 : |
332 | gf2k->dev.abs[gf2k_abs[0]] + gf2k->dev.abs[gf2k_abs[1]] - 32; | 332 | gf2k->dev.abs[gf2k_abs[0]] + gf2k->dev.abs[gf2k_abs[1]] - 32; |
333 | gf2k->dev.absmin[gf2k_abs[i]] = 32; | 333 | gf2k->dev.absmin[gf2k_abs[i]] = 32; |
334 | gf2k->dev.absfuzz[gf2k_abs[i]] = 8; | 334 | gf2k->dev.absfuzz[gf2k_abs[i]] = 8; |
335 | gf2k->dev.absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0; | 335 | gf2k->dev.absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0; |
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c index 42e5005d621f..0da7bd133ccf 100644 --- a/drivers/input/joystick/grip_mp.c +++ b/drivers/input/joystick/grip_mp.c | |||
@@ -171,7 +171,7 @@ static int mp_io(struct gameport* gameport, int sendflags, int sendcode, u32 *pa | |||
171 | *packet = 0; | 171 | *packet = 0; |
172 | raw_data = gameport_read(gameport); | 172 | raw_data = gameport_read(gameport); |
173 | if (raw_data & 1) | 173 | if (raw_data & 1) |
174 | return IO_RETRY; | 174 | return IO_RETRY; |
175 | 175 | ||
176 | for (i = 0; i < 64; i++) { | 176 | for (i = 0; i < 64; i++) { |
177 | raw_data = gameport_read(gameport); | 177 | raw_data = gameport_read(gameport); |
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index 028f3513629a..e31b7b93fde2 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c | |||
@@ -78,6 +78,7 @@ static struct iforce_device iforce_device[] = { | |||
78 | { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //? | 78 | { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //? |
79 | { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //? | 79 | { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //? |
80 | { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //? | 80 | { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //? |
81 | { 0x06f8, 0x0004, "Gullemot Jet Leader 3D", btn_joystick, abs_joystick, ff_iforce }, //? | ||
81 | { 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]", btn_joystick, abs_joystick, ff_iforce } | 82 | { 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]", btn_joystick, abs_joystick, ff_iforce } |
82 | }; | 83 | }; |
83 | 84 | ||
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 617c0b0e5a39..6369a24684fe 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c | |||
@@ -229,6 +229,7 @@ static struct usb_device_id iforce_usb_ids [] = { | |||
229 | { USB_DEVICE(0x061c, 0xc0a4) }, /* ACT LABS Force RS */ | 229 | { USB_DEVICE(0x061c, 0xc0a4) }, /* ACT LABS Force RS */ |
230 | { USB_DEVICE(0x06f8, 0x0001) }, /* Guillemot Race Leader Force Feedback */ | 230 | { USB_DEVICE(0x06f8, 0x0001) }, /* Guillemot Race Leader Force Feedback */ |
231 | { USB_DEVICE(0x06f8, 0x0004) }, /* Guillemot Force Feedback Racing Wheel */ | 231 | { USB_DEVICE(0x06f8, 0x0004) }, /* Guillemot Force Feedback Racing Wheel */ |
232 | { USB_DEVICE(0x06f8, 0xa302) }, /* Guillemot Jet Leader 3D */ | ||
232 | { } /* Terminating entry */ | 233 | { } /* Terminating entry */ |
233 | }; | 234 | }; |
234 | 235 | ||
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c index ec0a2a64d49c..a436f2220856 100644 --- a/drivers/input/joystick/spaceball.c +++ b/drivers/input/joystick/spaceball.c | |||
@@ -4,8 +4,8 @@ | |||
4 | * Copyright (c) 1999-2001 Vojtech Pavlik | 4 | * Copyright (c) 1999-2001 Vojtech Pavlik |
5 | * | 5 | * |
6 | * Based on the work of: | 6 | * Based on the work of: |
7 | * David Thompson | 7 | * David Thompson |
8 | * Joseph Krahn | 8 | * Joseph Krahn |
9 | */ | 9 | */ |
10 | 10 | ||
11 | /* | 11 | /* |
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c index 874367bfab08..01fd2e4791ae 100644 --- a/drivers/input/joystick/spaceorb.c +++ b/drivers/input/joystick/spaceorb.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (c) 1999-2001 Vojtech Pavlik | 4 | * Copyright (c) 1999-2001 Vojtech Pavlik |
5 | * | 5 | * |
6 | * Based on the work of: | 6 | * Based on the work of: |
7 | * David Thompson | 7 | * David Thompson |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* | 10 | /* |
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c index aaee52ceb920..9eb9954cac6e 100644 --- a/drivers/input/joystick/tmdc.c +++ b/drivers/input/joystick/tmdc.c | |||
@@ -79,7 +79,7 @@ static short tmdc_btn_pad[TMDC_BTN] = | |||
79 | { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR }; | 79 | { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR }; |
80 | static short tmdc_btn_joy[TMDC_BTN] = | 80 | static short tmdc_btn_joy[TMDC_BTN] = |
81 | { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE, | 81 | { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE, |
82 | BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z }; | 82 | BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z }; |
83 | static short tmdc_btn_fm[TMDC_BTN] = | 83 | static short tmdc_btn_fm[TMDC_BTN] = |
84 | { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 }; | 84 | { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 }; |
85 | static short tmdc_btn_at[TMDC_BTN] = | 85 | static short tmdc_btn_at[TMDC_BTN] = |
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index dd88b9cb49fa..28100d461cb7 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c | |||
@@ -84,6 +84,7 @@ static struct tgfx { | |||
84 | char phys[7][32]; | 84 | char phys[7][32]; |
85 | int sticks; | 85 | int sticks; |
86 | int used; | 86 | int used; |
87 | struct semaphore sem; | ||
87 | } *tgfx_base[3]; | 88 | } *tgfx_base[3]; |
88 | 89 | ||
89 | /* | 90 | /* |
@@ -99,7 +100,7 @@ static void tgfx_timer(unsigned long private) | |||
99 | for (i = 0; i < 7; i++) | 100 | for (i = 0; i < 7; i++) |
100 | if (tgfx->sticks & (1 << i)) { | 101 | if (tgfx->sticks & (1 << i)) { |
101 | 102 | ||
102 | dev = tgfx->dev + i; | 103 | dev = tgfx->dev + i; |
103 | 104 | ||
104 | parport_write_data(tgfx->pd->port, ~(1 << i)); | 105 | parport_write_data(tgfx->pd->port, ~(1 << i)); |
105 | data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; | 106 | data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; |
@@ -122,23 +123,34 @@ static void tgfx_timer(unsigned long private) | |||
122 | 123 | ||
123 | static int tgfx_open(struct input_dev *dev) | 124 | static int tgfx_open(struct input_dev *dev) |
124 | { | 125 | { |
125 | struct tgfx *tgfx = dev->private; | 126 | struct tgfx *tgfx = dev->private; |
126 | if (!tgfx->used++) { | 127 | int err; |
128 | |||
129 | err = down_interruptible(&tgfx->sem); | ||
130 | if (err) | ||
131 | return err; | ||
132 | |||
133 | if (!tgfx->used++) { | ||
127 | parport_claim(tgfx->pd); | 134 | parport_claim(tgfx->pd); |
128 | parport_write_control(tgfx->pd->port, 0x04); | 135 | parport_write_control(tgfx->pd->port, 0x04); |
129 | mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); | 136 | mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); |
130 | } | 137 | } |
131 | return 0; | 138 | |
139 | up(&tgfx->sem); | ||
140 | return 0; | ||
132 | } | 141 | } |
133 | 142 | ||
134 | static void tgfx_close(struct input_dev *dev) | 143 | static void tgfx_close(struct input_dev *dev) |
135 | { | 144 | { |
136 | struct tgfx *tgfx = dev->private; | 145 | struct tgfx *tgfx = dev->private; |
137 | if (!--tgfx->used) { | 146 | |
138 | del_timer(&tgfx->timer); | 147 | down(&tgfx->sem); |
148 | if (!--tgfx->used) { | ||
149 | del_timer_sync(&tgfx->timer); | ||
139 | parport_write_control(tgfx->pd->port, 0x00); | 150 | parport_write_control(tgfx->pd->port, 0x00); |
140 | parport_release(tgfx->pd); | 151 | parport_release(tgfx->pd); |
141 | } | 152 | } |
153 | up(&tgfx->sem); | ||
142 | } | 154 | } |
143 | 155 | ||
144 | /* | 156 | /* |
@@ -166,11 +178,12 @@ static struct tgfx __init *tgfx_probe(int *config, int nargs) | |||
166 | return NULL; | 178 | return NULL; |
167 | } | 179 | } |
168 | 180 | ||
169 | if (!(tgfx = kmalloc(sizeof(struct tgfx), GFP_KERNEL))) { | 181 | if (!(tgfx = kcalloc(1, sizeof(struct tgfx), GFP_KERNEL))) { |
170 | parport_put_port(pp); | 182 | parport_put_port(pp); |
171 | return NULL; | 183 | return NULL; |
172 | } | 184 | } |
173 | memset(tgfx, 0, sizeof(struct tgfx)); | 185 | |
186 | init_MUTEX(&tgfx->sem); | ||
174 | 187 | ||
175 | tgfx->pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); | 188 | tgfx->pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); |
176 | 189 | ||
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 82fad9a23ace..4d4985b59abf 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -227,7 +227,7 @@ static ssize_t atkbd_do_set_##_name(struct device *d, struct device_attribute *a | |||
227 | { \ | 227 | { \ |
228 | return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \ | 228 | return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \ |
229 | } \ | 229 | } \ |
230 | static struct device_attribute atkbd_attr_##_name = \ | 230 | static struct device_attribute atkbd_attr_##_name = \ |
231 | __ATTR(_name, S_IWUSR | S_IRUGO, atkbd_do_show_##_name, atkbd_do_set_##_name); | 231 | __ATTR(_name, S_IWUSR | S_IRUGO, atkbd_do_show_##_name, atkbd_do_set_##_name); |
232 | 232 | ||
233 | ATKBD_DEFINE_ATTR(extra); | 233 | ATKBD_DEFINE_ATTR(extra); |
@@ -388,7 +388,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
388 | value = atkbd->release ? 0 : | 388 | value = atkbd->release ? 0 : |
389 | (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key))); | 389 | (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key))); |
390 | 390 | ||
391 | switch (value) { /* Workaround Toshiba laptop multiple keypress */ | 391 | switch (value) { /* Workaround Toshiba laptop multiple keypress */ |
392 | case 0: | 392 | case 0: |
393 | atkbd->last = 0; | 393 | atkbd->last = 0; |
394 | break; | 394 | break; |
@@ -894,7 +894,7 @@ static int atkbd_reconnect(struct serio *serio) | |||
894 | if (atkbd->write) { | 894 | if (atkbd->write) { |
895 | param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0) | 895 | param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0) |
896 | | (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0) | 896 | | (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0) |
897 | | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0); | 897 | | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0); |
898 | 898 | ||
899 | if (atkbd_probe(atkbd)) | 899 | if (atkbd_probe(atkbd)) |
900 | return -1; | 900 | return -1; |
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 0f1220a0ceb5..a8551711e8d6 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #define CORGI_KEY_CALENDER KEY_F1 | 39 | #define CORGI_KEY_CALENDER KEY_F1 |
40 | #define CORGI_KEY_ADDRESS KEY_F2 | 40 | #define CORGI_KEY_ADDRESS KEY_F2 |
41 | #define CORGI_KEY_FN KEY_F3 | 41 | #define CORGI_KEY_FN KEY_F3 |
42 | #define CORGI_KEY_CANCEL KEY_F4 | ||
42 | #define CORGI_KEY_OFF KEY_SUSPEND | 43 | #define CORGI_KEY_OFF KEY_SUSPEND |
43 | #define CORGI_KEY_EXOK KEY_F5 | 44 | #define CORGI_KEY_EXOK KEY_F5 |
44 | #define CORGI_KEY_EXCANCEL KEY_F6 | 45 | #define CORGI_KEY_EXCANCEL KEY_F6 |
@@ -46,6 +47,7 @@ | |||
46 | #define CORGI_KEY_EXJOGUP KEY_F8 | 47 | #define CORGI_KEY_EXJOGUP KEY_F8 |
47 | #define CORGI_KEY_JAP1 KEY_LEFTCTRL | 48 | #define CORGI_KEY_JAP1 KEY_LEFTCTRL |
48 | #define CORGI_KEY_JAP2 KEY_LEFTALT | 49 | #define CORGI_KEY_JAP2 KEY_LEFTALT |
50 | #define CORGI_KEY_MAIL KEY_F10 | ||
49 | #define CORGI_KEY_OK KEY_F11 | 51 | #define CORGI_KEY_OK KEY_F11 |
50 | #define CORGI_KEY_MENU KEY_F12 | 52 | #define CORGI_KEY_MENU KEY_F12 |
51 | #define CORGI_HINGE_0 KEY_KP0 | 53 | #define CORGI_HINGE_0 KEY_KP0 |
@@ -59,8 +61,8 @@ static unsigned char corgikbd_keycode[NR_SCANCODES] = { | |||
59 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ | 61 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ |
60 | CORGI_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ | 62 | CORGI_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ |
61 | CORGI_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, 0, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, /* 65-80 */ | 63 | CORGI_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, 0, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, /* 65-80 */ |
62 | KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */ | 64 | CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */ |
63 | KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */ | 65 | KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */ |
64 | CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */ | 66 | CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */ |
65 | CORGI_HINGE_0, CORGI_HINGE_1, CORGI_HINGE_2 /* 125-127 */ | 67 | CORGI_HINGE_0, CORGI_HINGE_1, CORGI_HINGE_2 /* 125-127 */ |
66 | }; | 68 | }; |
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 2694ff2b5beb..098963c7cdd6 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c | |||
@@ -15,10 +15,10 @@ | |||
15 | * information given below, I will _not_ be liable! | 15 | * information given below, I will _not_ be liable! |
16 | * | 16 | * |
17 | * RJ10 pinout: To DE9: Or DB25: | 17 | * RJ10 pinout: To DE9: Or DB25: |
18 | * 1 - RxD <----> Pin 3 (TxD) <-> Pin 2 (TxD) | 18 | * 1 - RxD <----> Pin 3 (TxD) <-> Pin 2 (TxD) |
19 | * 2 - GND <----> Pin 5 (GND) <-> Pin 7 (GND) | 19 | * 2 - GND <----> Pin 5 (GND) <-> Pin 7 (GND) |
20 | * 4 - TxD <----> Pin 2 (RxD) <-> Pin 3 (RxD) | 20 | * 4 - TxD <----> Pin 2 (RxD) <-> Pin 3 (RxD) |
21 | * 3 - +12V (from HDD drive connector), DON'T connect to DE9 or DB25!!! | 21 | * 3 - +12V (from HDD drive connector), DON'T connect to DE9 or DB25!!! |
22 | * | 22 | * |
23 | * Pin numbers for DE9 and DB25 are noted on the plug (quite small:). For | 23 | * Pin numbers for DE9 and DB25 are noted on the plug (quite small:). For |
24 | * RJ10, it's like this: | 24 | * RJ10, it's like this: |
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index d3e9dd6a13cd..8935290256b3 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c | |||
@@ -42,7 +42,7 @@ MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>"); | |||
42 | MODULE_DESCRIPTION("LoCoMo keyboard driver"); | 42 | MODULE_DESCRIPTION("LoCoMo keyboard driver"); |
43 | MODULE_LICENSE("GPL"); | 43 | MODULE_LICENSE("GPL"); |
44 | 44 | ||
45 | #define LOCOMOKBD_NUMKEYS 128 | 45 | #define LOCOMOKBD_NUMKEYS 128 |
46 | 46 | ||
47 | #define KEY_ACTIVITY KEY_F16 | 47 | #define KEY_ACTIVITY KEY_F16 |
48 | #define KEY_CONTACT KEY_F18 | 48 | #define KEY_CONTACT KEY_F18 |
@@ -61,7 +61,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = { | |||
61 | KEY_G, KEY_F, KEY_X, KEY_S, 0, 0, 0, 0, 0, 0, /* 90 - 99 */ | 61 | KEY_G, KEY_F, KEY_X, KEY_S, 0, 0, 0, 0, 0, 0, /* 90 - 99 */ |
62 | 0, 0, KEY_DOT, 0, KEY_COMMA, KEY_N, KEY_B, KEY_C, KEY_Z, KEY_A, /* 100 - 109 */ | 62 | 0, 0, KEY_DOT, 0, KEY_COMMA, KEY_N, KEY_B, KEY_C, KEY_Z, KEY_A, /* 100 - 109 */ |
63 | KEY_LEFTSHIFT, KEY_TAB, KEY_LEFTCTRL, 0, 0, 0, 0, 0, 0, 0, /* 110 - 119 */ | 63 | KEY_LEFTSHIFT, KEY_TAB, KEY_LEFTCTRL, 0, 0, 0, 0, 0, 0, 0, /* 110 - 119 */ |
64 | KEY_M, KEY_SPACE, KEY_V, KEY_APOSTROPHE, KEY_SLASH, 0, 0, 0 /* 120 - 128 */ | 64 | KEY_M, KEY_SPACE, KEY_V, KEY_APOSTROPHE, KEY_SLASH, 0, 0, 0 /* 120 - 128 */ |
65 | }; | 65 | }; |
66 | 66 | ||
67 | #define KB_ROWS 16 | 67 | #define KB_ROWS 16 |
@@ -82,7 +82,7 @@ struct locomokbd { | |||
82 | struct locomo_dev *ldev; | 82 | struct locomo_dev *ldev; |
83 | unsigned long base; | 83 | unsigned long base; |
84 | spinlock_t lock; | 84 | spinlock_t lock; |
85 | 85 | ||
86 | struct timer_list timer; | 86 | struct timer_list timer; |
87 | }; | 87 | }; |
88 | 88 | ||
@@ -95,7 +95,7 @@ static inline void locomokbd_charge_all(unsigned long membase) | |||
95 | static inline void locomokbd_activate_all(unsigned long membase) | 95 | static inline void locomokbd_activate_all(unsigned long membase) |
96 | { | 96 | { |
97 | unsigned long r; | 97 | unsigned long r; |
98 | 98 | ||
99 | locomo_writel(0, membase + LOCOMO_KSC); | 99 | locomo_writel(0, membase + LOCOMO_KSC); |
100 | r = locomo_readl(membase + LOCOMO_KIC); | 100 | r = locomo_readl(membase + LOCOMO_KIC); |
101 | r &= 0xFEFF; | 101 | r &= 0xFEFF; |
@@ -127,7 +127,7 @@ static inline void locomokbd_reset_col(unsigned long membase, int col) | |||
127 | */ | 127 | */ |
128 | 128 | ||
129 | /* Scan the hardware keyboard and push any changes up through the input layer */ | 129 | /* Scan the hardware keyboard and push any changes up through the input layer */ |
130 | static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *regs) | 130 | static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *regs) |
131 | { | 131 | { |
132 | unsigned int row, col, rowd, scancode; | 132 | unsigned int row, col, rowd, scancode; |
133 | unsigned long flags; | 133 | unsigned long flags; |
@@ -138,7 +138,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * | |||
138 | 138 | ||
139 | if (regs) | 139 | if (regs) |
140 | input_regs(&locomokbd->input, regs); | 140 | input_regs(&locomokbd->input, regs); |
141 | 141 | ||
142 | locomokbd_charge_all(membase); | 142 | locomokbd_charge_all(membase); |
143 | 143 | ||
144 | num_pressed = 0; | 144 | num_pressed = 0; |
@@ -146,9 +146,9 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * | |||
146 | 146 | ||
147 | locomokbd_activate_col(membase, col); | 147 | locomokbd_activate_col(membase, col); |
148 | udelay(KB_DELAY); | 148 | udelay(KB_DELAY); |
149 | 149 | ||
150 | rowd = ~locomo_readl(membase + LOCOMO_KIB); | 150 | rowd = ~locomo_readl(membase + LOCOMO_KIB); |
151 | for (row = 0; row < KB_ROWS; row++ ) { | 151 | for (row = 0; row < KB_ROWS; row++) { |
152 | scancode = SCANCODE(col, row); | 152 | scancode = SCANCODE(col, row); |
153 | if (rowd & KB_ROWMASK(row)) { | 153 | if (rowd & KB_ROWMASK(row)) { |
154 | num_pressed += 1; | 154 | num_pressed += 1; |
@@ -170,7 +170,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * | |||
170 | spin_unlock_irqrestore(&locomokbd->lock, flags); | 170 | spin_unlock_irqrestore(&locomokbd->lock, flags); |
171 | } | 171 | } |
172 | 172 | ||
173 | /* | 173 | /* |
174 | * LoCoMo keyboard interrupt handler. | 174 | * LoCoMo keyboard interrupt handler. |
175 | */ | 175 | */ |
176 | static irqreturn_t locomokbd_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 176 | static irqreturn_t locomokbd_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
@@ -205,8 +205,8 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
205 | memset(locomokbd, 0, sizeof(struct locomokbd)); | 205 | memset(locomokbd, 0, sizeof(struct locomokbd)); |
206 | 206 | ||
207 | /* try and claim memory region */ | 207 | /* try and claim memory region */ |
208 | if (!request_mem_region((unsigned long) dev->mapbase, | 208 | if (!request_mem_region((unsigned long) dev->mapbase, |
209 | dev->length, | 209 | dev->length, |
210 | LOCOMO_DRIVER_NAME(dev))) { | 210 | LOCOMO_DRIVER_NAME(dev))) { |
211 | ret = -EBUSY; | 211 | ret = -EBUSY; |
212 | printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); | 212 | printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); |
@@ -225,7 +225,7 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
225 | locomokbd->timer.data = (unsigned long) locomokbd; | 225 | locomokbd->timer.data = (unsigned long) locomokbd; |
226 | 226 | ||
227 | locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 227 | locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
228 | 228 | ||
229 | init_input_dev(&locomokbd->input); | 229 | init_input_dev(&locomokbd->input); |
230 | locomokbd->input.keycode = locomokbd->keycode; | 230 | locomokbd->input.keycode = locomokbd->keycode; |
231 | locomokbd->input.keycodesize = sizeof(unsigned char); | 231 | locomokbd->input.keycodesize = sizeof(unsigned char); |
@@ -271,11 +271,11 @@ free: | |||
271 | static int locomokbd_remove(struct locomo_dev *dev) | 271 | static int locomokbd_remove(struct locomo_dev *dev) |
272 | { | 272 | { |
273 | struct locomokbd *locomokbd = locomo_get_drvdata(dev); | 273 | struct locomokbd *locomokbd = locomo_get_drvdata(dev); |
274 | 274 | ||
275 | free_irq(dev->irq[0], locomokbd); | 275 | free_irq(dev->irq[0], locomokbd); |
276 | 276 | ||
277 | del_timer_sync(&locomokbd->timer); | 277 | del_timer_sync(&locomokbd->timer); |
278 | 278 | ||
279 | input_unregister_device(&locomokbd->input); | 279 | input_unregister_device(&locomokbd->input); |
280 | locomo_set_drvdata(dev, NULL); | 280 | locomo_set_drvdata(dev, NULL); |
281 | 281 | ||
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index 859ed771ee0a..eecbde294f1f 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: maple_keyb.c,v 1.4 2004/03/22 01:18:15 lethal Exp $ | 2 | * $Id: maple_keyb.c,v 1.4 2004/03/22 01:18:15 lethal Exp $ |
3 | * SEGA Dreamcast keyboard driver | 3 | * SEGA Dreamcast keyboard driver |
4 | * Based on drivers/usb/usbkbd.c | 4 | * Based on drivers/usb/usbkbd.c |
5 | */ | 5 | */ |
6 | 6 | ||
@@ -40,7 +40,6 @@ struct dc_kbd { | |||
40 | struct input_dev dev; | 40 | struct input_dev dev; |
41 | unsigned char new[8]; | 41 | unsigned char new[8]; |
42 | unsigned char old[8]; | 42 | unsigned char old[8]; |
43 | int open; | ||
44 | }; | 43 | }; |
45 | 44 | ||
46 | 45 | ||
@@ -95,22 +94,6 @@ static void dc_kbd_callback(struct mapleq *mq) | |||
95 | } | 94 | } |
96 | } | 95 | } |
97 | 96 | ||
98 | |||
99 | static int dc_kbd_open(struct input_dev *dev) | ||
100 | { | ||
101 | struct dc_kbd *kbd = dev->private; | ||
102 | kbd->open++; | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | |||
107 | static void dc_kbd_close(struct input_dev *dev) | ||
108 | { | ||
109 | struct dc_kbd *kbd = dev->private; | ||
110 | kbd->open--; | ||
111 | } | ||
112 | |||
113 | |||
114 | static int dc_kbd_connect(struct maple_device *dev) | 97 | static int dc_kbd_connect(struct maple_device *dev) |
115 | { | 98 | { |
116 | int i; | 99 | int i; |
@@ -133,9 +116,6 @@ static int dc_kbd_connect(struct maple_device *dev) | |||
133 | clear_bit(0, kbd->dev.keybit); | 116 | clear_bit(0, kbd->dev.keybit); |
134 | 117 | ||
135 | kbd->dev.private = kbd; | 118 | kbd->dev.private = kbd; |
136 | kbd->dev.open = dc_kbd_open; | ||
137 | kbd->dev.close = dc_kbd_close; | ||
138 | kbd->dev.event = NULL; | ||
139 | 119 | ||
140 | kbd->dev.name = dev->product_name; | 120 | kbd->dev.name = dev->product_name; |
141 | kbd->dev.id.bustype = BUS_MAPLE; | 121 | kbd->dev.id.bustype = BUS_MAPLE; |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 158c8e845ff9..98710997aaaa 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -298,9 +298,11 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz | |||
298 | /* check if absmin/absmax/absfuzz/absflat are filled as | 298 | /* check if absmin/absmax/absfuzz/absflat are filled as |
299 | * told in Documentation/input/input-programming.txt */ | 299 | * told in Documentation/input/input-programming.txt */ |
300 | if (test_bit(EV_ABS, dev->evbit)) { | 300 | if (test_bit(EV_ABS, dev->evbit)) { |
301 | retval = uinput_validate_absbits(dev); | 301 | int err = uinput_validate_absbits(dev); |
302 | if (retval < 0) | 302 | if (err < 0) { |
303 | retval = err; | ||
303 | kfree(dev->name); | 304 | kfree(dev->name); |
305 | } | ||
304 | } | 306 | } |
305 | 307 | ||
306 | exit: | 308 | exit: |
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile index a7864195806a..c4909b49337d 100644 --- a/drivers/input/mouse/Makefile +++ b/drivers/input/mouse/Makefile | |||
@@ -15,4 +15,4 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o | |||
15 | obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o | 15 | obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o |
16 | obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o | 16 | obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o |
17 | 17 | ||
18 | psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o | 18 | psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 7bf4be733e9a..a12e98158a75 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -30,10 +30,11 @@ | |||
30 | 30 | ||
31 | #define ALPS_DUALPOINT 0x01 | 31 | #define ALPS_DUALPOINT 0x01 |
32 | #define ALPS_WHEEL 0x02 | 32 | #define ALPS_WHEEL 0x02 |
33 | #define ALPS_FW_BK 0x04 | 33 | #define ALPS_FW_BK_1 0x04 |
34 | #define ALPS_4BTN 0x08 | 34 | #define ALPS_4BTN 0x08 |
35 | #define ALPS_OLDPROTO 0x10 | 35 | #define ALPS_OLDPROTO 0x10 |
36 | #define ALPS_PASS 0x20 | 36 | #define ALPS_PASS 0x20 |
37 | #define ALPS_FW_BK_2 0x40 | ||
37 | 38 | ||
38 | static struct alps_model_info alps_model_data[] = { | 39 | static struct alps_model_info alps_model_data[] = { |
39 | { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */ | 40 | { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */ |
@@ -43,11 +44,11 @@ static struct alps_model_info alps_model_data[] = { | |||
43 | { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, | 44 | { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, |
44 | { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, 0 }, | 45 | { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, 0 }, |
45 | { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ | 46 | { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ |
46 | { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK }, /* NEC Versa L320 */ | 47 | { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ |
47 | { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, | 48 | { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, |
48 | { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS }, /* Dell Latitude D800 */ | 49 | { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS }, /* Dell Latitude D800 */ |
49 | { { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, | 50 | { { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, |
50 | { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, | 51 | { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */ |
51 | { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ | 52 | { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ |
52 | { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, | 53 | { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, |
53 | { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ | 54 | { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ |
@@ -61,11 +62,11 @@ static struct alps_model_info alps_model_data[] = { | |||
61 | 62 | ||
62 | /* | 63 | /* |
63 | * ALPS abolute Mode - new format | 64 | * ALPS abolute Mode - new format |
64 | * | 65 | * |
65 | * byte 0: 1 ? ? ? 1 ? ? ? | 66 | * byte 0: 1 ? ? ? 1 ? ? ? |
66 | * byte 1: 0 x6 x5 x4 x3 x2 x1 x0 | 67 | * byte 1: 0 x6 x5 x4 x3 x2 x1 x0 |
67 | * byte 2: 0 x10 x9 x8 x7 ? fin ges | 68 | * byte 2: 0 x10 x9 x8 x7 ? fin ges |
68 | * byte 3: 0 y9 y8 y7 1 M R L | 69 | * byte 3: 0 y9 y8 y7 1 M R L |
69 | * byte 4: 0 y6 y5 y4 y3 y2 y1 y0 | 70 | * byte 4: 0 y6 y5 y4 y3 y2 y1 y0 |
70 | * byte 5: 0 z6 z5 z4 z3 z2 z1 z0 | 71 | * byte 5: 0 z6 z5 z4 z3 z2 z1 z0 |
71 | * | 72 | * |
@@ -81,11 +82,12 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs) | |||
81 | struct input_dev *dev = &psmouse->dev; | 82 | struct input_dev *dev = &psmouse->dev; |
82 | struct input_dev *dev2 = &priv->dev2; | 83 | struct input_dev *dev2 = &priv->dev2; |
83 | int x, y, z, ges, fin, left, right, middle; | 84 | int x, y, z, ges, fin, left, right, middle; |
85 | int back = 0, forward = 0; | ||
84 | 86 | ||
85 | input_regs(dev, regs); | 87 | input_regs(dev, regs); |
86 | 88 | ||
87 | if ((packet[0] & 0xc8) == 0x08) { /* 3-byte PS/2 packet */ | 89 | if ((packet[0] & 0xc8) == 0x08) { /* 3-byte PS/2 packet */ |
88 | input_report_key(dev2, BTN_LEFT, packet[0] & 1); | 90 | input_report_key(dev2, BTN_LEFT, packet[0] & 1); |
89 | input_report_key(dev2, BTN_RIGHT, packet[0] & 2); | 91 | input_report_key(dev2, BTN_RIGHT, packet[0] & 2); |
90 | input_report_key(dev2, BTN_MIDDLE, packet[0] & 4); | 92 | input_report_key(dev2, BTN_MIDDLE, packet[0] & 4); |
91 | input_report_rel(dev2, REL_X, | 93 | input_report_rel(dev2, REL_X, |
@@ -112,6 +114,18 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs) | |||
112 | z = packet[5]; | 114 | z = packet[5]; |
113 | } | 115 | } |
114 | 116 | ||
117 | if (priv->i->flags & ALPS_FW_BK_1) { | ||
118 | back = packet[2] & 4; | ||
119 | forward = packet[0] & 0x10; | ||
120 | } | ||
121 | |||
122 | if (priv->i->flags & ALPS_FW_BK_2) { | ||
123 | back = packet[3] & 4; | ||
124 | forward = packet[2] & 4; | ||
125 | if ((middle = forward && back)) | ||
126 | forward = back = 0; | ||
127 | } | ||
128 | |||
115 | ges = packet[2] & 1; | 129 | ges = packet[2] & 1; |
116 | fin = packet[2] & 2; | 130 | fin = packet[2] & 2; |
117 | 131 | ||
@@ -155,13 +169,12 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs) | |||
155 | input_report_abs(dev, ABS_PRESSURE, z); | 169 | input_report_abs(dev, ABS_PRESSURE, z); |
156 | input_report_key(dev, BTN_TOOL_FINGER, z > 0); | 170 | input_report_key(dev, BTN_TOOL_FINGER, z > 0); |
157 | 171 | ||
158 | |||
159 | if (priv->i->flags & ALPS_WHEEL) | 172 | if (priv->i->flags & ALPS_WHEEL) |
160 | input_report_rel(dev, REL_WHEEL, ((packet[0] >> 4) & 0x07) | ((packet[2] >> 2) & 0x08)); | 173 | input_report_rel(dev, REL_WHEEL, ((packet[0] >> 4) & 0x07) | ((packet[2] >> 2) & 0x08)); |
161 | 174 | ||
162 | if (priv->i->flags & ALPS_FW_BK) { | 175 | if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { |
163 | input_report_key(dev, BTN_FORWARD, packet[0] & 0x10); | 176 | input_report_key(dev, BTN_FORWARD, forward); |
164 | input_report_key(dev, BTN_BACK, packet[2] & 0x04); | 177 | input_report_key(dev, BTN_BACK, back); |
165 | } | 178 | } |
166 | 179 | ||
167 | input_sync(dev); | 180 | input_sync(dev); |
@@ -257,7 +270,6 @@ static struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *vers | |||
257 | static int alps_passthrough_mode(struct psmouse *psmouse, int enable) | 270 | static int alps_passthrough_mode(struct psmouse *psmouse, int enable) |
258 | { | 271 | { |
259 | struct ps2dev *ps2dev = &psmouse->ps2dev; | 272 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
260 | unsigned char param[3]; | ||
261 | int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11; | 273 | int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11; |
262 | 274 | ||
263 | if (ps2_command(ps2dev, NULL, cmd) || | 275 | if (ps2_command(ps2dev, NULL, cmd) || |
@@ -267,7 +279,7 @@ static int alps_passthrough_mode(struct psmouse *psmouse, int enable) | |||
267 | return -1; | 279 | return -1; |
268 | 280 | ||
269 | /* we may get 3 more bytes, just ignore them */ | 281 | /* we may get 3 more bytes, just ignore them */ |
270 | ps2_command(ps2dev, param, 0x0300); | 282 | ps2_drain(ps2dev, 3, 100); |
271 | 283 | ||
272 | return 0; | 284 | return 0; |
273 | } | 285 | } |
@@ -425,7 +437,7 @@ int alps_init(struct psmouse *psmouse) | |||
425 | psmouse->dev.relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); | 437 | psmouse->dev.relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); |
426 | } | 438 | } |
427 | 439 | ||
428 | if (priv->i->flags & ALPS_FW_BK) { | 440 | if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { |
429 | psmouse->dev.keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); | 441 | psmouse->dev.keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); |
430 | psmouse->dev.keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); | 442 | psmouse->dev.keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); |
431 | } | 443 | } |
@@ -436,8 +448,8 @@ int alps_init(struct psmouse *psmouse) | |||
436 | priv->dev2.id.bustype = BUS_I8042; | 448 | priv->dev2.id.bustype = BUS_I8042; |
437 | priv->dev2.id.vendor = 0x0002; | 449 | priv->dev2.id.vendor = 0x0002; |
438 | priv->dev2.id.product = PSMOUSE_ALPS; | 450 | priv->dev2.id.product = PSMOUSE_ALPS; |
439 | priv->dev2.id.version = 0x0000; | 451 | priv->dev2.id.version = 0x0000; |
440 | 452 | ||
441 | priv->dev2.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 453 | priv->dev2.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
442 | priv->dev2.relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); | 454 | priv->dev2.relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); |
443 | priv->dev2.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 455 | priv->dev2.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
@@ -461,17 +473,15 @@ init_fail: | |||
461 | int alps_detect(struct psmouse *psmouse, int set_properties) | 473 | int alps_detect(struct psmouse *psmouse, int set_properties) |
462 | { | 474 | { |
463 | int version; | 475 | int version; |
464 | struct alps_model_info *model; | 476 | struct alps_model_info *model; |
465 | 477 | ||
466 | if (!(model = alps_get_model(psmouse, &version))) | 478 | if (!(model = alps_get_model(psmouse, &version))) |
467 | return -1; | 479 | return -1; |
468 | 480 | ||
469 | if (set_properties) { | 481 | if (set_properties) { |
470 | psmouse->vendor = "ALPS"; | 482 | psmouse->vendor = "ALPS"; |
471 | if (model->flags & ALPS_DUALPOINT) | 483 | psmouse->name = model->flags & ALPS_DUALPOINT ? |
472 | psmouse->name = "DualPoint TouchPad"; | 484 | "DualPoint TouchPad" : "GlidePoint"; |
473 | else | ||
474 | psmouse->name = "GlidePoint"; | ||
475 | psmouse->model = version; | 485 | psmouse->model = version; |
476 | } | 486 | } |
477 | return 0; | 487 | return 0; |
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index 7baa09cca7c5..e994849efb8f 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c | |||
@@ -33,7 +33,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | |||
33 | MODULE_DESCRIPTION("Amiga mouse driver"); | 33 | MODULE_DESCRIPTION("Amiga mouse driver"); |
34 | MODULE_LICENSE("GPL"); | 34 | MODULE_LICENSE("GPL"); |
35 | 35 | ||
36 | static int amimouse_used = 0; | ||
37 | static int amimouse_lastx, amimouse_lasty; | 36 | static int amimouse_lastx, amimouse_lasty; |
38 | static struct input_dev amimouse_dev; | 37 | static struct input_dev amimouse_dev; |
39 | 38 | ||
@@ -81,16 +80,12 @@ static int amimouse_open(struct input_dev *dev) | |||
81 | { | 80 | { |
82 | unsigned short joy0dat; | 81 | unsigned short joy0dat; |
83 | 82 | ||
84 | if (amimouse_used++) | ||
85 | return 0; | ||
86 | |||
87 | joy0dat = custom.joy0dat; | 83 | joy0dat = custom.joy0dat; |
88 | 84 | ||
89 | amimouse_lastx = joy0dat & 0xff; | 85 | amimouse_lastx = joy0dat & 0xff; |
90 | amimouse_lasty = joy0dat >> 8; | 86 | amimouse_lasty = joy0dat >> 8; |
91 | 87 | ||
92 | if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { | 88 | if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { |
93 | amimouse_used--; | ||
94 | printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); | 89 | printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); |
95 | return -EBUSY; | 90 | return -EBUSY; |
96 | } | 91 | } |
@@ -100,8 +95,7 @@ static int amimouse_open(struct input_dev *dev) | |||
100 | 95 | ||
101 | static void amimouse_close(struct input_dev *dev) | 96 | static void amimouse_close(struct input_dev *dev) |
102 | { | 97 | { |
103 | if (!--amimouse_used) | 98 | free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); |
104 | free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); | ||
105 | } | 99 | } |
106 | 100 | ||
107 | static int __init amimouse_init(void) | 101 | static int __init amimouse_init(void) |
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c index ca4e96886627..1f62c0134010 100644 --- a/drivers/input/mouse/inport.c +++ b/drivers/input/mouse/inport.c | |||
@@ -17,18 +17,18 @@ | |||
17 | /* | 17 | /* |
18 | * This program is free software; you can redistribute it and/or modify | 18 | * This program is free software; you can redistribute it and/or modify |
19 | * it under the terms of the GNU General Public License as published by | 19 | * it under the terms of the GNU General Public License as published by |
20 | * the Free Software Foundation; either version 2 of the License, or | 20 | * the Free Software Foundation; either version 2 of the License, or |
21 | * (at your option) any later version. | 21 | * (at your option) any later version. |
22 | * | 22 | * |
23 | * This program is distributed in the hope that it will be useful, | 23 | * This program is distributed in the hope that it will be useful, |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26 | * GNU General Public License for more details. | 26 | * GNU General Public License for more details. |
27 | * | 27 | * |
28 | * You should have received a copy of the GNU General Public License | 28 | * You should have received a copy of the GNU General Public License |
29 | * along with this program; if not, write to the Free Software | 29 | * along with this program; if not, write to the Free Software |
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
31 | * | 31 | * |
32 | * Should you need to contact me, the author, you can do so either by | 32 | * Should you need to contact me, the author, you can do so either by |
33 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: | 33 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: |
34 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | 34 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
@@ -87,29 +87,23 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); | |||
87 | 87 | ||
88 | __obsolete_setup("inport_irq="); | 88 | __obsolete_setup("inport_irq="); |
89 | 89 | ||
90 | static int inport_used; | ||
91 | |||
92 | static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); | 90 | static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); |
93 | 91 | ||
94 | static int inport_open(struct input_dev *dev) | 92 | static int inport_open(struct input_dev *dev) |
95 | { | 93 | { |
96 | if (!inport_used++) { | 94 | if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) |
97 | if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) | 95 | return -EBUSY; |
98 | return -EBUSY; | 96 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
99 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 97 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); |
100 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); | ||
101 | } | ||
102 | 98 | ||
103 | return 0; | 99 | return 0; |
104 | } | 100 | } |
105 | 101 | ||
106 | static void inport_close(struct input_dev *dev) | 102 | static void inport_close(struct input_dev *dev) |
107 | { | 103 | { |
108 | if (!--inport_used) { | 104 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
109 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 105 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); |
110 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); | 106 | free_irq(inport_irq, NULL); |
111 | free_irq(inport_irq, NULL); | ||
112 | } | ||
113 | } | 107 | } |
114 | 108 | ||
115 | static struct input_dev inport_dev = { | 109 | static struct input_dev inport_dev = { |
@@ -120,11 +114,11 @@ static struct input_dev inport_dev = { | |||
120 | .close = inport_close, | 114 | .close = inport_close, |
121 | .name = INPORT_NAME, | 115 | .name = INPORT_NAME, |
122 | .phys = "isa023c/input0", | 116 | .phys = "isa023c/input0", |
123 | .id = { | 117 | .id = { |
124 | .bustype = BUS_ISA, | 118 | .bustype = BUS_ISA, |
125 | .vendor = INPORT_VENDOR, | 119 | .vendor = INPORT_VENDOR, |
126 | .product = 0x0001, | 120 | .product = 0x0001, |
127 | .version = 0x0100, | 121 | .version = 0x0100, |
128 | }, | 122 | }, |
129 | }; | 123 | }; |
130 | 124 | ||
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c new file mode 100644 index 000000000000..bd9df9b28325 --- /dev/null +++ b/drivers/input/mouse/lifebook.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Fujitsu B-series Lifebook PS/2 TouchScreen driver | ||
3 | * | ||
4 | * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> | ||
5 | * Copyright (c) 2005 Kenan Esau <kenan.esau@conan.de> | ||
6 | * | ||
7 | * TouchScreen detection, absolute mode setting and packet layout is taken from | ||
8 | * Harald Hoyer's description of the device. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License version 2 as published by | ||
12 | * the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/input.h> | ||
16 | #include <linux/serio.h> | ||
17 | #include <linux/libps2.h> | ||
18 | #include <linux/dmi.h> | ||
19 | |||
20 | #include "psmouse.h" | ||
21 | #include "lifebook.h" | ||
22 | |||
23 | static struct dmi_system_id lifebook_dmi_table[] = { | ||
24 | { | ||
25 | .ident = "Lifebook B", | ||
26 | .matches = { | ||
27 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"), | ||
28 | }, | ||
29 | }, | ||
30 | { } | ||
31 | }; | ||
32 | |||
33 | |||
34 | static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs) | ||
35 | { | ||
36 | unsigned char *packet = psmouse->packet; | ||
37 | struct input_dev *dev = &psmouse->dev; | ||
38 | |||
39 | if (psmouse->pktcnt != 3) | ||
40 | return PSMOUSE_GOOD_DATA; | ||
41 | |||
42 | input_regs(dev, regs); | ||
43 | |||
44 | /* calculate X and Y */ | ||
45 | if ((packet[0] & 0x08) == 0x00) { | ||
46 | input_report_abs(dev, ABS_X, | ||
47 | (packet[1] | ((packet[0] & 0x30) << 4))); | ||
48 | input_report_abs(dev, ABS_Y, | ||
49 | 1024 - (packet[2] | ((packet[0] & 0xC0) << 2))); | ||
50 | } else { | ||
51 | input_report_rel(dev, REL_X, | ||
52 | ((packet[0] & 0x10) ? packet[1] - 256 : packet[1])); | ||
53 | input_report_rel(dev, REL_Y, | ||
54 | -(int)((packet[0] & 0x20) ? packet[2] - 256 : packet[2])); | ||
55 | } | ||
56 | |||
57 | input_report_key(dev, BTN_LEFT, packet[0] & 0x01); | ||
58 | input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); | ||
59 | input_report_key(dev, BTN_TOUCH, packet[0] & 0x04); | ||
60 | |||
61 | input_sync(dev); | ||
62 | |||
63 | return PSMOUSE_FULL_PACKET; | ||
64 | } | ||
65 | |||
66 | static int lifebook_absolute_mode(struct psmouse *psmouse) | ||
67 | { | ||
68 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
69 | unsigned char param; | ||
70 | |||
71 | if (psmouse_reset(psmouse)) | ||
72 | return -1; | ||
73 | |||
74 | /* | ||
75 | Enable absolute output -- ps2_command fails always but if | ||
76 | you leave this call out the touchsreen will never send | ||
77 | absolute coordinates | ||
78 | */ | ||
79 | param = 0x07; | ||
80 | ps2_command(ps2dev, ¶m, PSMOUSE_CMD_SETRES); | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution) | ||
86 | { | ||
87 | unsigned char params[] = { 0, 1, 2, 2, 3 }; | ||
88 | |||
89 | if (resolution == 0 || resolution > 400) | ||
90 | resolution = 400; | ||
91 | |||
92 | ps2_command(&psmouse->ps2dev, ¶ms[resolution / 100], PSMOUSE_CMD_SETRES); | ||
93 | psmouse->resolution = 50 << params[resolution / 100]; | ||
94 | } | ||
95 | |||
96 | static void lifebook_disconnect(struct psmouse *psmouse) | ||
97 | { | ||
98 | psmouse_reset(psmouse); | ||
99 | } | ||
100 | |||
101 | int lifebook_detect(struct psmouse *psmouse, int set_properties) | ||
102 | { | ||
103 | if (!dmi_check_system(lifebook_dmi_table)) | ||
104 | return -1; | ||
105 | |||
106 | if (set_properties) { | ||
107 | psmouse->vendor = "Fujitsu"; | ||
108 | psmouse->name = "Lifebook TouchScreen"; | ||
109 | } | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | int lifebook_init(struct psmouse *psmouse) | ||
115 | { | ||
116 | if (lifebook_absolute_mode(psmouse)) | ||
117 | return -1; | ||
118 | |||
119 | psmouse->dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); | ||
120 | psmouse->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
121 | psmouse->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
122 | psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
123 | input_set_abs_params(&psmouse->dev, ABS_X, 0, 1024, 0, 0); | ||
124 | input_set_abs_params(&psmouse->dev, ABS_Y, 0, 1024, 0, 0); | ||
125 | |||
126 | psmouse->protocol_handler = lifebook_process_byte; | ||
127 | psmouse->set_resolution = lifebook_set_resolution; | ||
128 | psmouse->disconnect = lifebook_disconnect; | ||
129 | psmouse->reconnect = lifebook_absolute_mode; | ||
130 | psmouse->pktsize = 3; | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
diff --git a/drivers/input/mouse/lifebook.h b/drivers/input/mouse/lifebook.h new file mode 100644 index 000000000000..be1c0943825d --- /dev/null +++ b/drivers/input/mouse/lifebook.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * Fujitsu B-series Lifebook PS/2 TouchScreen driver | ||
3 | * | ||
4 | * Copyright (c) 2005 Vojtech Pavlik | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published by | ||
8 | * the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #ifndef _LIFEBOOK_H | ||
12 | #define _LIFEBOOK_H | ||
13 | |||
14 | int lifebook_detect(struct psmouse *psmouse, int set_properties); | ||
15 | int lifebook_init(struct psmouse *psmouse); | ||
16 | |||
17 | #endif | ||
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c index 77eb83e87f61..8b5243167227 100644 --- a/drivers/input/mouse/logibm.c +++ b/drivers/input/mouse/logibm.c | |||
@@ -18,18 +18,18 @@ | |||
18 | /* | 18 | /* |
19 | * This program is free software; you can redistribute it and/or modify | 19 | * This program is free software; you can redistribute it and/or modify |
20 | * it under the terms of the GNU General Public License as published by | 20 | * it under the terms of the GNU General Public License as published by |
21 | * the Free Software Foundation; either version 2 of the License, or | 21 | * the Free Software Foundation; either version 2 of the License, or |
22 | * (at your option) any later version. | 22 | * (at your option) any later version. |
23 | * | 23 | * |
24 | * This program is distributed in the hope that it will be useful, | 24 | * This program is distributed in the hope that it will be useful, |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
27 | * GNU General Public License for more details. | 27 | * GNU General Public License for more details. |
28 | * | 28 | * |
29 | * You should have received a copy of the GNU General Public License | 29 | * You should have received a copy of the GNU General Public License |
30 | * along with this program; if not, write to the Free Software | 30 | * along with this program; if not, write to the Free Software |
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
32 | * | 32 | * |
33 | * Should you need to contact me, the author, you can do so either by | 33 | * Should you need to contact me, the author, you can do so either by |
34 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: | 34 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: |
35 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | 35 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
@@ -77,16 +77,11 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); | |||
77 | 77 | ||
78 | __obsolete_setup("logibm_irq="); | 78 | __obsolete_setup("logibm_irq="); |
79 | 79 | ||
80 | static int logibm_used = 0; | ||
81 | |||
82 | static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); | 80 | static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); |
83 | 81 | ||
84 | static int logibm_open(struct input_dev *dev) | 82 | static int logibm_open(struct input_dev *dev) |
85 | { | 83 | { |
86 | if (logibm_used++) | ||
87 | return 0; | ||
88 | if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { | 84 | if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { |
89 | logibm_used--; | ||
90 | printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); | 85 | printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); |
91 | return -EBUSY; | 86 | return -EBUSY; |
92 | } | 87 | } |
@@ -96,8 +91,6 @@ static int logibm_open(struct input_dev *dev) | |||
96 | 91 | ||
97 | static void logibm_close(struct input_dev *dev) | 92 | static void logibm_close(struct input_dev *dev) |
98 | { | 93 | { |
99 | if (--logibm_used) | ||
100 | return; | ||
101 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); | 94 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); |
102 | free_irq(logibm_irq, NULL); | 95 | free_irq(logibm_irq, NULL); |
103 | } | 96 | } |
@@ -167,7 +160,7 @@ static int __init logibm_init(void) | |||
167 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); | 160 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); |
168 | 161 | ||
169 | input_register_device(&logibm_dev); | 162 | input_register_device(&logibm_dev); |
170 | 163 | ||
171 | printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq); | 164 | printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq); |
172 | 165 | ||
173 | return 0; | 166 | return 0; |
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c index 12dc0ef5020f..e90c60cbbf05 100644 --- a/drivers/input/mouse/maplemouse.c +++ b/drivers/input/mouse/maplemouse.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: maplemouse.c,v 1.2 2004/03/22 01:18:15 lethal Exp $ | 2 | * $Id: maplemouse.c,v 1.2 2004/03/22 01:18:15 lethal Exp $ |
3 | * SEGA Dreamcast mouse driver | 3 | * SEGA Dreamcast mouse driver |
4 | * Based on drivers/usb/usbmouse.c | 4 | * Based on drivers/usb/usbmouse.c |
5 | */ | 5 | */ |
6 | 6 | ||
@@ -15,80 +15,51 @@ | |||
15 | MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); | 15 | MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); |
16 | MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); | 16 | MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); |
17 | 17 | ||
18 | struct dc_mouse { | ||
19 | struct input_dev dev; | ||
20 | int open; | ||
21 | }; | ||
22 | |||
23 | |||
24 | static void dc_mouse_callback(struct mapleq *mq) | 18 | static void dc_mouse_callback(struct mapleq *mq) |
25 | { | 19 | { |
26 | int buttons, relx, rely, relz; | 20 | int buttons, relx, rely, relz; |
27 | struct maple_device *mapledev = mq->dev; | 21 | struct maple_device *mapledev = mq->dev; |
28 | struct dc_mouse *mouse = mapledev->private_data; | 22 | struct input_dev *dev = mapledev->private_data; |
29 | struct input_dev *dev = &mouse->dev; | ||
30 | unsigned char *res = mq->recvbuf; | 23 | unsigned char *res = mq->recvbuf; |
31 | 24 | ||
32 | buttons = ~res[8]; | 25 | buttons = ~res[8]; |
33 | relx=*(unsigned short *)(res+12)-512; | 26 | relx = *(unsigned short *)(res + 12) - 512; |
34 | rely=*(unsigned short *)(res+14)-512; | 27 | rely = *(unsigned short *)(res + 14) - 512; |
35 | relz=*(unsigned short *)(res+16)-512; | 28 | relz = *(unsigned short *)(res + 16) - 512; |
36 | 29 | ||
37 | input_report_key(dev, BTN_LEFT, buttons&4); | 30 | input_report_key(dev, BTN_LEFT, buttons & 4); |
38 | input_report_key(dev, BTN_MIDDLE, buttons&9); | 31 | input_report_key(dev, BTN_MIDDLE, buttons & 9); |
39 | input_report_key(dev, BTN_RIGHT, buttons&2); | 32 | input_report_key(dev, BTN_RIGHT, buttons & 2); |
40 | input_report_rel(dev, REL_X, relx); | 33 | input_report_rel(dev, REL_X, relx); |
41 | input_report_rel(dev, REL_Y, rely); | 34 | input_report_rel(dev, REL_Y, rely); |
42 | input_report_rel(dev, REL_WHEEL, relz); | 35 | input_report_rel(dev, REL_WHEEL, relz); |
43 | input_sync(dev); | 36 | input_sync(dev); |
44 | } | 37 | } |
45 | 38 | ||
46 | |||
47 | static int dc_mouse_open(struct input_dev *dev) | ||
48 | { | ||
49 | struct dc_mouse *mouse = dev->private; | ||
50 | mouse->open++; | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | |||
55 | static void dc_mouse_close(struct input_dev *dev) | ||
56 | { | ||
57 | struct dc_mouse *mouse = dev->private; | ||
58 | mouse->open--; | ||
59 | } | ||
60 | |||
61 | |||
62 | static int dc_mouse_connect(struct maple_device *dev) | 39 | static int dc_mouse_connect(struct maple_device *dev) |
63 | { | 40 | { |
64 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | 41 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); |
65 | struct dc_mouse *mouse; | 42 | struct input_dev *input_dev; |
66 | 43 | ||
67 | if (!(mouse = kmalloc(sizeof(struct dc_mouse), GFP_KERNEL))) | 44 | if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL))) |
68 | return -1; | 45 | return -1; |
69 | memset(mouse, 0, sizeof(struct dc_mouse)); | ||
70 | |||
71 | dev->private_data = mouse; | ||
72 | 46 | ||
73 | mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 47 | dev->private_data = input_dev; |
74 | mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
75 | mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); | ||
76 | 48 | ||
77 | init_input_dev(&mouse->dev); | 49 | memset(input_dev, 0, sizeof(struct dc_mouse)); |
50 | init_input_dev(input_dev); | ||
51 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
52 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
53 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); | ||
78 | 54 | ||
79 | mouse->dev.private = mouse; | 55 | input_dev->name = dev->product_name; |
80 | mouse->dev.open = dc_mouse_open; | 56 | input_dev->id.bustype = BUS_MAPLE; |
81 | mouse->dev.close = dc_mouse_close; | ||
82 | mouse->dev.event = NULL; | ||
83 | 57 | ||
84 | mouse->dev.name = dev->product_name; | 58 | input_register_device(input_dev); |
85 | mouse->dev.id.bustype = BUS_MAPLE; | ||
86 | |||
87 | input_register_device(&mouse->dev); | ||
88 | 59 | ||
89 | maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); | 60 | maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); |
90 | 61 | ||
91 | printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, mouse->dev.name); | 62 | printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name); |
92 | 63 | ||
93 | return 0; | 64 | return 0; |
94 | } | 65 | } |
@@ -96,10 +67,10 @@ static int dc_mouse_connect(struct maple_device *dev) | |||
96 | 67 | ||
97 | static void dc_mouse_disconnect(struct maple_device *dev) | 68 | static void dc_mouse_disconnect(struct maple_device *dev) |
98 | { | 69 | { |
99 | struct dc_mouse *mouse = dev->private_data; | 70 | struct input_dev *input_dev = dev->private_data; |
100 | 71 | ||
101 | input_unregister_device(&mouse->dev); | 72 | input_unregister_device(input_dev); |
102 | kfree(mouse); | 73 | kfree(input_dev); |
103 | } | 74 | } |
104 | 75 | ||
105 | 76 | ||
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c index 0c74918fe254..93393d5c0078 100644 --- a/drivers/input/mouse/pc110pad.c +++ b/drivers/input/mouse/pc110pad.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (c) 2000-2001 Vojtech Pavlik | 4 | * Copyright (c) 2000-2001 Vojtech Pavlik |
5 | * | 5 | * |
6 | * Based on the work of: | 6 | * Based on the work of: |
7 | * Alan Cox Robin O'Leary | 7 | * Alan Cox Robin O'Leary |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* | 10 | /* |
@@ -56,7 +56,6 @@ static int pc110pad_io = 0x15e0; | |||
56 | static struct input_dev pc110pad_dev; | 56 | static struct input_dev pc110pad_dev; |
57 | static int pc110pad_data[3]; | 57 | static int pc110pad_data[3]; |
58 | static int pc110pad_count; | 58 | static int pc110pad_count; |
59 | static int pc110pad_used; | ||
60 | 59 | ||
61 | static char *pc110pad_name = "IBM PC110 TouchPad"; | 60 | static char *pc110pad_name = "IBM PC110 TouchPad"; |
62 | static char *pc110pad_phys = "isa15e0/input0"; | 61 | static char *pc110pad_phys = "isa15e0/input0"; |
@@ -74,7 +73,7 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
74 | 73 | ||
75 | if (pc110pad_count < 3) | 74 | if (pc110pad_count < 3) |
76 | return IRQ_HANDLED; | 75 | return IRQ_HANDLED; |
77 | 76 | ||
78 | input_regs(&pc110pad_dev, regs); | 77 | input_regs(&pc110pad_dev, regs); |
79 | input_report_key(&pc110pad_dev, BTN_TOUCH, | 78 | input_report_key(&pc110pad_dev, BTN_TOUCH, |
80 | pc110pad_data[0] & 0x01); | 79 | pc110pad_data[0] & 0x01); |
@@ -90,15 +89,11 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
90 | 89 | ||
91 | static void pc110pad_close(struct input_dev *dev) | 90 | static void pc110pad_close(struct input_dev *dev) |
92 | { | 91 | { |
93 | if (!--pc110pad_used) | 92 | outb(PC110PAD_OFF, pc110pad_io + 2); |
94 | outb(PC110PAD_OFF, pc110pad_io + 2); | ||
95 | } | 93 | } |
96 | 94 | ||
97 | static int pc110pad_open(struct input_dev *dev) | 95 | static int pc110pad_open(struct input_dev *dev) |
98 | { | 96 | { |
99 | if (pc110pad_used++) | ||
100 | return 0; | ||
101 | |||
102 | pc110pad_interrupt(0,NULL,NULL); | 97 | pc110pad_interrupt(0,NULL,NULL); |
103 | pc110pad_interrupt(0,NULL,NULL); | 98 | pc110pad_interrupt(0,NULL,NULL); |
104 | pc110pad_interrupt(0,NULL,NULL); | 99 | pc110pad_interrupt(0,NULL,NULL); |
@@ -145,7 +140,7 @@ static int __init pc110pad_init(void) | |||
145 | 140 | ||
146 | pc110pad_dev.absmax[ABS_X] = 0x1ff; | 141 | pc110pad_dev.absmax[ABS_X] = 0x1ff; |
147 | pc110pad_dev.absmax[ABS_Y] = 0x0ff; | 142 | pc110pad_dev.absmax[ABS_Y] = 0x0ff; |
148 | 143 | ||
149 | pc110pad_dev.open = pc110pad_open; | 144 | pc110pad_dev.open = pc110pad_open; |
150 | pc110pad_dev.close = pc110pad_close; | 145 | pc110pad_dev.close = pc110pad_close; |
151 | 146 | ||
@@ -156,17 +151,17 @@ static int __init pc110pad_init(void) | |||
156 | pc110pad_dev.id.product = 0x0001; | 151 | pc110pad_dev.id.product = 0x0001; |
157 | pc110pad_dev.id.version = 0x0100; | 152 | pc110pad_dev.id.version = 0x0100; |
158 | 153 | ||
159 | input_register_device(&pc110pad_dev); | 154 | input_register_device(&pc110pad_dev); |
160 | 155 | ||
161 | printk(KERN_INFO "input: %s at %#x irq %d\n", | 156 | printk(KERN_INFO "input: %s at %#x irq %d\n", |
162 | pc110pad_name, pc110pad_io, pc110pad_irq); | 157 | pc110pad_name, pc110pad_io, pc110pad_irq); |
163 | 158 | ||
164 | return 0; | 159 | return 0; |
165 | } | 160 | } |
166 | 161 | ||
167 | static void __exit pc110pad_exit(void) | 162 | static void __exit pc110pad_exit(void) |
168 | { | 163 | { |
169 | input_unregister_device(&pc110pad_dev); | 164 | input_unregister_device(&pc110pad_dev); |
170 | 165 | ||
171 | outb(PC110PAD_OFF, pc110pad_io + 2); | 166 | outb(PC110PAD_OFF, pc110pad_io + 2); |
172 | 167 | ||
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 019034b21a0b..19785a6c5abd 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "synaptics.h" | 24 | #include "synaptics.h" |
25 | #include "logips2pp.h" | 25 | #include "logips2pp.h" |
26 | #include "alps.h" | 26 | #include "alps.h" |
27 | #include "lifebook.h" | ||
27 | 28 | ||
28 | #define DRIVER_DESC "PS/2 mouse driver" | 29 | #define DRIVER_DESC "PS/2 mouse driver" |
29 | 30 | ||
@@ -31,10 +32,9 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); | |||
31 | MODULE_DESCRIPTION(DRIVER_DESC); | 32 | MODULE_DESCRIPTION(DRIVER_DESC); |
32 | MODULE_LICENSE("GPL"); | 33 | MODULE_LICENSE("GPL"); |
33 | 34 | ||
34 | static unsigned int psmouse_max_proto = -1U; | 35 | static unsigned int psmouse_max_proto = PSMOUSE_AUTO; |
35 | static int psmouse_set_maxproto(const char *val, struct kernel_param *kp); | 36 | static int psmouse_set_maxproto(const char *val, struct kernel_param *kp); |
36 | static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp); | 37 | static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp); |
37 | static char *psmouse_proto_abbrev[] = { NULL, "bare", NULL, NULL, NULL, "imps", "exps", NULL, NULL, NULL }; | ||
38 | #define param_check_proto_abbrev(name, p) __param_check(name, p, unsigned int) | 38 | #define param_check_proto_abbrev(name, p) __param_check(name, p, unsigned int) |
39 | #define param_set_proto_abbrev psmouse_set_maxproto | 39 | #define param_set_proto_abbrev psmouse_set_maxproto |
40 | #define param_get_proto_abbrev psmouse_get_maxproto | 40 | #define param_get_proto_abbrev psmouse_get_maxproto |
@@ -57,6 +57,7 @@ static unsigned int psmouse_resetafter; | |||
57 | module_param_named(resetafter, psmouse_resetafter, uint, 0644); | 57 | module_param_named(resetafter, psmouse_resetafter, uint, 0644); |
58 | MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); | 58 | MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); |
59 | 59 | ||
60 | PSMOUSE_DEFINE_ATTR(protocol); | ||
60 | PSMOUSE_DEFINE_ATTR(rate); | 61 | PSMOUSE_DEFINE_ATTR(rate); |
61 | PSMOUSE_DEFINE_ATTR(resolution); | 62 | PSMOUSE_DEFINE_ATTR(resolution); |
62 | PSMOUSE_DEFINE_ATTR(resetafter); | 63 | PSMOUSE_DEFINE_ATTR(resetafter); |
@@ -67,7 +68,23 @@ __obsolete_setup("psmouse_smartscroll="); | |||
67 | __obsolete_setup("psmouse_resetafter="); | 68 | __obsolete_setup("psmouse_resetafter="); |
68 | __obsolete_setup("psmouse_rate="); | 69 | __obsolete_setup("psmouse_rate="); |
69 | 70 | ||
70 | static char *psmouse_protocols[] = { "None", "PS/2", "PS2++", "ThinkPS/2", "GenPS/2", "ImPS/2", "ImExPS/2", "SynPS/2", "AlpsPS/2" }; | 71 | /* |
72 | * psmouse_sem protects all operations changing state of mouse | ||
73 | * (connecting, disconnecting, changing rate or resolution via | ||
74 | * sysfs). We could use a per-device semaphore but since there | ||
75 | * rarely more than one PS/2 mouse connected and since semaphore | ||
76 | * is taken in "slow" paths it is not worth it. | ||
77 | */ | ||
78 | static DECLARE_MUTEX(psmouse_sem); | ||
79 | |||
80 | struct psmouse_protocol { | ||
81 | enum psmouse_type type; | ||
82 | char *name; | ||
83 | char *alias; | ||
84 | int maxproto; | ||
85 | int (*detect)(struct psmouse *, int); | ||
86 | int (*init)(struct psmouse *); | ||
87 | }; | ||
71 | 88 | ||
72 | /* | 89 | /* |
73 | * psmouse_process_byte() analyzes the PS/2 data stream and reports | 90 | * psmouse_process_byte() analyzes the PS/2 data stream and reports |
@@ -407,12 +424,15 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties) | |||
407 | */ | 424 | */ |
408 | static int ps2bare_detect(struct psmouse *psmouse, int set_properties) | 425 | static int ps2bare_detect(struct psmouse *psmouse, int set_properties) |
409 | { | 426 | { |
410 | if (!psmouse->vendor) psmouse->vendor = "Generic"; | 427 | if (set_properties) { |
411 | if (!psmouse->name) psmouse->name = "Mouse"; | 428 | if (!psmouse->vendor) psmouse->vendor = "Generic"; |
429 | if (!psmouse->name) psmouse->name = "Mouse"; | ||
430 | } | ||
412 | 431 | ||
413 | return 0; | 432 | return 0; |
414 | } | 433 | } |
415 | 434 | ||
435 | |||
416 | /* | 436 | /* |
417 | * psmouse_extensions() probes for any extensions to the basic PS/2 protocol | 437 | * psmouse_extensions() probes for any extensions to the basic PS/2 protocol |
418 | * the mouse may have. | 438 | * the mouse may have. |
@@ -424,6 +444,17 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
424 | int synaptics_hardware = 0; | 444 | int synaptics_hardware = 0; |
425 | 445 | ||
426 | /* | 446 | /* |
447 | * We always check for lifebook because it does not disturb mouse | ||
448 | * (it only checks DMI information). | ||
449 | */ | ||
450 | if (lifebook_detect(psmouse, set_properties) == 0) { | ||
451 | if (max_proto > PSMOUSE_IMEX) { | ||
452 | if (!set_properties || lifebook_init(psmouse) == 0) | ||
453 | return PSMOUSE_LIFEBOOK; | ||
454 | } | ||
455 | } | ||
456 | |||
457 | /* | ||
427 | * Try Kensington ThinkingMouse (we try first, because synaptics probe | 458 | * Try Kensington ThinkingMouse (we try first, because synaptics probe |
428 | * upsets the thinkingmouse). | 459 | * upsets the thinkingmouse). |
429 | */ | 460 | */ |
@@ -506,6 +537,103 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
506 | return PSMOUSE_PS2; | 537 | return PSMOUSE_PS2; |
507 | } | 538 | } |
508 | 539 | ||
540 | static struct psmouse_protocol psmouse_protocols[] = { | ||
541 | { | ||
542 | .type = PSMOUSE_PS2, | ||
543 | .name = "PS/2", | ||
544 | .alias = "bare", | ||
545 | .maxproto = 1, | ||
546 | .detect = ps2bare_detect, | ||
547 | }, | ||
548 | { | ||
549 | .type = PSMOUSE_PS2PP, | ||
550 | .name = "PS2++", | ||
551 | .alias = "logitech", | ||
552 | .detect = ps2pp_init, | ||
553 | }, | ||
554 | { | ||
555 | .type = PSMOUSE_THINKPS, | ||
556 | .name = "ThinkPS/2", | ||
557 | .alias = "thinkps", | ||
558 | .detect = thinking_detect, | ||
559 | }, | ||
560 | { | ||
561 | .type = PSMOUSE_GENPS, | ||
562 | .name = "GenPS/2", | ||
563 | .alias = "genius", | ||
564 | .detect = genius_detect, | ||
565 | }, | ||
566 | { | ||
567 | .type = PSMOUSE_IMPS, | ||
568 | .name = "ImPS/2", | ||
569 | .alias = "imps", | ||
570 | .maxproto = 1, | ||
571 | .detect = intellimouse_detect, | ||
572 | }, | ||
573 | { | ||
574 | .type = PSMOUSE_IMEX, | ||
575 | .name = "ImExPS/2", | ||
576 | .alias = "exps", | ||
577 | .maxproto = 1, | ||
578 | .detect = im_explorer_detect, | ||
579 | }, | ||
580 | { | ||
581 | .type = PSMOUSE_SYNAPTICS, | ||
582 | .name = "SynPS/2", | ||
583 | .alias = "synaptics", | ||
584 | .detect = synaptics_detect, | ||
585 | .init = synaptics_init, | ||
586 | }, | ||
587 | { | ||
588 | .type = PSMOUSE_ALPS, | ||
589 | .name = "AlpsPS/2", | ||
590 | .alias = "alps", | ||
591 | .detect = alps_detect, | ||
592 | .init = alps_init, | ||
593 | }, | ||
594 | { | ||
595 | .type = PSMOUSE_LIFEBOOK, | ||
596 | .name = "LBPS/2", | ||
597 | .alias = "lifebook", | ||
598 | .init = lifebook_init, | ||
599 | }, | ||
600 | { | ||
601 | .type = PSMOUSE_AUTO, | ||
602 | .name = "auto", | ||
603 | .alias = "any", | ||
604 | .maxproto = 1, | ||
605 | }, | ||
606 | }; | ||
607 | |||
608 | static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type) | ||
609 | { | ||
610 | int i; | ||
611 | |||
612 | for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) | ||
613 | if (psmouse_protocols[i].type == type) | ||
614 | return &psmouse_protocols[i]; | ||
615 | |||
616 | WARN_ON(1); | ||
617 | return &psmouse_protocols[0]; | ||
618 | } | ||
619 | |||
620 | static struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len) | ||
621 | { | ||
622 | struct psmouse_protocol *p; | ||
623 | int i; | ||
624 | |||
625 | for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) { | ||
626 | p = &psmouse_protocols[i]; | ||
627 | |||
628 | if ((strlen(p->name) == len && !strncmp(p->name, name, len)) || | ||
629 | (strlen(p->alias) == len && !strncmp(p->alias, name, len))) | ||
630 | return &psmouse_protocols[i]; | ||
631 | } | ||
632 | |||
633 | return NULL; | ||
634 | } | ||
635 | |||
636 | |||
509 | /* | 637 | /* |
510 | * psmouse_probe() probes for a PS/2 mouse. | 638 | * psmouse_probe() probes for a PS/2 mouse. |
511 | */ | 639 | */ |
@@ -653,30 +781,84 @@ static void psmouse_cleanup(struct serio *serio) | |||
653 | 781 | ||
654 | static void psmouse_disconnect(struct serio *serio) | 782 | static void psmouse_disconnect(struct serio *serio) |
655 | { | 783 | { |
656 | struct psmouse *psmouse, *parent; | 784 | struct psmouse *psmouse, *parent = NULL; |
657 | 785 | ||
786 | psmouse = serio_get_drvdata(serio); | ||
787 | |||
788 | device_remove_file(&serio->dev, &psmouse_attr_protocol); | ||
658 | device_remove_file(&serio->dev, &psmouse_attr_rate); | 789 | device_remove_file(&serio->dev, &psmouse_attr_rate); |
659 | device_remove_file(&serio->dev, &psmouse_attr_resolution); | 790 | device_remove_file(&serio->dev, &psmouse_attr_resolution); |
660 | device_remove_file(&serio->dev, &psmouse_attr_resetafter); | 791 | device_remove_file(&serio->dev, &psmouse_attr_resetafter); |
661 | 792 | ||
662 | psmouse = serio_get_drvdata(serio); | 793 | down(&psmouse_sem); |
794 | |||
663 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); | 795 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); |
664 | 796 | ||
665 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { | 797 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { |
666 | parent = serio_get_drvdata(serio->parent); | 798 | parent = serio_get_drvdata(serio->parent); |
667 | if (parent->pt_deactivate) | 799 | psmouse_deactivate(parent); |
668 | parent->pt_deactivate(parent); | ||
669 | } | 800 | } |
670 | 801 | ||
671 | if (psmouse->disconnect) | 802 | if (psmouse->disconnect) |
672 | psmouse->disconnect(psmouse); | 803 | psmouse->disconnect(psmouse); |
673 | 804 | ||
805 | if (parent && parent->pt_deactivate) | ||
806 | parent->pt_deactivate(parent); | ||
807 | |||
674 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); | 808 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); |
675 | 809 | ||
676 | input_unregister_device(&psmouse->dev); | 810 | input_unregister_device(&psmouse->dev); |
677 | serio_close(serio); | 811 | serio_close(serio); |
678 | serio_set_drvdata(serio, NULL); | 812 | serio_set_drvdata(serio, NULL); |
679 | kfree(psmouse); | 813 | kfree(psmouse); |
814 | |||
815 | if (parent) | ||
816 | psmouse_activate(parent); | ||
817 | |||
818 | up(&psmouse_sem); | ||
819 | } | ||
820 | |||
821 | static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) | ||
822 | { | ||
823 | memset(&psmouse->dev, 0, sizeof(struct input_dev)); | ||
824 | |||
825 | init_input_dev(&psmouse->dev); | ||
826 | |||
827 | psmouse->dev.private = psmouse; | ||
828 | psmouse->dev.dev = &psmouse->ps2dev.serio->dev; | ||
829 | |||
830 | psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
831 | psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
832 | psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
833 | |||
834 | psmouse->set_rate = psmouse_set_rate; | ||
835 | psmouse->set_resolution = psmouse_set_resolution; | ||
836 | psmouse->protocol_handler = psmouse_process_byte; | ||
837 | psmouse->pktsize = 3; | ||
838 | |||
839 | if (proto && (proto->detect || proto->init)) { | ||
840 | if (proto->detect && proto->detect(psmouse, 1) < 0) | ||
841 | return -1; | ||
842 | |||
843 | if (proto->init && proto->init(psmouse) < 0) | ||
844 | return -1; | ||
845 | |||
846 | psmouse->type = proto->type; | ||
847 | } | ||
848 | else | ||
849 | psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, 1); | ||
850 | |||
851 | sprintf(psmouse->devname, "%s %s %s", | ||
852 | psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); | ||
853 | |||
854 | psmouse->dev.name = psmouse->devname; | ||
855 | psmouse->dev.phys = psmouse->phys; | ||
856 | psmouse->dev.id.bustype = BUS_I8042; | ||
857 | psmouse->dev.id.vendor = 0x0002; | ||
858 | psmouse->dev.id.product = psmouse->type; | ||
859 | psmouse->dev.id.version = psmouse->model; | ||
860 | |||
861 | return 0; | ||
680 | } | 862 | } |
681 | 863 | ||
682 | /* | 864 | /* |
@@ -688,6 +870,8 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
688 | struct psmouse *psmouse, *parent = NULL; | 870 | struct psmouse *psmouse, *parent = NULL; |
689 | int retval; | 871 | int retval; |
690 | 872 | ||
873 | down(&psmouse_sem); | ||
874 | |||
691 | /* | 875 | /* |
692 | * If this is a pass-through port deactivate parent so the device | 876 | * If this is a pass-through port deactivate parent so the device |
693 | * connected to this port can be successfully identified | 877 | * connected to this port can be successfully identified |
@@ -697,20 +881,14 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
697 | psmouse_deactivate(parent); | 881 | psmouse_deactivate(parent); |
698 | } | 882 | } |
699 | 883 | ||
700 | if (!(psmouse = kmalloc(sizeof(struct psmouse), GFP_KERNEL))) { | 884 | if (!(psmouse = kcalloc(1, sizeof(struct psmouse), GFP_KERNEL))) { |
701 | retval = -ENOMEM; | 885 | retval = -ENOMEM; |
702 | goto out; | 886 | goto out; |
703 | } | 887 | } |
704 | 888 | ||
705 | memset(psmouse, 0, sizeof(struct psmouse)); | ||
706 | |||
707 | ps2_init(&psmouse->ps2dev, serio); | 889 | ps2_init(&psmouse->ps2dev, serio); |
708 | sprintf(psmouse->phys, "%s/input0", serio->phys); | 890 | sprintf(psmouse->phys, "%s/input0", serio->phys); |
709 | psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 891 | |
710 | psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | ||
711 | psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | ||
712 | psmouse->dev.private = psmouse; | ||
713 | psmouse->dev.dev = &serio->dev; | ||
714 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | 892 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); |
715 | 893 | ||
716 | serio_set_drvdata(serio, psmouse); | 894 | serio_set_drvdata(serio, psmouse); |
@@ -734,25 +912,10 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
734 | psmouse->resolution = psmouse_resolution; | 912 | psmouse->resolution = psmouse_resolution; |
735 | psmouse->resetafter = psmouse_resetafter; | 913 | psmouse->resetafter = psmouse_resetafter; |
736 | psmouse->smartscroll = psmouse_smartscroll; | 914 | psmouse->smartscroll = psmouse_smartscroll; |
737 | psmouse->set_rate = psmouse_set_rate; | ||
738 | psmouse->set_resolution = psmouse_set_resolution; | ||
739 | psmouse->protocol_handler = psmouse_process_byte; | ||
740 | psmouse->pktsize = 3; | ||
741 | 915 | ||
742 | psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, 1); | 916 | psmouse_switch_protocol(psmouse, NULL); |
743 | |||
744 | sprintf(psmouse->devname, "%s %s %s", | ||
745 | psmouse_protocols[psmouse->type], psmouse->vendor, psmouse->name); | ||
746 | |||
747 | psmouse->dev.name = psmouse->devname; | ||
748 | psmouse->dev.phys = psmouse->phys; | ||
749 | psmouse->dev.id.bustype = BUS_I8042; | ||
750 | psmouse->dev.id.vendor = 0x0002; | ||
751 | psmouse->dev.id.product = psmouse->type; | ||
752 | psmouse->dev.id.version = psmouse->model; | ||
753 | 917 | ||
754 | input_register_device(&psmouse->dev); | 918 | input_register_device(&psmouse->dev); |
755 | |||
756 | printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys); | 919 | printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys); |
757 | 920 | ||
758 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); | 921 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); |
@@ -762,6 +925,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
762 | if (parent && parent->pt_activate) | 925 | if (parent && parent->pt_activate) |
763 | parent->pt_activate(parent); | 926 | parent->pt_activate(parent); |
764 | 927 | ||
928 | device_create_file(&serio->dev, &psmouse_attr_protocol); | ||
765 | device_create_file(&serio->dev, &psmouse_attr_rate); | 929 | device_create_file(&serio->dev, &psmouse_attr_rate); |
766 | device_create_file(&serio->dev, &psmouse_attr_resolution); | 930 | device_create_file(&serio->dev, &psmouse_attr_resolution); |
767 | device_create_file(&serio->dev, &psmouse_attr_resetafter); | 931 | device_create_file(&serio->dev, &psmouse_attr_resetafter); |
@@ -771,10 +935,11 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
771 | retval = 0; | 935 | retval = 0; |
772 | 936 | ||
773 | out: | 937 | out: |
774 | /* If this is a pass-through port the parent awaits to be activated */ | 938 | /* If this is a pass-through port the parent needs to be re-activated */ |
775 | if (parent) | 939 | if (parent) |
776 | psmouse_activate(parent); | 940 | psmouse_activate(parent); |
777 | 941 | ||
942 | up(&psmouse_sem); | ||
778 | return retval; | 943 | return retval; |
779 | } | 944 | } |
780 | 945 | ||
@@ -791,6 +956,8 @@ static int psmouse_reconnect(struct serio *serio) | |||
791 | return -1; | 956 | return -1; |
792 | } | 957 | } |
793 | 958 | ||
959 | down(&psmouse_sem); | ||
960 | |||
794 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { | 961 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { |
795 | parent = serio_get_drvdata(serio->parent); | 962 | parent = serio_get_drvdata(serio->parent); |
796 | psmouse_deactivate(parent); | 963 | psmouse_deactivate(parent); |
@@ -823,6 +990,7 @@ out: | |||
823 | if (parent) | 990 | if (parent) |
824 | psmouse_activate(parent); | 991 | psmouse_activate(parent); |
825 | 992 | ||
993 | up(&psmouse_sem); | ||
826 | return rc; | 994 | return rc; |
827 | } | 995 | } |
828 | 996 | ||
@@ -893,26 +1061,109 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun | |||
893 | 1061 | ||
894 | if (serio->drv != &psmouse_drv) { | 1062 | if (serio->drv != &psmouse_drv) { |
895 | retval = -ENODEV; | 1063 | retval = -ENODEV; |
896 | goto out; | 1064 | goto out_unpin; |
1065 | } | ||
1066 | |||
1067 | retval = down_interruptible(&psmouse_sem); | ||
1068 | if (retval) | ||
1069 | goto out_unpin; | ||
1070 | |||
1071 | if (psmouse->state == PSMOUSE_IGNORE) { | ||
1072 | retval = -ENODEV; | ||
1073 | goto out_up; | ||
897 | } | 1074 | } |
898 | 1075 | ||
899 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { | 1076 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { |
900 | parent = serio_get_drvdata(serio->parent); | 1077 | parent = serio_get_drvdata(serio->parent); |
901 | psmouse_deactivate(parent); | 1078 | psmouse_deactivate(parent); |
902 | } | 1079 | } |
1080 | |||
903 | psmouse_deactivate(psmouse); | 1081 | psmouse_deactivate(psmouse); |
904 | 1082 | ||
905 | retval = handler(psmouse, buf, count); | 1083 | retval = handler(psmouse, buf, count); |
906 | 1084 | ||
907 | psmouse_activate(psmouse); | 1085 | if (retval != -ENODEV) |
1086 | psmouse_activate(psmouse); | ||
1087 | |||
908 | if (parent) | 1088 | if (parent) |
909 | psmouse_activate(parent); | 1089 | psmouse_activate(parent); |
910 | 1090 | ||
911 | out: | 1091 | out_up: |
1092 | up(&psmouse_sem); | ||
1093 | out_unpin: | ||
912 | serio_unpin_driver(serio); | 1094 | serio_unpin_driver(serio); |
913 | return retval; | 1095 | return retval; |
914 | } | 1096 | } |
915 | 1097 | ||
1098 | static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, char *buf) | ||
1099 | { | ||
1100 | return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); | ||
1101 | } | ||
1102 | |||
1103 | static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *buf, size_t count) | ||
1104 | { | ||
1105 | struct serio *serio = psmouse->ps2dev.serio; | ||
1106 | struct psmouse *parent = NULL; | ||
1107 | struct psmouse_protocol *proto; | ||
1108 | int retry = 0; | ||
1109 | |||
1110 | if (!(proto = psmouse_protocol_by_name(buf, count))) | ||
1111 | return -EINVAL; | ||
1112 | |||
1113 | if (psmouse->type == proto->type) | ||
1114 | return count; | ||
1115 | |||
1116 | while (serio->child) { | ||
1117 | if (++retry > 3) { | ||
1118 | printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); | ||
1119 | return -EIO; | ||
1120 | } | ||
1121 | |||
1122 | up(&psmouse_sem); | ||
1123 | serio_unpin_driver(serio); | ||
1124 | serio_unregister_child_port(serio); | ||
1125 | serio_pin_driver_uninterruptible(serio); | ||
1126 | down(&psmouse_sem); | ||
1127 | |||
1128 | if (serio->drv != &psmouse_drv) | ||
1129 | return -ENODEV; | ||
1130 | |||
1131 | if (psmouse->type == proto->type) | ||
1132 | return count; /* switched by other thread */ | ||
1133 | } | ||
1134 | |||
1135 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { | ||
1136 | parent = serio_get_drvdata(serio->parent); | ||
1137 | if (parent->pt_deactivate) | ||
1138 | parent->pt_deactivate(parent); | ||
1139 | } | ||
1140 | |||
1141 | if (psmouse->disconnect) | ||
1142 | psmouse->disconnect(psmouse); | ||
1143 | |||
1144 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); | ||
1145 | input_unregister_device(&psmouse->dev); | ||
1146 | |||
1147 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | ||
1148 | |||
1149 | if (psmouse_switch_protocol(psmouse, proto) < 0) { | ||
1150 | psmouse_reset(psmouse); | ||
1151 | /* default to PSMOUSE_PS2 */ | ||
1152 | psmouse_switch_protocol(psmouse, &psmouse_protocols[0]); | ||
1153 | } | ||
1154 | |||
1155 | psmouse_initialize(psmouse); | ||
1156 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); | ||
1157 | |||
1158 | input_register_device(&psmouse->dev); | ||
1159 | printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys); | ||
1160 | |||
1161 | if (parent && parent->pt_activate) | ||
1162 | parent->pt_activate(parent); | ||
1163 | |||
1164 | return count; | ||
1165 | } | ||
1166 | |||
916 | static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf) | 1167 | static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf) |
917 | { | 1168 | { |
918 | return sprintf(buf, "%d\n", psmouse->rate); | 1169 | return sprintf(buf, "%d\n", psmouse->rate); |
@@ -969,34 +1220,26 @@ static ssize_t psmouse_attr_set_resetafter(struct psmouse *psmouse, const char * | |||
969 | 1220 | ||
970 | static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) | 1221 | static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) |
971 | { | 1222 | { |
972 | int i; | 1223 | struct psmouse_protocol *proto; |
973 | 1224 | ||
974 | if (!val) | 1225 | if (!val) |
975 | return -EINVAL; | 1226 | return -EINVAL; |
976 | 1227 | ||
977 | if (!strncmp(val, "any", 3)) { | 1228 | proto = psmouse_protocol_by_name(val, strlen(val)); |
978 | *((unsigned int *)kp->arg) = -1U; | ||
979 | return 0; | ||
980 | } | ||
981 | 1229 | ||
982 | for (i = 0; i < ARRAY_SIZE(psmouse_proto_abbrev); i++) { | 1230 | if (!proto || !proto->maxproto) |
983 | if (!psmouse_proto_abbrev[i]) | 1231 | return -EINVAL; |
984 | continue; | ||
985 | 1232 | ||
986 | if (!strncmp(val, psmouse_proto_abbrev[i], strlen(psmouse_proto_abbrev[i]))) { | 1233 | *((unsigned int *)kp->arg) = proto->type; |
987 | *((unsigned int *)kp->arg) = i; | ||
988 | return 0; | ||
989 | } | ||
990 | } | ||
991 | 1234 | ||
992 | return -EINVAL; \ | 1235 | return 0; \ |
993 | } | 1236 | } |
994 | 1237 | ||
995 | static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) | 1238 | static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) |
996 | { | 1239 | { |
997 | return sprintf(buffer, "%s\n", | 1240 | int type = *((unsigned int *)kp->arg); |
998 | psmouse_max_proto < ARRAY_SIZE(psmouse_proto_abbrev) ? | 1241 | |
999 | psmouse_proto_abbrev[psmouse_max_proto] : "any"); | 1242 | return sprintf(buffer, "%s\n", psmouse_protocol_by_type(type)->name); |
1000 | } | 1243 | } |
1001 | 1244 | ||
1002 | static int __init psmouse_init(void) | 1245 | static int __init psmouse_init(void) |
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 79e17a0c4664..86691cf43433 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h | |||
@@ -77,6 +77,8 @@ enum psmouse_type { | |||
77 | PSMOUSE_IMEX, | 77 | PSMOUSE_IMEX, |
78 | PSMOUSE_SYNAPTICS, | 78 | PSMOUSE_SYNAPTICS, |
79 | PSMOUSE_ALPS, | 79 | PSMOUSE_ALPS, |
80 | PSMOUSE_LIFEBOOK, | ||
81 | PSMOUSE_AUTO /* This one should always be last */ | ||
80 | }; | 82 | }; |
81 | 83 | ||
82 | int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); | 84 | int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); |
@@ -99,7 +101,7 @@ static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute | |||
99 | { \ | 101 | { \ |
100 | return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ | 102 | return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ |
101 | } \ | 103 | } \ |
102 | static struct device_attribute psmouse_attr_##_name = \ | 104 | static struct device_attribute psmouse_attr_##_name = \ |
103 | __ATTR(_name, S_IWUSR | S_IRUGO, \ | 105 | __ATTR(_name, S_IWUSR | S_IRUGO, \ |
104 | psmouse_do_show_##_name, psmouse_do_set_##_name); | 106 | psmouse_do_show_##_name, psmouse_do_set_##_name); |
105 | 107 | ||
diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c index 7280f68afcee..8fe1212b8fd7 100644 --- a/drivers/input/mouse/rpcmouse.c +++ b/drivers/input/mouse/rpcmouse.c | |||
@@ -59,7 +59,7 @@ static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs) | |||
59 | b = (short) (__raw_readl(0xe0310000) ^ 0x70); | 59 | b = (short) (__raw_readl(0xe0310000) ^ 0x70); |
60 | 60 | ||
61 | dx = x - rpcmouse_lastx; | 61 | dx = x - rpcmouse_lastx; |
62 | dy = y - rpcmouse_lasty; | 62 | dy = y - rpcmouse_lasty; |
63 | 63 | ||
64 | rpcmouse_lastx = x; | 64 | rpcmouse_lastx = x; |
65 | rpcmouse_lasty = y; | 65 | rpcmouse_lasty = y; |
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index b2cb101c8110..f024be9b44d2 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for DEC VSXXX-AA mouse (hockey-puck mouse, ball or two rollers) | 2 | * Driver for DEC VSXXX-AA mouse (hockey-puck mouse, ball or two rollers) |
3 | * DEC VSXXX-GA mouse (rectangular mouse, with ball) | 3 | * DEC VSXXX-GA mouse (rectangular mouse, with ball) |
4 | * DEC VSXXX-AB tablet (digitizer with hair cross or stylus) | 4 | * DEC VSXXX-AB tablet (digitizer with hair cross or stylus) |
5 | * | 5 | * |
6 | * Copyright (C) 2003-2004 by Jan-Benedict Glaw <jbglaw@lug-owl.de> | 6 | * Copyright (C) 2003-2004 by Jan-Benedict Glaw <jbglaw@lug-owl.de> |
7 | * | 7 | * |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 062848ac7e6b..c6194a9dd174 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -220,6 +220,7 @@ static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_h | |||
220 | struct mousedev_list *list; | 220 | struct mousedev_list *list; |
221 | struct mousedev_motion *p; | 221 | struct mousedev_motion *p; |
222 | unsigned long flags; | 222 | unsigned long flags; |
223 | int wake_readers = 0; | ||
223 | 224 | ||
224 | list_for_each_entry(list, &mousedev->list, node) { | 225 | list_for_each_entry(list, &mousedev->list, node) { |
225 | spin_lock_irqsave(&list->packet_lock, flags); | 226 | spin_lock_irqsave(&list->packet_lock, flags); |
@@ -255,11 +256,14 @@ static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_h | |||
255 | 256 | ||
256 | spin_unlock_irqrestore(&list->packet_lock, flags); | 257 | spin_unlock_irqrestore(&list->packet_lock, flags); |
257 | 258 | ||
258 | if (list->ready) | 259 | if (list->ready) { |
259 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 260 | kill_fasync(&list->fasync, SIGIO, POLL_IN); |
261 | wake_readers = 1; | ||
262 | } | ||
260 | } | 263 | } |
261 | 264 | ||
262 | wake_up_interruptible(&mousedev->wait); | 265 | if (wake_readers) |
266 | wake_up_interruptible(&mousedev->wait); | ||
263 | } | 267 | } |
264 | 268 | ||
265 | static void mousedev_touchpad_touch(struct mousedev *mousedev, int value) | 269 | static void mousedev_touchpad_touch(struct mousedev *mousedev, int value) |
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c index c978657068c5..d4c990f7c85e 100644 --- a/drivers/input/serio/libps2.c +++ b/drivers/input/serio/libps2.c | |||
@@ -29,6 +29,7 @@ MODULE_LICENSE("GPL"); | |||
29 | 29 | ||
30 | EXPORT_SYMBOL(ps2_init); | 30 | EXPORT_SYMBOL(ps2_init); |
31 | EXPORT_SYMBOL(ps2_sendbyte); | 31 | EXPORT_SYMBOL(ps2_sendbyte); |
32 | EXPORT_SYMBOL(ps2_drain); | ||
32 | EXPORT_SYMBOL(ps2_command); | 33 | EXPORT_SYMBOL(ps2_command); |
33 | EXPORT_SYMBOL(ps2_schedule_command); | 34 | EXPORT_SYMBOL(ps2_schedule_command); |
34 | EXPORT_SYMBOL(ps2_handle_ack); | 35 | EXPORT_SYMBOL(ps2_handle_ack); |
@@ -45,11 +46,11 @@ struct ps2work { | |||
45 | 46 | ||
46 | 47 | ||
47 | /* | 48 | /* |
48 | * ps2_sendbyte() sends a byte to the mouse, and waits for acknowledge. | 49 | * ps2_sendbyte() sends a byte to the device and waits for acknowledge. |
49 | * It doesn't handle retransmission, though it could - because when there would | 50 | * It doesn't handle retransmission, though it could - because if there |
50 | * be need for retransmissions, the mouse has to be replaced anyway. | 51 | * is a need for retransmissions device has to be replaced anyway. |
51 | * | 52 | * |
52 | * ps2_sendbyte() can only be called from a process context | 53 | * ps2_sendbyte() can only be called from a process context. |
53 | */ | 54 | */ |
54 | 55 | ||
55 | int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout) | 56 | int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout) |
@@ -72,6 +73,91 @@ int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout) | |||
72 | } | 73 | } |
73 | 74 | ||
74 | /* | 75 | /* |
76 | * ps2_drain() waits for device to transmit requested number of bytes | ||
77 | * and discards them. | ||
78 | */ | ||
79 | |||
80 | void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout) | ||
81 | { | ||
82 | if (maxbytes > sizeof(ps2dev->cmdbuf)) { | ||
83 | WARN_ON(1); | ||
84 | maxbytes = sizeof(ps2dev->cmdbuf); | ||
85 | } | ||
86 | |||
87 | down(&ps2dev->cmd_sem); | ||
88 | |||
89 | serio_pause_rx(ps2dev->serio); | ||
90 | ps2dev->flags = PS2_FLAG_CMD; | ||
91 | ps2dev->cmdcnt = maxbytes; | ||
92 | serio_continue_rx(ps2dev->serio); | ||
93 | |||
94 | wait_event_timeout(ps2dev->wait, | ||
95 | !(ps2dev->flags & PS2_FLAG_CMD), | ||
96 | msecs_to_jiffies(timeout)); | ||
97 | up(&ps2dev->cmd_sem); | ||
98 | } | ||
99 | |||
100 | /* | ||
101 | * ps2_is_keyboard_id() checks received ID byte against the list of | ||
102 | * known keyboard IDs. | ||
103 | */ | ||
104 | |||
105 | static inline int ps2_is_keyboard_id(char id_byte) | ||
106 | { | ||
107 | static char keyboard_ids[] = { | ||
108 | 0xab, /* Regular keyboards */ | ||
109 | 0xac, /* NCD Sun keyboard */ | ||
110 | 0x2b, /* Trust keyboard, translated */ | ||
111 | 0x5d, /* Trust keyboard */ | ||
112 | 0x60, /* NMB SGI keyboard, translated */ | ||
113 | 0x47, /* NMB SGI keyboard */ | ||
114 | }; | ||
115 | |||
116 | return memchr(keyboard_ids, id_byte, sizeof(keyboard_ids)) != NULL; | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * ps2_adjust_timeout() is called after receiving 1st byte of command | ||
121 | * response and tries to reduce remaining timeout to speed up command | ||
122 | * completion. | ||
123 | */ | ||
124 | |||
125 | static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout) | ||
126 | { | ||
127 | switch (command) { | ||
128 | case PS2_CMD_RESET_BAT: | ||
129 | /* | ||
130 | * Device has sent the first response byte after | ||
131 | * reset command, reset is thus done, so we can | ||
132 | * shorten the timeout. | ||
133 | * The next byte will come soon (keyboard) or not | ||
134 | * at all (mouse). | ||
135 | */ | ||
136 | if (timeout > msecs_to_jiffies(100)) | ||
137 | timeout = msecs_to_jiffies(100); | ||
138 | break; | ||
139 | |||
140 | case PS2_CMD_GETID: | ||
141 | /* | ||
142 | * If device behind the port is not a keyboard there | ||
143 | * won't be 2nd byte of ID response. | ||
144 | */ | ||
145 | if (!ps2_is_keyboard_id(ps2dev->cmdbuf[1])) { | ||
146 | serio_pause_rx(ps2dev->serio); | ||
147 | ps2dev->flags = ps2dev->cmdcnt = 0; | ||
148 | serio_continue_rx(ps2dev->serio); | ||
149 | timeout = 0; | ||
150 | } | ||
151 | break; | ||
152 | |||
153 | default: | ||
154 | break; | ||
155 | } | ||
156 | |||
157 | return timeout; | ||
158 | } | ||
159 | |||
160 | /* | ||
75 | * ps2_command() sends a command and its parameters to the mouse, | 161 | * ps2_command() sends a command and its parameters to the mouse, |
76 | * then waits for the response and puts it in the param array. | 162 | * then waits for the response and puts it in the param array. |
77 | * | 163 | * |
@@ -86,6 +172,11 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command) | |||
86 | int rc = -1; | 172 | int rc = -1; |
87 | int i; | 173 | int i; |
88 | 174 | ||
175 | if (receive > sizeof(ps2dev->cmdbuf)) { | ||
176 | WARN_ON(1); | ||
177 | return -1; | ||
178 | } | ||
179 | |||
89 | down(&ps2dev->cmd_sem); | 180 | down(&ps2dev->cmd_sem); |
90 | 181 | ||
91 | serio_pause_rx(ps2dev->serio); | 182 | serio_pause_rx(ps2dev->serio); |
@@ -101,10 +192,9 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command) | |||
101 | * ACKing the reset command, and so it can take a long | 192 | * ACKing the reset command, and so it can take a long |
102 | * time before the ACK arrrives. | 193 | * time before the ACK arrrives. |
103 | */ | 194 | */ |
104 | if (command & 0xff) | 195 | if (ps2_sendbyte(ps2dev, command & 0xff, |
105 | if (ps2_sendbyte(ps2dev, command & 0xff, | 196 | command == PS2_CMD_RESET_BAT ? 1000 : 200)) |
106 | command == PS2_CMD_RESET_BAT ? 1000 : 200)) | 197 | goto out; |
107 | goto out; | ||
108 | 198 | ||
109 | for (i = 0; i < send; i++) | 199 | for (i = 0; i < send; i++) |
110 | if (ps2_sendbyte(ps2dev, param[i], 200)) | 200 | if (ps2_sendbyte(ps2dev, param[i], 200)) |
@@ -120,33 +210,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command) | |||
120 | 210 | ||
121 | if (ps2dev->cmdcnt && timeout > 0) { | 211 | if (ps2dev->cmdcnt && timeout > 0) { |
122 | 212 | ||
123 | if (command == PS2_CMD_RESET_BAT && timeout > msecs_to_jiffies(100)) { | 213 | timeout = ps2_adjust_timeout(ps2dev, command, timeout); |
124 | /* | ||
125 | * Device has sent the first response byte | ||
126 | * after a reset command, reset is thus done, | ||
127 | * shorten the timeout. The next byte will come | ||
128 | * soon (keyboard) or not at all (mouse). | ||
129 | */ | ||
130 | timeout = msecs_to_jiffies(100); | ||
131 | } | ||
132 | |||
133 | if (command == PS2_CMD_GETID && | ||
134 | ps2dev->cmdbuf[receive - 1] != 0xab && /* Regular keyboards */ | ||
135 | ps2dev->cmdbuf[receive - 1] != 0xac && /* NCD Sun keyboard */ | ||
136 | ps2dev->cmdbuf[receive - 1] != 0x2b && /* Trust keyboard, translated */ | ||
137 | ps2dev->cmdbuf[receive - 1] != 0x5d && /* Trust keyboard */ | ||
138 | ps2dev->cmdbuf[receive - 1] != 0x60 && /* NMB SGI keyboard, translated */ | ||
139 | ps2dev->cmdbuf[receive - 1] != 0x47) { /* NMB SGI keyboard */ | ||
140 | /* | ||
141 | * Device behind the port is not a keyboard | ||
142 | * so we don't need to wait for the 2nd byte | ||
143 | * of ID response. | ||
144 | */ | ||
145 | serio_pause_rx(ps2dev->serio); | ||
146 | ps2dev->flags = ps2dev->cmdcnt = 0; | ||
147 | serio_continue_rx(ps2dev->serio); | ||
148 | } | ||
149 | |||
150 | wait_event_timeout(ps2dev->wait, | 214 | wait_event_timeout(ps2dev->wait, |
151 | !(ps2dev->flags & PS2_FLAG_CMD), timeout); | 215 | !(ps2dev->flags & PS2_FLAG_CMD), timeout); |
152 | } | 216 | } |
@@ -160,7 +224,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command) | |||
160 | 224 | ||
161 | rc = 0; | 225 | rc = 0; |
162 | 226 | ||
163 | out: | 227 | out: |
164 | serio_pause_rx(ps2dev->serio); | 228 | serio_pause_rx(ps2dev->serio); |
165 | ps2dev->flags = 0; | 229 | ps2dev->flags = 0; |
166 | serio_continue_rx(ps2dev->serio); | 230 | serio_continue_rx(ps2dev->serio); |
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 546ce599334e..3cdc9cab688d 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c | |||
@@ -226,7 +226,7 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) | |||
226 | input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); | 226 | input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); |
227 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0); | 227 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0); |
228 | break; | 228 | break; |
229 | 229 | ||
230 | case 1: /* 6-byte protocol */ | 230 | case 1: /* 6-byte protocol */ |
231 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0); | 231 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0); |
232 | 232 | ||
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c index acb9137a0226..bcfa1e36f957 100644 --- a/drivers/input/touchscreen/h3600_ts_input.c +++ b/drivers/input/touchscreen/h3600_ts_input.c | |||
@@ -89,9 +89,9 @@ MODULE_LICENSE("GPL"); | |||
89 | #define H3600_SCANCODE_Q 4 /* 4 -> Q button */ | 89 | #define H3600_SCANCODE_Q 4 /* 4 -> Q button */ |
90 | #define H3600_SCANCODE_START 5 /* 5 -> start menu */ | 90 | #define H3600_SCANCODE_START 5 /* 5 -> start menu */ |
91 | #define H3600_SCANCODE_UP 6 /* 6 -> up */ | 91 | #define H3600_SCANCODE_UP 6 /* 6 -> up */ |
92 | #define H3600_SCANCODE_RIGHT 7 /* 7 -> right */ | 92 | #define H3600_SCANCODE_RIGHT 7 /* 7 -> right */ |
93 | #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ | 93 | #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ |
94 | #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ | 94 | #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ |
95 | 95 | ||
96 | static char *h3600_name = "H3600 TouchScreen"; | 96 | static char *h3600_name = "H3600 TouchScreen"; |
97 | 97 | ||
@@ -113,7 +113,7 @@ struct h3600_dev { | |||
113 | 113 | ||
114 | static irqreturn_t action_button_handler(int irq, void *dev_id, struct pt_regs *regs) | 114 | static irqreturn_t action_button_handler(int irq, void *dev_id, struct pt_regs *regs) |
115 | { | 115 | { |
116 | int down = (GPLR & GPIO_BITSY_ACTION_BUTTON) ? 0 : 1; | 116 | int down = (GPLR & GPIO_BITSY_ACTION_BUTTON) ? 0 : 1; |
117 | struct input_dev *dev = (struct input_dev *) dev_id; | 117 | struct input_dev *dev = (struct input_dev *) dev_id; |
118 | 118 | ||
119 | input_regs(dev, regs); | 119 | input_regs(dev, regs); |
@@ -125,7 +125,7 @@ static irqreturn_t action_button_handler(int irq, void *dev_id, struct pt_regs * | |||
125 | 125 | ||
126 | static irqreturn_t npower_button_handler(int irq, void *dev_id, struct pt_regs *regs) | 126 | static irqreturn_t npower_button_handler(int irq, void *dev_id, struct pt_regs *regs) |
127 | { | 127 | { |
128 | int down = (GPLR & GPIO_BITSY_NPOWER_BUTTON) ? 0 : 1; | 128 | int down = (GPLR & GPIO_BITSY_NPOWER_BUTTON) ? 0 : 1; |
129 | struct input_dev *dev = (struct input_dev *) dev_id; | 129 | struct input_dev *dev = (struct input_dev *) dev_id; |
130 | 130 | ||
131 | /* | 131 | /* |
@@ -145,8 +145,8 @@ static irqreturn_t npower_button_handler(int irq, void *dev_id, struct pt_regs * | |||
145 | static int flite_brightness = 25; | 145 | static int flite_brightness = 25; |
146 | 146 | ||
147 | enum flite_pwr { | 147 | enum flite_pwr { |
148 | FLITE_PWR_OFF = 0, | 148 | FLITE_PWR_OFF = 0, |
149 | FLITE_PWR_ON = 1 | 149 | FLITE_PWR_ON = 1 |
150 | }; | 150 | }; |
151 | 151 | ||
152 | /* | 152 | /* |
@@ -157,9 +157,9 @@ unsigned int h3600_flite_power(struct input_dev *dev, enum flite_pwr pwr) | |||
157 | struct h3600_dev *ts = dev->private; | 157 | struct h3600_dev *ts = dev->private; |
158 | 158 | ||
159 | /* Must be in this order */ | 159 | /* Must be in this order */ |
160 | ts->serio->write(ts->serio, 1); | 160 | ts->serio->write(ts->serio, 1); |
161 | ts->serio->write(ts->serio, pwr); | 161 | ts->serio->write(ts->serio, pwr); |
162 | ts->serio->write(ts->serio, brightness); | 162 | ts->serio->write(ts->serio, brightness); |
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
165 | 165 | ||
@@ -169,26 +169,26 @@ static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req, | |||
169 | { | 169 | { |
170 | struct input_dev *dev = (struct input_dev *) data; | 170 | struct input_dev *dev = (struct input_dev *) data; |
171 | 171 | ||
172 | switch (req) { | 172 | switch (req) { |
173 | case PM_SUSPEND: /* enter D1-D3 */ | 173 | case PM_SUSPEND: /* enter D1-D3 */ |
174 | suspended = 1; | 174 | suspended = 1; |
175 | h3600_flite_power(dev, FLITE_PWR_OFF); | 175 | h3600_flite_power(dev, FLITE_PWR_OFF); |
176 | break; | 176 | break; |
177 | case PM_BLANK: | 177 | case PM_BLANK: |
178 | if (!suspended) | 178 | if (!suspended) |
179 | h3600_flite_power(dev, FLITE_PWR_OFF); | 179 | h3600_flite_power(dev, FLITE_PWR_OFF); |
180 | break; | 180 | break; |
181 | case PM_RESUME: /* enter D0 */ | 181 | case PM_RESUME: /* enter D0 */ |
182 | /* same as unblank */ | 182 | /* same as unblank */ |
183 | case PM_UNBLANK: | 183 | case PM_UNBLANK: |
184 | if (suspended) { | 184 | if (suspended) { |
185 | //initSerial(); | 185 | //initSerial(); |
186 | suspended = 0; | 186 | suspended = 0; |
187 | } | 187 | } |
188 | h3600_flite_power(dev, FLITE_PWR_ON); | 188 | h3600_flite_power(dev, FLITE_PWR_ON); |
189 | break; | 189 | break; |
190 | } | 190 | } |
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | #endif | 193 | #endif |
194 | 194 | ||
@@ -199,25 +199,25 @@ static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req, | |||
199 | */ | 199 | */ |
200 | static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | 200 | static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) |
201 | { | 201 | { |
202 | struct input_dev *dev = &ts->dev; | 202 | struct input_dev *dev = &ts->dev; |
203 | static int touched = 0; | 203 | static int touched = 0; |
204 | int key, down = 0; | 204 | int key, down = 0; |
205 | 205 | ||
206 | input_regs(dev, regs); | 206 | input_regs(dev, regs); |
207 | 207 | ||
208 | switch (ts->event) { | 208 | switch (ts->event) { |
209 | /* | 209 | /* |
210 | Buttons - returned as a single byte | 210 | Buttons - returned as a single byte |
211 | 7 6 5 4 3 2 1 0 | 211 | 7 6 5 4 3 2 1 0 |
212 | S x x x N N N N | 212 | S x x x N N N N |
213 | 213 | ||
214 | S switch state ( 0=pressed 1=released) | 214 | S switch state ( 0=pressed 1=released) |
215 | x Unused. | 215 | x Unused. |
216 | NNNN switch number 0-15 | 216 | NNNN switch number 0-15 |
217 | 217 | ||
218 | Note: This is true for non interrupt generated key events. | 218 | Note: This is true for non interrupt generated key events. |
219 | */ | 219 | */ |
220 | case KEYBD_ID: | 220 | case KEYBD_ID: |
221 | down = (ts->buf[0] & 0x80) ? 0 : 1; | 221 | down = (ts->buf[0] & 0x80) ? 0 : 1; |
222 | 222 | ||
223 | switch (ts->buf[0] & 0x7f) { | 223 | switch (ts->buf[0] & 0x7f) { |
@@ -229,40 +229,40 @@ static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | |||
229 | break; | 229 | break; |
230 | case H3600_SCANCODE_CONTACTS: | 230 | case H3600_SCANCODE_CONTACTS: |
231 | key = KEY_PROG2; | 231 | key = KEY_PROG2; |
232 | break; | 232 | break; |
233 | case H3600_SCANCODE_Q: | 233 | case H3600_SCANCODE_Q: |
234 | key = KEY_Q; | 234 | key = KEY_Q; |
235 | break; | 235 | break; |
236 | case H3600_SCANCODE_START: | 236 | case H3600_SCANCODE_START: |
237 | key = KEY_PROG3; | 237 | key = KEY_PROG3; |
238 | break; | 238 | break; |
239 | case H3600_SCANCODE_UP: | 239 | case H3600_SCANCODE_UP: |
240 | key = KEY_UP; | 240 | key = KEY_UP; |
241 | break; | 241 | break; |
242 | case H3600_SCANCODE_RIGHT: | 242 | case H3600_SCANCODE_RIGHT: |
243 | key = KEY_RIGHT; | 243 | key = KEY_RIGHT; |
244 | break; | 244 | break; |
245 | case H3600_SCANCODE_LEFT: | 245 | case H3600_SCANCODE_LEFT: |
246 | key = KEY_LEFT; | 246 | key = KEY_LEFT; |
247 | break; | 247 | break; |
248 | case H3600_SCANCODE_DOWN: | 248 | case H3600_SCANCODE_DOWN: |
249 | key = KEY_DOWN; | 249 | key = KEY_DOWN; |
250 | break; | 250 | break; |
251 | default: | 251 | default: |
252 | key = 0; | 252 | key = 0; |
253 | } | 253 | } |
254 | if (key) | 254 | if (key) |
255 | input_report_key(dev, key, down); | 255 | input_report_key(dev, key, down); |
256 | break; | 256 | break; |
257 | /* | 257 | /* |
258 | * Native touchscreen event data is formatted as shown below:- | 258 | * Native touchscreen event data is formatted as shown below:- |
259 | * | 259 | * |
260 | * +-------+-------+-------+-------+ | 260 | * +-------+-------+-------+-------+ |
261 | * | Xmsb | Xlsb | Ymsb | Ylsb | | 261 | * | Xmsb | Xlsb | Ymsb | Ylsb | |
262 | * +-------+-------+-------+-------+ | 262 | * +-------+-------+-------+-------+ |
263 | * byte 0 1 2 3 | 263 | * byte 0 1 2 3 |
264 | */ | 264 | */ |
265 | case TOUCHS_ID: | 265 | case TOUCHS_ID: |
266 | if (!touched) { | 266 | if (!touched) { |
267 | input_report_key(dev, BTN_TOUCH, 1); | 267 | input_report_key(dev, BTN_TOUCH, 1); |
268 | touched = 1; | 268 | touched = 1; |
@@ -272,19 +272,19 @@ static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | |||
272 | unsigned short x, y; | 272 | unsigned short x, y; |
273 | 273 | ||
274 | x = ts->buf[0]; x <<= 8; x += ts->buf[1]; | 274 | x = ts->buf[0]; x <<= 8; x += ts->buf[1]; |
275 | y = ts->buf[2]; y <<= 8; y += ts->buf[3]; | 275 | y = ts->buf[2]; y <<= 8; y += ts->buf[3]; |
276 | 276 | ||
277 | input_report_abs(dev, ABS_X, x); | 277 | input_report_abs(dev, ABS_X, x); |
278 | input_report_abs(dev, ABS_Y, y); | 278 | input_report_abs(dev, ABS_Y, y); |
279 | } else { | 279 | } else { |
280 | input_report_key(dev, BTN_TOUCH, 0); | 280 | input_report_key(dev, BTN_TOUCH, 0); |
281 | touched = 0; | 281 | touched = 0; |
282 | } | 282 | } |
283 | break; | 283 | break; |
284 | default: | 284 | default: |
285 | /* Send a non input event elsewhere */ | 285 | /* Send a non input event elsewhere */ |
286 | break; | 286 | break; |
287 | } | 287 | } |
288 | 288 | ||
289 | input_sync(dev); | 289 | input_sync(dev); |
290 | } | 290 | } |
@@ -293,7 +293,7 @@ static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | |||
293 | * h3600ts_event() handles events from the input module. | 293 | * h3600ts_event() handles events from the input module. |
294 | */ | 294 | */ |
295 | static int h3600ts_event(struct input_dev *dev, unsigned int type, | 295 | static int h3600ts_event(struct input_dev *dev, unsigned int type, |
296 | unsigned int code, int value) | 296 | unsigned int code, int value) |
297 | { | 297 | { |
298 | struct h3600_dev *ts = dev->private; | 298 | struct h3600_dev *ts = dev->private; |
299 | 299 | ||
@@ -332,41 +332,41 @@ static int state; | |||
332 | static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data, | 332 | static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data, |
333 | unsigned int flags, struct pt_regs *regs) | 333 | unsigned int flags, struct pt_regs *regs) |
334 | { | 334 | { |
335 | struct h3600_dev *ts = serio_get_drvdata(serio); | 335 | struct h3600_dev *ts = serio_get_drvdata(serio); |
336 | 336 | ||
337 | /* | 337 | /* |
338 | * We have a new frame coming in. | 338 | * We have a new frame coming in. |
339 | */ | 339 | */ |
340 | switch (state) { | 340 | switch (state) { |
341 | case STATE_SOF: | 341 | case STATE_SOF: |
342 | if (data == CHAR_SOF) | 342 | if (data == CHAR_SOF) |
343 | state = STATE_ID; | 343 | state = STATE_ID; |
344 | break; | 344 | break; |
345 | case STATE_ID: | 345 | case STATE_ID: |
346 | ts->event = (data & 0xf0) >> 4; | 346 | ts->event = (data & 0xf0) >> 4; |
347 | ts->len = (data & 0xf); | 347 | ts->len = (data & 0xf); |
348 | ts->idx = 0; | 348 | ts->idx = 0; |
349 | if (ts->event >= MAX_ID) { | 349 | if (ts->event >= MAX_ID) { |
350 | state = STATE_SOF; | 350 | state = STATE_SOF; |
351 | break; | 351 | break; |
352 | } | 352 | } |
353 | ts->chksum = data; | 353 | ts->chksum = data; |
354 | state = (ts->len > 0) ? STATE_DATA : STATE_EOF; | 354 | state = (ts->len > 0) ? STATE_DATA : STATE_EOF; |
355 | break; | 355 | break; |
356 | case STATE_DATA: | 356 | case STATE_DATA: |
357 | ts->chksum += data; | 357 | ts->chksum += data; |
358 | ts->buf[ts->idx]= data; | 358 | ts->buf[ts->idx]= data; |
359 | if(++ts->idx == ts->len) | 359 | if (++ts->idx == ts->len) |
360 | state = STATE_EOF; | 360 | state = STATE_EOF; |
361 | break; | 361 | break; |
362 | case STATE_EOF: | 362 | case STATE_EOF: |
363 | state = STATE_SOF; | 363 | state = STATE_SOF; |
364 | if (data == CHAR_EOF || data == ts->chksum) | 364 | if (data == CHAR_EOF || data == ts->chksum) |
365 | h3600ts_process_packet(ts, regs); | 365 | h3600ts_process_packet(ts, regs); |
366 | break; | 366 | break; |
367 | default: | 367 | default: |
368 | printk("Error3\n"); | 368 | printk("Error3\n"); |
369 | break; | 369 | break; |
370 | } | 370 | } |
371 | 371 | ||
372 | return IRQ_HANDLED; | 372 | return IRQ_HANDLED; |
@@ -390,10 +390,10 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
390 | init_input_dev(&ts->dev); | 390 | init_input_dev(&ts->dev); |
391 | 391 | ||
392 | /* Device specific stuff */ | 392 | /* Device specific stuff */ |
393 | set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); | 393 | set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); |
394 | set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); | 394 | set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); |
395 | 395 | ||
396 | if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, | 396 | if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, |
397 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, | 397 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, |
398 | "h3600_action", &ts->dev)) { | 398 | "h3600_action", &ts->dev)) { |
399 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); | 399 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); |
@@ -401,7 +401,7 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
401 | return -EBUSY; | 401 | return -EBUSY; |
402 | } | 402 | } |
403 | 403 | ||
404 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, | 404 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, |
405 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, | 405 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, |
406 | "h3600_suspend", &ts->dev)) { | 406 | "h3600_suspend", &ts->dev)) { |
407 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); | 407 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); |
@@ -433,7 +433,7 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
433 | 433 | ||
434 | sprintf(ts->phys, "%s/input0", serio->phys); | 434 | sprintf(ts->phys, "%s/input0", serio->phys); |
435 | 435 | ||
436 | ts->dev.event = h3600ts_event; | 436 | ts->dev.event = h3600ts_event; |
437 | ts->dev.private = ts; | 437 | ts->dev.private = ts; |
438 | ts->dev.name = h3600_name; | 438 | ts->dev.name = h3600_name; |
439 | ts->dev.phys = ts->phys; | 439 | ts->dev.phys = ts->phys; |
@@ -446,8 +446,8 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
446 | 446 | ||
447 | err = serio_open(serio, drv); | 447 | err = serio_open(serio, drv); |
448 | if (err) { | 448 | if (err) { |
449 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts); | 449 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts); |
450 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts); | 450 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts); |
451 | serio_set_drvdata(serio, NULL); | 451 | serio_set_drvdata(serio, NULL); |
452 | kfree(ts); | 452 | kfree(ts); |
453 | return err; | 453 | return err; |
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c index 2d14a57a05e5..afaaebe5225b 100644 --- a/drivers/input/touchscreen/mk712.c +++ b/drivers/input/touchscreen/mk712.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * found in Gateway AOL Connected Touchpad computers. | 17 | * found in Gateway AOL Connected Touchpad computers. |
18 | * | 18 | * |
19 | * Documentation for ICS MK712 can be found at: | 19 | * Documentation for ICS MK712 can be found at: |
20 | * http://www.icst.com/pdf/mk712.pdf | 20 | * http://www.icst.com/pdf/mk712.pdf |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /* | 23 | /* |
@@ -77,7 +77,6 @@ MODULE_PARM_DESC(irq, "IRQ of MK712 touchscreen controller"); | |||
77 | #define MK712_READ_ONE_POINT 0x20 | 77 | #define MK712_READ_ONE_POINT 0x20 |
78 | #define MK712_POWERUP 0x40 | 78 | #define MK712_POWERUP 0x40 |
79 | 79 | ||
80 | static int mk712_used = 0; | ||
81 | static struct input_dev mk712_dev; | 80 | static struct input_dev mk712_dev; |
82 | static DEFINE_SPINLOCK(mk712_lock); | 81 | static DEFINE_SPINLOCK(mk712_lock); |
83 | 82 | ||
@@ -130,17 +129,14 @@ static int mk712_open(struct input_dev *dev) | |||
130 | 129 | ||
131 | spin_lock_irqsave(&mk712_lock, flags); | 130 | spin_lock_irqsave(&mk712_lock, flags); |
132 | 131 | ||
133 | if (!mk712_used++) { | 132 | outb(0, mk712_io + MK712_CONTROL); /* Reset */ |
134 | 133 | ||
135 | outb(0, mk712_io + MK712_CONTROL); /* Reset */ | 134 | outb(MK712_ENABLE_INT | MK712_INT_ON_CONVERSION_COMPLETE | |
135 | MK712_INT_ON_CHANGE_IN_TOUCH_STATUS | | ||
136 | MK712_ENABLE_PERIODIC_CONVERSIONS | | ||
137 | MK712_POWERUP, mk712_io + MK712_CONTROL); | ||
136 | 138 | ||
137 | outb(MK712_ENABLE_INT | MK712_INT_ON_CONVERSION_COMPLETE | | 139 | outb(10, mk712_io + MK712_RATE); /* 187 points per second */ |
138 | MK712_INT_ON_CHANGE_IN_TOUCH_STATUS | | ||
139 | MK712_ENABLE_PERIODIC_CONVERSIONS | | ||
140 | MK712_POWERUP, mk712_io + MK712_CONTROL); | ||
141 | |||
142 | outb(10, mk712_io + MK712_RATE); /* 187 points per second */ | ||
143 | } | ||
144 | 140 | ||
145 | spin_unlock_irqrestore(&mk712_lock, flags); | 141 | spin_unlock_irqrestore(&mk712_lock, flags); |
146 | 142 | ||
@@ -153,8 +149,7 @@ static void mk712_close(struct input_dev *dev) | |||
153 | 149 | ||
154 | spin_lock_irqsave(&mk712_lock, flags); | 150 | spin_lock_irqsave(&mk712_lock, flags); |
155 | 151 | ||
156 | if (!--mk712_used) | 152 | outb(0, mk712_io + MK712_CONTROL); |
157 | outb(0, mk712_io + MK712_CONTROL); | ||
158 | 153 | ||
159 | spin_unlock_irqrestore(&mk712_lock, flags); | 154 | spin_unlock_irqrestore(&mk712_lock, flags); |
160 | } | 155 | } |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f9383e7f34ff..1b70f8b0feb9 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -7,7 +7,7 @@ menu "Video For Linux" | |||
7 | 7 | ||
8 | comment "Video Adapters" | 8 | comment "Video Adapters" |
9 | 9 | ||
10 | config CONFIG_TUNER_MULTI_I2C | 10 | config TUNER_MULTI_I2C |
11 | bool "Enable support for multiple I2C devices on Video Adapters (EXPERIMENTAL)" | 11 | bool "Enable support for multiple I2C devices on Video Adapters (EXPERIMENTAL)" |
12 | depends on VIDEO_DEV && EXPERIMENTAL | 12 | depends on VIDEO_DEV && EXPERIMENTAL |
13 | ---help--- | 13 | ---help--- |
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index a61d4433a989..a708a1dbb530 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile | |||
@@ -31,6 +31,7 @@ obj-$(CONFIG_USB_MOUSE) += input/ | |||
31 | obj-$(CONFIG_USB_MTOUCH) += input/ | 31 | obj-$(CONFIG_USB_MTOUCH) += input/ |
32 | obj-$(CONFIG_USB_POWERMATE) += input/ | 32 | obj-$(CONFIG_USB_POWERMATE) += input/ |
33 | obj-$(CONFIG_USB_WACOM) += input/ | 33 | obj-$(CONFIG_USB_WACOM) += input/ |
34 | obj-$(CONFIG_USB_ACECAD) += input/ | ||
34 | obj-$(CONFIG_USB_XPAD) += input/ | 35 | obj-$(CONFIG_USB_XPAD) += input/ |
35 | 36 | ||
36 | obj-$(CONFIG_USB_DABUSB) += media/ | 37 | obj-$(CONFIG_USB_DABUSB) += media/ |
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig index d28e7eab6f98..fd59f6bdd67f 100644 --- a/drivers/usb/input/Kconfig +++ b/drivers/usb/input/Kconfig | |||
@@ -151,6 +151,18 @@ config USB_WACOM | |||
151 | To compile this driver as a module, choose M here: the | 151 | To compile this driver as a module, choose M here: the |
152 | module will be called wacom. | 152 | module will be called wacom. |
153 | 153 | ||
154 | config USB_ACECAD | ||
155 | tristate "Acecad Flair tablet support" | ||
156 | depends on USB && INPUT | ||
157 | help | ||
158 | Say Y here if you want to use the USB version of the Acecad Flair | ||
159 | tablet. Make sure to say Y to "Mouse support" | ||
160 | (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support" | ||
161 | (CONFIG_INPUT_EVDEV) as well. | ||
162 | |||
163 | To compile this driver as a module, choose M here: the | ||
164 | module will be called acecad. | ||
165 | |||
154 | config USB_KBTAB | 166 | config USB_KBTAB |
155 | tristate "KB Gear JamStudio tablet support" | 167 | tristate "KB Gear JamStudio tablet support" |
156 | depends on USB && INPUT | 168 | depends on USB && INPUT |
@@ -190,6 +202,18 @@ config USB_MTOUCH | |||
190 | To compile this driver as a module, choose M here: the | 202 | To compile this driver as a module, choose M here: the |
191 | module will be called mtouchusb. | 203 | module will be called mtouchusb. |
192 | 204 | ||
205 | config USB_ITMTOUCH | ||
206 | tristate "ITM Touch USB Touchscreen Driver" | ||
207 | depends on USB && INPUT | ||
208 | ---help--- | ||
209 | Say Y here if you want to use a ITM Touch USB | ||
210 | Touchscreen controller. | ||
211 | |||
212 | This touchscreen is used in LG 1510SF monitors. | ||
213 | |||
214 | To compile this driver as a module, choose M here: the | ||
215 | module will be called itmtouch. | ||
216 | |||
193 | config USB_EGALAX | 217 | config USB_EGALAX |
194 | tristate "eGalax TouchKit USB Touchscreen Driver" | 218 | tristate "eGalax TouchKit USB Touchscreen Driver" |
195 | depends on USB && INPUT | 219 | depends on USB && INPUT |
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile index 6bcedd16b0a1..831b2b0f1f05 100644 --- a/drivers/usb/input/Makefile +++ b/drivers/usb/input/Makefile | |||
@@ -33,7 +33,9 @@ obj-$(CONFIG_USB_KBD) += usbkbd.o | |||
33 | obj-$(CONFIG_USB_KBTAB) += kbtab.o | 33 | obj-$(CONFIG_USB_KBTAB) += kbtab.o |
34 | obj-$(CONFIG_USB_MOUSE) += usbmouse.o | 34 | obj-$(CONFIG_USB_MOUSE) += usbmouse.o |
35 | obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o | 35 | obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o |
36 | obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o | ||
36 | obj-$(CONFIG_USB_EGALAX) += touchkitusb.o | 37 | obj-$(CONFIG_USB_EGALAX) += touchkitusb.o |
37 | obj-$(CONFIG_USB_POWERMATE) += powermate.o | 38 | obj-$(CONFIG_USB_POWERMATE) += powermate.o |
38 | obj-$(CONFIG_USB_WACOM) += wacom.o | 39 | obj-$(CONFIG_USB_WACOM) += wacom.o |
40 | obj-$(CONFIG_USB_ACECAD) += acecad.o | ||
39 | obj-$(CONFIG_USB_XPAD) += xpad.o | 41 | obj-$(CONFIG_USB_XPAD) += xpad.o |
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c new file mode 100644 index 000000000000..ebcf7c955800 --- /dev/null +++ b/drivers/usb/input/acecad.c | |||
@@ -0,0 +1,285 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2001-2005 Edouard TISSERANT <edouard.tisserant@wanadoo.fr> | ||
3 | * Copyright (c) 2004-2005 Stephane VOLTZ <svoltz@numericable.fr> | ||
4 | * | ||
5 | * USB Acecad "Acecad Flair" tablet support | ||
6 | * | ||
7 | * Changelog: | ||
8 | * v3.2 - Added sysfs support | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <linux/input.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/usb.h> | ||
34 | |||
35 | /* | ||
36 | * Version Information | ||
37 | */ | ||
38 | #define DRIVER_VERSION "v3.2" | ||
39 | #define DRIVER_DESC "USB Acecad Flair tablet driver" | ||
40 | #define DRIVER_LICENSE "GPL" | ||
41 | #define DRIVER_AUTHOR "Edouard TISSERANT <edouard.tisserant@wanadoo.fr>" | ||
42 | |||
43 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
44 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
45 | MODULE_LICENSE(DRIVER_LICENSE); | ||
46 | |||
47 | #define USB_VENDOR_ID_ACECAD 0x0460 | ||
48 | #define USB_DEVICE_ID_FLAIR 0x0004 | ||
49 | #define USB_DEVICE_ID_302 0x0008 | ||
50 | |||
51 | struct usb_acecad { | ||
52 | char name[128]; | ||
53 | char phys[64]; | ||
54 | struct usb_device *usbdev; | ||
55 | struct input_dev dev; | ||
56 | struct urb *irq; | ||
57 | |||
58 | signed char *data; | ||
59 | dma_addr_t data_dma; | ||
60 | }; | ||
61 | |||
62 | static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs) | ||
63 | { | ||
64 | struct usb_acecad *acecad = urb->context; | ||
65 | unsigned char *data = acecad->data; | ||
66 | struct input_dev *dev = &acecad->dev; | ||
67 | int prox, status; | ||
68 | |||
69 | switch (urb->status) { | ||
70 | case 0: | ||
71 | /* success */ | ||
72 | break; | ||
73 | case -ECONNRESET: | ||
74 | case -ENOENT: | ||
75 | case -ESHUTDOWN: | ||
76 | /* this urb is terminated, clean up */ | ||
77 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); | ||
78 | return; | ||
79 | default: | ||
80 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); | ||
81 | goto resubmit; | ||
82 | } | ||
83 | |||
84 | prox = (data[0] & 0x04) >> 2; | ||
85 | input_report_key(dev, BTN_TOOL_PEN, prox); | ||
86 | |||
87 | if (prox) { | ||
88 | int x = data[1] | (data[2] << 8); | ||
89 | int y = data[3] | (data[4] << 8); | ||
90 | /*Pressure should compute the same way for flair and 302*/ | ||
91 | int pressure = data[5] | ((int)data[6] << 8); | ||
92 | int touch = data[0] & 0x01; | ||
93 | int stylus = (data[0] & 0x10) >> 4; | ||
94 | int stylus2 = (data[0] & 0x20) >> 5; | ||
95 | input_report_abs(dev, ABS_X, x); | ||
96 | input_report_abs(dev, ABS_Y, y); | ||
97 | input_report_abs(dev, ABS_PRESSURE, pressure); | ||
98 | input_report_key(dev, BTN_TOUCH, touch); | ||
99 | input_report_key(dev, BTN_STYLUS, stylus); | ||
100 | input_report_key(dev, BTN_STYLUS2, stylus2); | ||
101 | } | ||
102 | |||
103 | /* event termination */ | ||
104 | input_sync(dev); | ||
105 | |||
106 | resubmit: | ||
107 | status = usb_submit_urb (urb, GFP_ATOMIC); | ||
108 | if (status) | ||
109 | err ("can't resubmit intr, %s-%s/input0, status %d", | ||
110 | acecad->usbdev->bus->bus_name, acecad->usbdev->devpath, status); | ||
111 | } | ||
112 | |||
113 | static int usb_acecad_open(struct input_dev *dev) | ||
114 | { | ||
115 | struct usb_acecad *acecad = dev->private; | ||
116 | |||
117 | acecad->irq->dev = acecad->usbdev; | ||
118 | if (usb_submit_urb(acecad->irq, GFP_KERNEL)) | ||
119 | return -EIO; | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static void usb_acecad_close(struct input_dev *dev) | ||
125 | { | ||
126 | struct usb_acecad *acecad = dev->private; | ||
127 | |||
128 | usb_kill_urb(acecad->irq); | ||
129 | } | ||
130 | |||
131 | static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
132 | { | ||
133 | struct usb_device *dev = interface_to_usbdev(intf); | ||
134 | struct usb_host_interface *interface = intf->cur_altsetting; | ||
135 | struct usb_endpoint_descriptor *endpoint; | ||
136 | struct usb_acecad *acecad; | ||
137 | int pipe, maxp; | ||
138 | char path[64]; | ||
139 | |||
140 | if (interface->desc.bNumEndpoints != 1) | ||
141 | return -ENODEV; | ||
142 | |||
143 | endpoint = &interface->endpoint[0].desc; | ||
144 | |||
145 | if (!(endpoint->bEndpointAddress & 0x80)) | ||
146 | return -ENODEV; | ||
147 | |||
148 | if ((endpoint->bmAttributes & 3) != 3) | ||
149 | return -ENODEV; | ||
150 | |||
151 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | ||
152 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | ||
153 | |||
154 | acecad = kcalloc(1, sizeof(struct usb_acecad), GFP_KERNEL); | ||
155 | if (!acecad) | ||
156 | return -ENOMEM; | ||
157 | |||
158 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); | ||
159 | if (!acecad->data) | ||
160 | goto fail1; | ||
161 | |||
162 | acecad->irq = usb_alloc_urb(0, GFP_KERNEL); | ||
163 | if (!acecad->irq) | ||
164 | goto fail2; | ||
165 | |||
166 | if (dev->manufacturer) | ||
167 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); | ||
168 | |||
169 | if (dev->product) { | ||
170 | if (dev->manufacturer) | ||
171 | strlcat(acecad->name, " ", sizeof(acecad->name)); | ||
172 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); | ||
173 | } | ||
174 | |||
175 | usb_make_path(dev, path, sizeof(path)); | ||
176 | snprintf(acecad->phys, sizeof(acecad->phys), "%s/input0", path); | ||
177 | |||
178 | acecad->usbdev = dev; | ||
179 | |||
180 | acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
181 | acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
182 | acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
183 | acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | ||
184 | |||
185 | switch (id->driver_info) { | ||
186 | case 0: | ||
187 | acecad->dev.absmax[ABS_X] = 5000; | ||
188 | acecad->dev.absmax[ABS_Y] = 3750; | ||
189 | acecad->dev.absmax[ABS_PRESSURE] = 512; | ||
190 | if (!strlen(acecad->name)) | ||
191 | snprintf(acecad->name, sizeof(acecad->name), | ||
192 | "USB Acecad Flair Tablet %04x:%04x", | ||
193 | dev->descriptor.idVendor, dev->descriptor.idProduct); | ||
194 | break; | ||
195 | case 1: | ||
196 | acecad->dev.absmax[ABS_X] = 3000; | ||
197 | acecad->dev.absmax[ABS_Y] = 2250; | ||
198 | acecad->dev.absmax[ABS_PRESSURE] = 1024; | ||
199 | if (!strlen(acecad->name)) | ||
200 | snprintf(acecad->name, sizeof(acecad->name), | ||
201 | "USB Acecad 302 Tablet %04x:%04x", | ||
202 | dev->descriptor.idVendor, dev->descriptor.idProduct); | ||
203 | break; | ||
204 | } | ||
205 | |||
206 | acecad->dev.absfuzz[ABS_X] = 4; | ||
207 | acecad->dev.absfuzz[ABS_Y] = 4; | ||
208 | |||
209 | acecad->dev.private = acecad; | ||
210 | acecad->dev.open = usb_acecad_open; | ||
211 | acecad->dev.close = usb_acecad_close; | ||
212 | |||
213 | acecad->dev.name = acecad->name; | ||
214 | acecad->dev.phys = acecad->phys; | ||
215 | acecad->dev.id.bustype = BUS_USB; | ||
216 | acecad->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); | ||
217 | acecad->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); | ||
218 | acecad->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice); | ||
219 | acecad->dev.dev = &intf->dev; | ||
220 | |||
221 | usb_fill_int_urb(acecad->irq, dev, pipe, | ||
222 | acecad->data, maxp > 8 ? 8 : maxp, | ||
223 | usb_acecad_irq, acecad, endpoint->bInterval); | ||
224 | acecad->irq->transfer_dma = acecad->data_dma; | ||
225 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
226 | |||
227 | input_register_device(&acecad->dev); | ||
228 | |||
229 | printk(KERN_INFO "input: %s with packet size %d on %s\n", | ||
230 | acecad->name, maxp, path); | ||
231 | |||
232 | usb_set_intfdata(intf, acecad); | ||
233 | |||
234 | return 0; | ||
235 | |||
236 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); | ||
237 | fail1: kfree(acecad); | ||
238 | return -ENOMEM; | ||
239 | } | ||
240 | |||
241 | static void usb_acecad_disconnect(struct usb_interface *intf) | ||
242 | { | ||
243 | struct usb_acecad *acecad = usb_get_intfdata(intf); | ||
244 | |||
245 | usb_set_intfdata(intf, NULL); | ||
246 | if (acecad) { | ||
247 | usb_kill_urb(acecad->irq); | ||
248 | input_unregister_device(&acecad->dev); | ||
249 | usb_free_urb(acecad->irq); | ||
250 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); | ||
251 | kfree(acecad); | ||
252 | } | ||
253 | } | ||
254 | |||
255 | static struct usb_device_id usb_acecad_id_table [] = { | ||
256 | { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_FLAIR), .driver_info = 0 }, | ||
257 | { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_302), .driver_info = 1 }, | ||
258 | { } | ||
259 | }; | ||
260 | |||
261 | MODULE_DEVICE_TABLE(usb, usb_acecad_id_table); | ||
262 | |||
263 | static struct usb_driver usb_acecad_driver = { | ||
264 | .owner = THIS_MODULE, | ||
265 | .name = "usb_acecad", | ||
266 | .probe = usb_acecad_probe, | ||
267 | .disconnect = usb_acecad_disconnect, | ||
268 | .id_table = usb_acecad_id_table, | ||
269 | }; | ||
270 | |||
271 | static int __init usb_acecad_init(void) | ||
272 | { | ||
273 | int result = usb_register(&usb_acecad_driver); | ||
274 | if (result == 0) | ||
275 | info(DRIVER_VERSION ":" DRIVER_DESC); | ||
276 | return result; | ||
277 | } | ||
278 | |||
279 | static void __exit usb_acecad_exit(void) | ||
280 | { | ||
281 | usb_deregister(&usb_acecad_driver); | ||
282 | } | ||
283 | |||
284 | module_init(usb_acecad_init); | ||
285 | module_exit(usb_acecad_exit); | ||
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index e991f7ed7330..6bb0f25e8e93 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Native support for the Aiptek HyperPen USB Tablets | 2 | * Native support for the Aiptek HyperPen USB Tablets |
3 | * (4000U/5000U/6000U/8000U/12000U) | 3 | * (4000U/5000U/6000U/8000U/12000U) |
4 | * | 4 | * |
5 | * Copyright (c) 2001 Chris Atenasio <chris@crud.net> | 5 | * Copyright (c) 2001 Chris Atenasio <chris@crud.net> |
6 | * Copyright (c) 2002-2004 Bryan W. Headley <bwheadley@earthlink.net> | 6 | * Copyright (c) 2002-2004 Bryan W. Headley <bwheadley@earthlink.net> |
7 | * | 7 | * |
@@ -31,7 +31,7 @@ | |||
31 | * - Added support for the sysfs interface, deprecating the | 31 | * - Added support for the sysfs interface, deprecating the |
32 | * procfs interface for 2.5.x kernel. Also added support for | 32 | * procfs interface for 2.5.x kernel. Also added support for |
33 | * Wheel command. Bryan W. Headley July-15-2003. | 33 | * Wheel command. Bryan W. Headley July-15-2003. |
34 | * v1.2 - Reworked jitter timer as a kernel thread. | 34 | * v1.2 - Reworked jitter timer as a kernel thread. |
35 | * Bryan W. Headley November-28-2003/Jan-10-2004. | 35 | * Bryan W. Headley November-28-2003/Jan-10-2004. |
36 | * v1.3 - Repaired issue of kernel thread going nuts on single-processor | 36 | * v1.3 - Repaired issue of kernel thread going nuts on single-processor |
37 | * machines, introduced programmableDelay as a command line | 37 | * machines, introduced programmableDelay as a command line |
@@ -49,10 +49,10 @@ | |||
49 | * NOTE: | 49 | * NOTE: |
50 | * This kernel driver is augmented by the "Aiptek" XFree86 input | 50 | * This kernel driver is augmented by the "Aiptek" XFree86 input |
51 | * driver for your X server, as well as the Gaiptek GUI Front-end | 51 | * driver for your X server, as well as the Gaiptek GUI Front-end |
52 | * "Tablet Manager". | 52 | * "Tablet Manager". |
53 | * These three products are highly interactive with one another, | 53 | * These three products are highly interactive with one another, |
54 | * so therefore it's easier to document them all as one subsystem. | 54 | * so therefore it's easier to document them all as one subsystem. |
55 | * Please visit the project's "home page", located at, | 55 | * Please visit the project's "home page", located at, |
56 | * http://aiptektablet.sourceforge.net. | 56 | * http://aiptektablet.sourceforge.net. |
57 | * | 57 | * |
58 | * This program is free software; you can redistribute it and/or modify | 58 | * This program is free software; you can redistribute it and/or modify |
@@ -156,7 +156,7 @@ | |||
156 | * Command/Data Description Return Bytes Return Value | 156 | * Command/Data Description Return Bytes Return Value |
157 | * 0x10/0x00 SwitchToMouse 0 | 157 | * 0x10/0x00 SwitchToMouse 0 |
158 | * 0x10/0x01 SwitchToTablet 0 | 158 | * 0x10/0x01 SwitchToTablet 0 |
159 | * 0x18/0x04 SetResolution 0 | 159 | * 0x18/0x04 SetResolution 0 |
160 | * 0x12/0xFF AutoGainOn 0 | 160 | * 0x12/0xFF AutoGainOn 0 |
161 | * 0x17/0x00 FilterOn 0 | 161 | * 0x17/0x00 FilterOn 0 |
162 | * 0x01/0x00 GetXExtension 2 MaxX | 162 | * 0x01/0x00 GetXExtension 2 MaxX |
@@ -247,7 +247,7 @@ | |||
247 | #define AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE 2 | 247 | #define AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE 2 |
248 | #define AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED 3 | 248 | #define AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED 3 |
249 | 249 | ||
250 | /* Time to wait (in ms) to help mask hand jittering | 250 | /* Time to wait (in ms) to help mask hand jittering |
251 | * when pressing the stylus buttons. | 251 | * when pressing the stylus buttons. |
252 | */ | 252 | */ |
253 | #define AIPTEK_JITTER_DELAY_DEFAULT 50 | 253 | #define AIPTEK_JITTER_DELAY_DEFAULT 50 |
@@ -324,7 +324,6 @@ struct aiptek { | |||
324 | struct aiptek_settings curSetting; /* tablet's current programmable */ | 324 | struct aiptek_settings curSetting; /* tablet's current programmable */ |
325 | struct aiptek_settings newSetting; /* ... and new param settings */ | 325 | struct aiptek_settings newSetting; /* ... and new param settings */ |
326 | unsigned int ifnum; /* interface number for IO */ | 326 | unsigned int ifnum; /* interface number for IO */ |
327 | int openCount; /* module use counter */ | ||
328 | int diagnostic; /* tablet diagnostic codes */ | 327 | int diagnostic; /* tablet diagnostic codes */ |
329 | unsigned long eventCount; /* event count */ | 328 | unsigned long eventCount; /* event count */ |
330 | int inDelay; /* jitter: in jitter delay? */ | 329 | int inDelay; /* jitter: in jitter delay? */ |
@@ -791,7 +790,7 @@ exit: | |||
791 | * specific Aiptek model numbers, because there has been overlaps, | 790 | * specific Aiptek model numbers, because there has been overlaps, |
792 | * use, and reuse of id's in existing models. Certain models have | 791 | * use, and reuse of id's in existing models. Certain models have |
793 | * been known to use more than one ID, indicative perhaps of | 792 | * been known to use more than one ID, indicative perhaps of |
794 | * manufacturing revisions. In any event, we consider these | 793 | * manufacturing revisions. In any event, we consider these |
795 | * IDs to not be model-specific nor unique. | 794 | * IDs to not be model-specific nor unique. |
796 | */ | 795 | */ |
797 | static const struct usb_device_id aiptek_ids[] = { | 796 | static const struct usb_device_id aiptek_ids[] = { |
@@ -814,15 +813,9 @@ static int aiptek_open(struct input_dev *inputdev) | |||
814 | { | 813 | { |
815 | struct aiptek *aiptek = inputdev->private; | 814 | struct aiptek *aiptek = inputdev->private; |
816 | 815 | ||
817 | if (aiptek->openCount++ > 0) { | ||
818 | return 0; | ||
819 | } | ||
820 | |||
821 | aiptek->urb->dev = aiptek->usbdev; | 816 | aiptek->urb->dev = aiptek->usbdev; |
822 | if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0) { | 817 | if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0) |
823 | aiptek->openCount--; | ||
824 | return -EIO; | 818 | return -EIO; |
825 | } | ||
826 | 819 | ||
827 | return 0; | 820 | return 0; |
828 | } | 821 | } |
@@ -834,13 +827,11 @@ static void aiptek_close(struct input_dev *inputdev) | |||
834 | { | 827 | { |
835 | struct aiptek *aiptek = inputdev->private; | 828 | struct aiptek *aiptek = inputdev->private; |
836 | 829 | ||
837 | if (--aiptek->openCount == 0) { | 830 | usb_kill_urb(aiptek->urb); |
838 | usb_kill_urb(aiptek->urb); | ||
839 | } | ||
840 | } | 831 | } |
841 | 832 | ||
842 | /*********************************************************************** | 833 | /*********************************************************************** |
843 | * aiptek_set_report and aiptek_get_report() are borrowed from Linux 2.4.x, | 834 | * aiptek_set_report and aiptek_get_report() are borrowed from Linux 2.4.x, |
844 | * where they were known as usb_set_report and usb_get_report. | 835 | * where they were known as usb_set_report and usb_get_report. |
845 | */ | 836 | */ |
846 | static int | 837 | static int |
@@ -2252,7 +2243,6 @@ static void aiptek_disconnect(struct usb_interface *intf) | |||
2252 | AIPTEK_PACKET_LENGTH, | 2243 | AIPTEK_PACKET_LENGTH, |
2253 | aiptek->data, aiptek->data_dma); | 2244 | aiptek->data, aiptek->data_dma); |
2254 | kfree(aiptek); | 2245 | kfree(aiptek); |
2255 | aiptek = NULL; | ||
2256 | } | 2246 | } |
2257 | } | 2247 | } |
2258 | 2248 | ||
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index 860df26323b1..db95c975952b 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
@@ -1,15 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | * USB ATI Remote support | 2 | * USB ATI Remote support |
3 | * | 3 | * |
4 | * Version 2.2.0 Copyright (c) 2004 Torrey Hoffman <thoffman@arnor.net> | 4 | * Version 2.2.0 Copyright (c) 2004 Torrey Hoffman <thoffman@arnor.net> |
5 | * Version 2.1.1 Copyright (c) 2002 Vladimir Dergachev | 5 | * Version 2.1.1 Copyright (c) 2002 Vladimir Dergachev |
6 | * | 6 | * |
7 | * This 2.2.0 version is a rewrite / cleanup of the 2.1.1 driver, including | 7 | * This 2.2.0 version is a rewrite / cleanup of the 2.1.1 driver, including |
8 | * porting to the 2.6 kernel interfaces, along with other modification | 8 | * porting to the 2.6 kernel interfaces, along with other modification |
9 | * to better match the style of the existing usb/input drivers. However, the | 9 | * to better match the style of the existing usb/input drivers. However, the |
10 | * protocol and hardware handling is essentially unchanged from 2.1.1. | 10 | * protocol and hardware handling is essentially unchanged from 2.1.1. |
11 | * | 11 | * |
12 | * The 2.1.1 driver was derived from the usbati_remote and usbkbd drivers by | 12 | * The 2.1.1 driver was derived from the usbati_remote and usbkbd drivers by |
13 | * Vojtech Pavlik. | 13 | * Vojtech Pavlik. |
14 | * | 14 | * |
15 | * Changes: | 15 | * Changes: |
@@ -23,64 +23,64 @@ | |||
23 | * Added support for the "Lola" remote contributed by: | 23 | * Added support for the "Lola" remote contributed by: |
24 | * Seth Cohn <sethcohn@yahoo.com> | 24 | * Seth Cohn <sethcohn@yahoo.com> |
25 | * | 25 | * |
26 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 26 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
27 | * | 27 | * |
28 | * This program is free software; you can redistribute it and/or modify | 28 | * This program is free software; you can redistribute it and/or modify |
29 | * it under the terms of the GNU General Public License as published by | 29 | * it under the terms of the GNU General Public License as published by |
30 | * the Free Software Foundation; either version 2 of the License, or | 30 | * the Free Software Foundation; either version 2 of the License, or |
31 | * (at your option) any later version. | 31 | * (at your option) any later version. |
32 | * | 32 | * |
33 | * This program is distributed in the hope that it will be useful, | 33 | * This program is distributed in the hope that it will be useful, |
34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
36 | * GNU General Public License for more details. | 36 | * GNU General Public License for more details. |
37 | * | 37 | * |
38 | * You should have received a copy of the GNU General Public License | 38 | * You should have received a copy of the GNU General Public License |
39 | * along with this program; if not, write to the Free Software | 39 | * along with this program; if not, write to the Free Software |
40 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 40 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
41 | * | 41 | * |
42 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 42 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
43 | * | 43 | * |
44 | * Hardware & software notes | 44 | * Hardware & software notes |
45 | * | 45 | * |
46 | * These remote controls are distributed by ATI as part of their | 46 | * These remote controls are distributed by ATI as part of their |
47 | * "All-In-Wonder" video card packages. The receiver self-identifies as a | 47 | * "All-In-Wonder" video card packages. The receiver self-identifies as a |
48 | * "USB Receiver" with manufacturer "X10 Wireless Technology Inc". | 48 | * "USB Receiver" with manufacturer "X10 Wireless Technology Inc". |
49 | * | 49 | * |
50 | * The "Lola" remote is available from X10. See: | 50 | * The "Lola" remote is available from X10. See: |
51 | * http://www.x10.com/products/lola_sg1.htm | 51 | * http://www.x10.com/products/lola_sg1.htm |
52 | * The Lola is similar to the ATI remote but has no mouse support, and slightly | 52 | * The Lola is similar to the ATI remote but has no mouse support, and slightly |
53 | * different keys. | 53 | * different keys. |
54 | * | 54 | * |
55 | * It is possible to use multiple receivers and remotes on multiple computers | 55 | * It is possible to use multiple receivers and remotes on multiple computers |
56 | * simultaneously by configuring them to use specific channels. | 56 | * simultaneously by configuring them to use specific channels. |
57 | * | 57 | * |
58 | * The RF protocol used by the remote supports 16 distinct channels, 1 to 16. | 58 | * The RF protocol used by the remote supports 16 distinct channels, 1 to 16. |
59 | * Actually, it may even support more, at least in some revisions of the | 59 | * Actually, it may even support more, at least in some revisions of the |
60 | * hardware. | 60 | * hardware. |
61 | * | 61 | * |
62 | * Each remote can be configured to transmit on one channel as follows: | 62 | * Each remote can be configured to transmit on one channel as follows: |
63 | * - Press and hold the "hand icon" button. | 63 | * - Press and hold the "hand icon" button. |
64 | * - When the red LED starts to blink, let go of the "hand icon" button. | 64 | * - When the red LED starts to blink, let go of the "hand icon" button. |
65 | * - When it stops blinking, input the channel code as two digits, from 01 | 65 | * - When it stops blinking, input the channel code as two digits, from 01 |
66 | * to 16, and press the hand icon again. | 66 | * to 16, and press the hand icon again. |
67 | * | 67 | * |
68 | * The timing can be a little tricky. Try loading the module with debug=1 | 68 | * The timing can be a little tricky. Try loading the module with debug=1 |
69 | * to have the kernel print out messages about the remote control number | 69 | * to have the kernel print out messages about the remote control number |
70 | * and mask. Note: debugging prints remote numbers as zero-based hexadecimal. | 70 | * and mask. Note: debugging prints remote numbers as zero-based hexadecimal. |
71 | * | 71 | * |
72 | * The driver has a "channel_mask" parameter. This bitmask specifies which | 72 | * The driver has a "channel_mask" parameter. This bitmask specifies which |
73 | * channels will be ignored by the module. To mask out channels, just add | 73 | * channels will be ignored by the module. To mask out channels, just add |
74 | * all the 2^channel_number values together. | 74 | * all the 2^channel_number values together. |
75 | * | 75 | * |
76 | * For instance, set channel_mask = 2^4 = 16 (binary 10000) to make ati_remote | 76 | * For instance, set channel_mask = 2^4 = 16 (binary 10000) to make ati_remote |
77 | * ignore signals coming from remote controls transmitting on channel 4, but | 77 | * ignore signals coming from remote controls transmitting on channel 4, but |
78 | * accept all other channels. | 78 | * accept all other channels. |
79 | * | 79 | * |
80 | * Or, set channel_mask = 65533, (0xFFFD), and all channels except 1 will be | 80 | * Or, set channel_mask = 65533, (0xFFFD), and all channels except 1 will be |
81 | * ignored. | 81 | * ignored. |
82 | * | 82 | * |
83 | * The default is 0 (respond to all channels). Bit 0 and bits 17-32 of this | 83 | * The default is 0 (respond to all channels). Bit 0 and bits 17-32 of this |
84 | * parameter are unused. | 84 | * parameter are unused. |
85 | * | 85 | * |
86 | */ | 86 | */ |
@@ -99,13 +99,13 @@ | |||
99 | /* | 99 | /* |
100 | * Module and Version Information, Module Parameters | 100 | * Module and Version Information, Module Parameters |
101 | */ | 101 | */ |
102 | 102 | ||
103 | #define ATI_REMOTE_VENDOR_ID 0x0bc7 | 103 | #define ATI_REMOTE_VENDOR_ID 0x0bc7 |
104 | #define ATI_REMOTE_PRODUCT_ID 0x004 | 104 | #define ATI_REMOTE_PRODUCT_ID 0x004 |
105 | #define LOLA_REMOTE_PRODUCT_ID 0x002 | 105 | #define LOLA_REMOTE_PRODUCT_ID 0x002 |
106 | #define MEDION_REMOTE_PRODUCT_ID 0x006 | 106 | #define MEDION_REMOTE_PRODUCT_ID 0x006 |
107 | 107 | ||
108 | #define DRIVER_VERSION "2.2.1" | 108 | #define DRIVER_VERSION "2.2.1" |
109 | #define DRIVER_AUTHOR "Torrey Hoffman <thoffman@arnor.net>" | 109 | #define DRIVER_AUTHOR "Torrey Hoffman <thoffman@arnor.net>" |
110 | #define DRIVER_DESC "ATI/X10 RF USB Remote Control" | 110 | #define DRIVER_DESC "ATI/X10 RF USB Remote Control" |
111 | 111 | ||
@@ -113,18 +113,18 @@ | |||
113 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ | 113 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ |
114 | #define ATI_INPUTNUM 1 /* Which input device to register as */ | 114 | #define ATI_INPUTNUM 1 /* Which input device to register as */ |
115 | 115 | ||
116 | static unsigned long channel_mask = 0; | 116 | static unsigned long channel_mask; |
117 | module_param(channel_mask, ulong, 0444); | 117 | module_param(channel_mask, ulong, 0444); |
118 | MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore"); | 118 | MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore"); |
119 | 119 | ||
120 | static int debug = 0; | 120 | static int debug; |
121 | module_param(debug, int, 0444); | 121 | module_param(debug, int, 0444); |
122 | MODULE_PARM_DESC(debug, "Enable extra debug messages and information"); | 122 | MODULE_PARM_DESC(debug, "Enable extra debug messages and information"); |
123 | 123 | ||
124 | #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) | 124 | #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) |
125 | #undef err | 125 | #undef err |
126 | #define err(format, arg...) printk(KERN_ERR format , ## arg) | 126 | #define err(format, arg...) printk(KERN_ERR format , ## arg) |
127 | 127 | ||
128 | static struct usb_device_id ati_remote_table[] = { | 128 | static struct usb_device_id ati_remote_table[] = { |
129 | { USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID) }, | 129 | { USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID) }, |
130 | { USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID) }, | 130 | { USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID) }, |
@@ -148,7 +148,7 @@ static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 }; | |||
148 | /* Acceleration curve for directional control pad */ | 148 | /* Acceleration curve for directional control pad */ |
149 | static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; | 149 | static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; |
150 | 150 | ||
151 | /* Duplicate event filtering time. | 151 | /* Duplicate event filtering time. |
152 | * Sequential, identical KIND_FILTERED inputs with less than | 152 | * Sequential, identical KIND_FILTERED inputs with less than |
153 | * FILTER_TIME jiffies between them are considered as repeat | 153 | * FILTER_TIME jiffies between them are considered as repeat |
154 | * events. The hardware generates 5 events for the first keypress | 154 | * events. The hardware generates 5 events for the first keypress |
@@ -161,10 +161,10 @@ static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; | |||
161 | static DECLARE_MUTEX(disconnect_sem); | 161 | static DECLARE_MUTEX(disconnect_sem); |
162 | 162 | ||
163 | struct ati_remote { | 163 | struct ati_remote { |
164 | struct input_dev idev; | 164 | struct input_dev idev; |
165 | struct usb_device *udev; | 165 | struct usb_device *udev; |
166 | struct usb_interface *interface; | 166 | struct usb_interface *interface; |
167 | 167 | ||
168 | struct urb *irq_urb; | 168 | struct urb *irq_urb; |
169 | struct urb *out_urb; | 169 | struct urb *out_urb; |
170 | struct usb_endpoint_descriptor *endpoint_in; | 170 | struct usb_endpoint_descriptor *endpoint_in; |
@@ -174,13 +174,11 @@ struct ati_remote { | |||
174 | dma_addr_t inbuf_dma; | 174 | dma_addr_t inbuf_dma; |
175 | dma_addr_t outbuf_dma; | 175 | dma_addr_t outbuf_dma; |
176 | 176 | ||
177 | int open; /* open counter */ | ||
178 | |||
179 | unsigned char old_data[2]; /* Detect duplicate events */ | 177 | unsigned char old_data[2]; /* Detect duplicate events */ |
180 | unsigned long old_jiffies; | 178 | unsigned long old_jiffies; |
181 | unsigned long acc_jiffies; /* handle acceleration */ | 179 | unsigned long acc_jiffies; /* handle acceleration */ |
182 | unsigned int repeat_count; | 180 | unsigned int repeat_count; |
183 | 181 | ||
184 | char name[NAME_BUFSIZE]; | 182 | char name[NAME_BUFSIZE]; |
185 | char phys[NAME_BUFSIZE]; | 183 | char phys[NAME_BUFSIZE]; |
186 | 184 | ||
@@ -206,14 +204,14 @@ static struct | |||
206 | int type; | 204 | int type; |
207 | unsigned int code; | 205 | unsigned int code; |
208 | int value; | 206 | int value; |
209 | } ati_remote_tbl[] = | 207 | } ati_remote_tbl[] = |
210 | { | 208 | { |
211 | /* Directional control pad axes */ | 209 | /* Directional control pad axes */ |
212 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ | 210 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ |
213 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ | 211 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ |
214 | {KIND_ACCEL, 0x37, 0x72, EV_REL, REL_Y, -1}, /* up */ | 212 | {KIND_ACCEL, 0x37, 0x72, EV_REL, REL_Y, -1}, /* up */ |
215 | {KIND_ACCEL, 0x38, 0x73, EV_REL, REL_Y, 1}, /* down */ | 213 | {KIND_ACCEL, 0x38, 0x73, EV_REL, REL_Y, 1}, /* down */ |
216 | /* Directional control pad diagonals */ | 214 | /* Directional control pad diagonals */ |
217 | {KIND_LU, 0x39, 0x74, EV_REL, 0, 0}, /* left up */ | 215 | {KIND_LU, 0x39, 0x74, EV_REL, 0, 0}, /* left up */ |
218 | {KIND_RU, 0x3a, 0x75, EV_REL, 0, 0}, /* right up */ | 216 | {KIND_RU, 0x3a, 0x75, EV_REL, 0, 0}, /* right up */ |
219 | {KIND_LD, 0x3c, 0x77, EV_REL, 0, 0}, /* left down */ | 217 | {KIND_LD, 0x3c, 0x77, EV_REL, 0, 0}, /* left down */ |
@@ -225,7 +223,7 @@ static struct | |||
225 | {KIND_LITERAL, 0x41, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */ | 223 | {KIND_LITERAL, 0x41, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */ |
226 | {KIND_LITERAL, 0x42, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */ | 224 | {KIND_LITERAL, 0x42, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */ |
227 | 225 | ||
228 | /* Artificial "doubleclick" events are generated by the hardware. | 226 | /* Artificial "doubleclick" events are generated by the hardware. |
229 | * They are mapped to the "side" and "extra" mouse buttons here. */ | 227 | * They are mapped to the "side" and "extra" mouse buttons here. */ |
230 | {KIND_FILTERED, 0x3f, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */ | 228 | {KIND_FILTERED, 0x3f, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */ |
231 | {KIND_FILTERED, 0x43, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */ | 229 | {KIND_FILTERED, 0x43, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */ |
@@ -273,15 +271,15 @@ static struct | |||
273 | {KIND_FILTERED, 0xea, 0x25, EV_KEY, KEY_PLAY, 1}, /* ( >) */ | 271 | {KIND_FILTERED, 0xea, 0x25, EV_KEY, KEY_PLAY, 1}, /* ( >) */ |
274 | {KIND_FILTERED, 0xe9, 0x24, EV_KEY, KEY_REWIND, 1}, /* (<<) */ | 272 | {KIND_FILTERED, 0xe9, 0x24, EV_KEY, KEY_REWIND, 1}, /* (<<) */ |
275 | {KIND_FILTERED, 0xeb, 0x26, EV_KEY, KEY_FORWARD, 1}, /* (>>) */ | 273 | {KIND_FILTERED, 0xeb, 0x26, EV_KEY, KEY_FORWARD, 1}, /* (>>) */ |
276 | {KIND_FILTERED, 0xed, 0x28, EV_KEY, KEY_STOP, 1}, /* ([]) */ | 274 | {KIND_FILTERED, 0xed, 0x28, EV_KEY, KEY_STOP, 1}, /* ([]) */ |
277 | {KIND_FILTERED, 0xee, 0x29, EV_KEY, KEY_PAUSE, 1}, /* ('') */ | 275 | {KIND_FILTERED, 0xee, 0x29, EV_KEY, KEY_PAUSE, 1}, /* ('') */ |
278 | {KIND_FILTERED, 0xf0, 0x2b, EV_KEY, KEY_PREVIOUS, 1}, /* (<-) */ | 276 | {KIND_FILTERED, 0xf0, 0x2b, EV_KEY, KEY_PREVIOUS, 1}, /* (<-) */ |
279 | {KIND_FILTERED, 0xef, 0x2a, EV_KEY, KEY_NEXT, 1}, /* (>+) */ | 277 | {KIND_FILTERED, 0xef, 0x2a, EV_KEY, KEY_NEXT, 1}, /* (>+) */ |
280 | {KIND_FILTERED, 0xf2, 0x2D, EV_KEY, KEY_INFO, 1}, /* PLAYING */ | 278 | {KIND_FILTERED, 0xf2, 0x2D, EV_KEY, KEY_INFO, 1}, /* PLAYING */ |
281 | {KIND_FILTERED, 0xf3, 0x2E, EV_KEY, KEY_HOME, 1}, /* TOP */ | 279 | {KIND_FILTERED, 0xf3, 0x2E, EV_KEY, KEY_HOME, 1}, /* TOP */ |
282 | {KIND_FILTERED, 0xf4, 0x2F, EV_KEY, KEY_END, 1}, /* END */ | 280 | {KIND_FILTERED, 0xf4, 0x2F, EV_KEY, KEY_END, 1}, /* END */ |
283 | {KIND_FILTERED, 0xf5, 0x30, EV_KEY, KEY_SELECT, 1}, /* SELECT */ | 281 | {KIND_FILTERED, 0xf5, 0x30, EV_KEY, KEY_SELECT, 1}, /* SELECT */ |
284 | 282 | ||
285 | {KIND_END, 0x00, 0x00, EV_MAX + 1, 0, 0} | 283 | {KIND_END, 0x00, 0x00, EV_MAX + 1, 0, 0} |
286 | }; | 284 | }; |
287 | 285 | ||
@@ -315,7 +313,7 @@ static void ati_remote_dump(unsigned char *data, unsigned int len) | |||
315 | if ((len == 1) && (data[0] != (unsigned char)0xff) && (data[0] != 0x00)) | 313 | if ((len == 1) && (data[0] != (unsigned char)0xff) && (data[0] != 0x00)) |
316 | warn("Weird byte 0x%02x", data[0]); | 314 | warn("Weird byte 0x%02x", data[0]); |
317 | else if (len == 4) | 315 | else if (len == 4) |
318 | warn("Weird key %02x %02x %02x %02x", | 316 | warn("Weird key %02x %02x %02x %02x", |
319 | data[0], data[1], data[2], data[3]); | 317 | data[0], data[1], data[2], data[3]); |
320 | else | 318 | else |
321 | warn("Weird data, len=%d %02x %02x %02x %02x %02x %02x ...", | 319 | warn("Weird data, len=%d %02x %02x %02x %02x %02x %02x ...", |
@@ -328,25 +326,16 @@ static void ati_remote_dump(unsigned char *data, unsigned int len) | |||
328 | static int ati_remote_open(struct input_dev *inputdev) | 326 | static int ati_remote_open(struct input_dev *inputdev) |
329 | { | 327 | { |
330 | struct ati_remote *ati_remote = inputdev->private; | 328 | struct ati_remote *ati_remote = inputdev->private; |
331 | int retval = 0; | ||
332 | |||
333 | down(&disconnect_sem); | ||
334 | |||
335 | if (ati_remote->open++) | ||
336 | goto exit; | ||
337 | 329 | ||
338 | /* On first open, submit the read urb which was set up previously. */ | 330 | /* On first open, submit the read urb which was set up previously. */ |
339 | ati_remote->irq_urb->dev = ati_remote->udev; | 331 | ati_remote->irq_urb->dev = ati_remote->udev; |
340 | if (usb_submit_urb(ati_remote->irq_urb, GFP_KERNEL)) { | 332 | if (usb_submit_urb(ati_remote->irq_urb, GFP_KERNEL)) { |
341 | dev_err(&ati_remote->interface->dev, | 333 | dev_err(&ati_remote->interface->dev, |
342 | "%s: usb_submit_urb failed!\n", __FUNCTION__); | 334 | "%s: usb_submit_urb failed!\n", __FUNCTION__); |
343 | ati_remote->open--; | 335 | return -EIO; |
344 | retval = -EIO; | ||
345 | } | 336 | } |
346 | 337 | ||
347 | exit: | 338 | return 0; |
348 | up(&disconnect_sem); | ||
349 | return retval; | ||
350 | } | 339 | } |
351 | 340 | ||
352 | /* | 341 | /* |
@@ -355,9 +344,8 @@ exit: | |||
355 | static void ati_remote_close(struct input_dev *inputdev) | 344 | static void ati_remote_close(struct input_dev *inputdev) |
356 | { | 345 | { |
357 | struct ati_remote *ati_remote = inputdev->private; | 346 | struct ati_remote *ati_remote = inputdev->private; |
358 | 347 | ||
359 | if (!--ati_remote->open) | 348 | usb_kill_urb(ati_remote->irq_urb); |
360 | usb_kill_urb(ati_remote->irq_urb); | ||
361 | } | 349 | } |
362 | 350 | ||
363 | /* | 351 | /* |
@@ -366,13 +354,13 @@ static void ati_remote_close(struct input_dev *inputdev) | |||
366 | static void ati_remote_irq_out(struct urb *urb, struct pt_regs *regs) | 354 | static void ati_remote_irq_out(struct urb *urb, struct pt_regs *regs) |
367 | { | 355 | { |
368 | struct ati_remote *ati_remote = urb->context; | 356 | struct ati_remote *ati_remote = urb->context; |
369 | 357 | ||
370 | if (urb->status) { | 358 | if (urb->status) { |
371 | dev_dbg(&ati_remote->interface->dev, "%s: status %d\n", | 359 | dev_dbg(&ati_remote->interface->dev, "%s: status %d\n", |
372 | __FUNCTION__, urb->status); | 360 | __FUNCTION__, urb->status); |
373 | return; | 361 | return; |
374 | } | 362 | } |
375 | 363 | ||
376 | ati_remote->send_flags |= SEND_FLAG_COMPLETE; | 364 | ati_remote->send_flags |= SEND_FLAG_COMPLETE; |
377 | wmb(); | 365 | wmb(); |
378 | wake_up(&ati_remote->wait); | 366 | wake_up(&ati_remote->wait); |
@@ -380,16 +368,16 @@ static void ati_remote_irq_out(struct urb *urb, struct pt_regs *regs) | |||
380 | 368 | ||
381 | /* | 369 | /* |
382 | * ati_remote_sendpacket | 370 | * ati_remote_sendpacket |
383 | * | 371 | * |
384 | * Used to send device initialization strings | 372 | * Used to send device initialization strings |
385 | */ | 373 | */ |
386 | static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd, unsigned char *data) | 374 | static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd, unsigned char *data) |
387 | { | 375 | { |
388 | int retval = 0; | 376 | int retval = 0; |
389 | 377 | ||
390 | /* Set up out_urb */ | 378 | /* Set up out_urb */ |
391 | memcpy(ati_remote->out_urb->transfer_buffer + 1, data, LO(cmd)); | 379 | memcpy(ati_remote->out_urb->transfer_buffer + 1, data, LO(cmd)); |
392 | ((char *) ati_remote->out_urb->transfer_buffer)[0] = HI(cmd); | 380 | ((char *) ati_remote->out_urb->transfer_buffer)[0] = HI(cmd); |
393 | 381 | ||
394 | ati_remote->out_urb->transfer_buffer_length = LO(cmd) + 1; | 382 | ati_remote->out_urb->transfer_buffer_length = LO(cmd) + 1; |
395 | ati_remote->out_urb->dev = ati_remote->udev; | 383 | ati_remote->out_urb->dev = ati_remote->udev; |
@@ -397,17 +385,17 @@ static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd, unsigne | |||
397 | 385 | ||
398 | retval = usb_submit_urb(ati_remote->out_urb, GFP_ATOMIC); | 386 | retval = usb_submit_urb(ati_remote->out_urb, GFP_ATOMIC); |
399 | if (retval) { | 387 | if (retval) { |
400 | dev_dbg(&ati_remote->interface->dev, | 388 | dev_dbg(&ati_remote->interface->dev, |
401 | "sendpacket: usb_submit_urb failed: %d\n", retval); | 389 | "sendpacket: usb_submit_urb failed: %d\n", retval); |
402 | return retval; | 390 | return retval; |
403 | } | 391 | } |
404 | 392 | ||
405 | wait_event_timeout(ati_remote->wait, | 393 | wait_event_timeout(ati_remote->wait, |
406 | ((ati_remote->out_urb->status != -EINPROGRESS) || | 394 | ((ati_remote->out_urb->status != -EINPROGRESS) || |
407 | (ati_remote->send_flags & SEND_FLAG_COMPLETE)), | 395 | (ati_remote->send_flags & SEND_FLAG_COMPLETE)), |
408 | HZ); | 396 | HZ); |
409 | usb_kill_urb(ati_remote->out_urb); | 397 | usb_kill_urb(ati_remote->out_urb); |
410 | 398 | ||
411 | return retval; | 399 | return retval; |
412 | } | 400 | } |
413 | 401 | ||
@@ -419,15 +407,15 @@ static int ati_remote_event_lookup(int rem, unsigned char d1, unsigned char d2) | |||
419 | int i; | 407 | int i; |
420 | 408 | ||
421 | for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) { | 409 | for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) { |
422 | /* | 410 | /* |
423 | * Decide if the table entry matches the remote input. | 411 | * Decide if the table entry matches the remote input. |
424 | */ | 412 | */ |
425 | if ((((ati_remote_tbl[i].data1 & 0x0f) == (d1 & 0x0f))) && | 413 | if ((((ati_remote_tbl[i].data1 & 0x0f) == (d1 & 0x0f))) && |
426 | ((((ati_remote_tbl[i].data1 >> 4) - | 414 | ((((ati_remote_tbl[i].data1 >> 4) - |
427 | (d1 >> 4) + rem) & 0x0f) == 0x0f) && | 415 | (d1 >> 4) + rem) & 0x0f) == 0x0f) && |
428 | (ati_remote_tbl[i].data2 == d2)) | 416 | (ati_remote_tbl[i].data2 == d2)) |
429 | return i; | 417 | return i; |
430 | 418 | ||
431 | } | 419 | } |
432 | return -1; | 420 | return -1; |
433 | } | 421 | } |
@@ -435,16 +423,16 @@ static int ati_remote_event_lookup(int rem, unsigned char d1, unsigned char d2) | |||
435 | /* | 423 | /* |
436 | * ati_remote_report_input | 424 | * ati_remote_report_input |
437 | */ | 425 | */ |
438 | static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | 426 | static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) |
439 | { | 427 | { |
440 | struct ati_remote *ati_remote = urb->context; | 428 | struct ati_remote *ati_remote = urb->context; |
441 | unsigned char *data= ati_remote->inbuf; | 429 | unsigned char *data= ati_remote->inbuf; |
442 | struct input_dev *dev = &ati_remote->idev; | 430 | struct input_dev *dev = &ati_remote->idev; |
443 | int index, acc; | 431 | int index, acc; |
444 | int remote_num; | 432 | int remote_num; |
445 | 433 | ||
446 | /* Deal with strange looking inputs */ | 434 | /* Deal with strange looking inputs */ |
447 | if ( (urb->actual_length != 4) || (data[0] != 0x14) || | 435 | if ( (urb->actual_length != 4) || (data[0] != 0x14) || |
448 | ((data[3] & 0x0f) != 0x00) ) { | 436 | ((data[3] & 0x0f) != 0x00) ) { |
449 | ati_remote_dump(data, urb->actual_length); | 437 | ati_remote_dump(data, urb->actual_length); |
450 | return; | 438 | return; |
@@ -453,7 +441,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
453 | /* Mask unwanted remote channels. */ | 441 | /* Mask unwanted remote channels. */ |
454 | /* note: remote_num is 0-based, channel 1 on remote == 0 here */ | 442 | /* note: remote_num is 0-based, channel 1 on remote == 0 here */ |
455 | remote_num = (data[3] >> 4) & 0x0f; | 443 | remote_num = (data[3] >> 4) & 0x0f; |
456 | if (channel_mask & (1 << (remote_num + 1))) { | 444 | if (channel_mask & (1 << (remote_num + 1))) { |
457 | dbginfo(&ati_remote->interface->dev, | 445 | dbginfo(&ati_remote->interface->dev, |
458 | "Masked input from channel 0x%02x: data %02x,%02x, mask= 0x%02lx\n", | 446 | "Masked input from channel 0x%02x: data %02x,%02x, mask= 0x%02lx\n", |
459 | remote_num, data[1], data[2], channel_mask); | 447 | remote_num, data[1], data[2], channel_mask); |
@@ -463,37 +451,36 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
463 | /* Look up event code index in translation table */ | 451 | /* Look up event code index in translation table */ |
464 | index = ati_remote_event_lookup(remote_num, data[1], data[2]); | 452 | index = ati_remote_event_lookup(remote_num, data[1], data[2]); |
465 | if (index < 0) { | 453 | if (index < 0) { |
466 | dev_warn(&ati_remote->interface->dev, | 454 | dev_warn(&ati_remote->interface->dev, |
467 | "Unknown input from channel 0x%02x: data %02x,%02x\n", | 455 | "Unknown input from channel 0x%02x: data %02x,%02x\n", |
468 | remote_num, data[1], data[2]); | 456 | remote_num, data[1], data[2]); |
469 | return; | 457 | return; |
470 | } | 458 | } |
471 | dbginfo(&ati_remote->interface->dev, | 459 | dbginfo(&ati_remote->interface->dev, |
472 | "channel 0x%02x; data %02x,%02x; index %d; keycode %d\n", | 460 | "channel 0x%02x; data %02x,%02x; index %d; keycode %d\n", |
473 | remote_num, data[1], data[2], index, ati_remote_tbl[index].code); | 461 | remote_num, data[1], data[2], index, ati_remote_tbl[index].code); |
474 | 462 | ||
475 | if (ati_remote_tbl[index].kind == KIND_LITERAL) { | 463 | if (ati_remote_tbl[index].kind == KIND_LITERAL) { |
476 | input_regs(dev, regs); | 464 | input_regs(dev, regs); |
477 | input_event(dev, ati_remote_tbl[index].type, | 465 | input_event(dev, ati_remote_tbl[index].type, |
478 | ati_remote_tbl[index].code, | 466 | ati_remote_tbl[index].code, |
479 | ati_remote_tbl[index].value); | 467 | ati_remote_tbl[index].value); |
480 | input_sync(dev); | 468 | input_sync(dev); |
481 | 469 | ||
482 | ati_remote->old_jiffies = jiffies; | 470 | ati_remote->old_jiffies = jiffies; |
483 | return; | 471 | return; |
484 | } | 472 | } |
485 | 473 | ||
486 | if (ati_remote_tbl[index].kind == KIND_FILTERED) { | 474 | if (ati_remote_tbl[index].kind == KIND_FILTERED) { |
487 | /* Filter duplicate events which happen "too close" together. */ | 475 | /* Filter duplicate events which happen "too close" together. */ |
488 | if ((ati_remote->old_data[0] == data[1]) && | 476 | if ((ati_remote->old_data[0] == data[1]) && |
489 | (ati_remote->old_data[1] == data[2]) && | 477 | (ati_remote->old_data[1] == data[2]) && |
490 | ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) { | 478 | ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) { |
491 | ati_remote->repeat_count++; | 479 | ati_remote->repeat_count++; |
492 | } | 480 | } else { |
493 | else { | ||
494 | ati_remote->repeat_count = 0; | 481 | ati_remote->repeat_count = 0; |
495 | } | 482 | } |
496 | 483 | ||
497 | ati_remote->old_data[0] = data[1]; | 484 | ati_remote->old_data[0] = data[1]; |
498 | ati_remote->old_data[1] = data[2]; | 485 | ati_remote->old_data[1] = data[2]; |
499 | ati_remote->old_jiffies = jiffies; | 486 | ati_remote->old_jiffies = jiffies; |
@@ -501,7 +488,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
501 | if ((ati_remote->repeat_count > 0) | 488 | if ((ati_remote->repeat_count > 0) |
502 | && (ati_remote->repeat_count < 5)) | 489 | && (ati_remote->repeat_count < 5)) |
503 | return; | 490 | return; |
504 | 491 | ||
505 | 492 | ||
506 | input_regs(dev, regs); | 493 | input_regs(dev, regs); |
507 | input_event(dev, ati_remote_tbl[index].type, | 494 | input_event(dev, ati_remote_tbl[index].type, |
@@ -511,13 +498,13 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
511 | input_sync(dev); | 498 | input_sync(dev); |
512 | 499 | ||
513 | return; | 500 | return; |
514 | } | 501 | } |
515 | 502 | ||
516 | /* | 503 | /* |
517 | * Other event kinds are from the directional control pad, and have an | 504 | * Other event kinds are from the directional control pad, and have an |
518 | * acceleration factor applied to them. Without this acceleration, the | 505 | * acceleration factor applied to them. Without this acceleration, the |
519 | * control pad is mostly unusable. | 506 | * control pad is mostly unusable. |
520 | * | 507 | * |
521 | * If elapsed time since last event is > 1/4 second, user "stopped", | 508 | * If elapsed time since last event is > 1/4 second, user "stopped", |
522 | * so reset acceleration. Otherwise, user is probably holding the control | 509 | * so reset acceleration. Otherwise, user is probably holding the control |
523 | * pad down, so we increase acceleration, ramping up over two seconds to | 510 | * pad down, so we increase acceleration, ramping up over two seconds to |
@@ -559,7 +546,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
559 | input_report_rel(dev, REL_Y, acc); | 546 | input_report_rel(dev, REL_Y, acc); |
560 | break; | 547 | break; |
561 | default: | 548 | default: |
562 | dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n", | 549 | dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n", |
563 | ati_remote_tbl[index].kind); | 550 | ati_remote_tbl[index].kind); |
564 | } | 551 | } |
565 | input_sync(dev); | 552 | input_sync(dev); |
@@ -586,12 +573,12 @@ static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs) | |||
586 | case -ESHUTDOWN: | 573 | case -ESHUTDOWN: |
587 | dev_dbg(&ati_remote->interface->dev, "%s: urb error status, unlink? \n", | 574 | dev_dbg(&ati_remote->interface->dev, "%s: urb error status, unlink? \n", |
588 | __FUNCTION__); | 575 | __FUNCTION__); |
589 | return; | 576 | return; |
590 | default: /* error */ | 577 | default: /* error */ |
591 | dev_dbg(&ati_remote->interface->dev, "%s: Nonzero urb status %d\n", | 578 | dev_dbg(&ati_remote->interface->dev, "%s: Nonzero urb status %d\n", |
592 | __FUNCTION__, urb->status); | 579 | __FUNCTION__, urb->status); |
593 | } | 580 | } |
594 | 581 | ||
595 | retval = usb_submit_urb(urb, SLAB_ATOMIC); | 582 | retval = usb_submit_urb(urb, SLAB_ATOMIC); |
596 | if (retval) | 583 | if (retval) |
597 | dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n", | 584 | dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n", |
@@ -603,8 +590,6 @@ static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs) | |||
603 | */ | 590 | */ |
604 | static void ati_remote_delete(struct ati_remote *ati_remote) | 591 | static void ati_remote_delete(struct ati_remote *ati_remote) |
605 | { | 592 | { |
606 | if (!ati_remote) return; | ||
607 | |||
608 | if (ati_remote->irq_urb) | 593 | if (ati_remote->irq_urb) |
609 | usb_kill_urb(ati_remote->irq_urb); | 594 | usb_kill_urb(ati_remote->irq_urb); |
610 | 595 | ||
@@ -614,16 +599,16 @@ static void ati_remote_delete(struct ati_remote *ati_remote) | |||
614 | input_unregister_device(&ati_remote->idev); | 599 | input_unregister_device(&ati_remote->idev); |
615 | 600 | ||
616 | if (ati_remote->inbuf) | 601 | if (ati_remote->inbuf) |
617 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 602 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, |
618 | ati_remote->inbuf, ati_remote->inbuf_dma); | 603 | ati_remote->inbuf, ati_remote->inbuf_dma); |
619 | 604 | ||
620 | if (ati_remote->outbuf) | 605 | if (ati_remote->outbuf) |
621 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 606 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, |
622 | ati_remote->outbuf, ati_remote->outbuf_dma); | 607 | ati_remote->outbuf, ati_remote->outbuf_dma); |
623 | 608 | ||
624 | if (ati_remote->irq_urb) | 609 | if (ati_remote->irq_urb) |
625 | usb_free_urb(ati_remote->irq_urb); | 610 | usb_free_urb(ati_remote->irq_urb); |
626 | 611 | ||
627 | if (ati_remote->out_urb) | 612 | if (ati_remote->out_urb) |
628 | usb_free_urb(ati_remote->out_urb); | 613 | usb_free_urb(ati_remote->out_urb); |
629 | 614 | ||
@@ -636,21 +621,21 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
636 | int i; | 621 | int i; |
637 | 622 | ||
638 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 623 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
639 | idev->keybit[LONG(BTN_MOUSE)] = ( BIT(BTN_LEFT) | BIT(BTN_RIGHT) | | 624 | idev->keybit[LONG(BTN_MOUSE)] = ( BIT(BTN_LEFT) | BIT(BTN_RIGHT) | |
640 | BIT(BTN_SIDE) | BIT(BTN_EXTRA) ); | 625 | BIT(BTN_SIDE) | BIT(BTN_EXTRA) ); |
641 | idev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 626 | idev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
642 | for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) | 627 | for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) |
643 | if (ati_remote_tbl[i].type == EV_KEY) | 628 | if (ati_remote_tbl[i].type == EV_KEY) |
644 | set_bit(ati_remote_tbl[i].code, idev->keybit); | 629 | set_bit(ati_remote_tbl[i].code, idev->keybit); |
645 | 630 | ||
646 | idev->private = ati_remote; | 631 | idev->private = ati_remote; |
647 | idev->open = ati_remote_open; | 632 | idev->open = ati_remote_open; |
648 | idev->close = ati_remote_close; | 633 | idev->close = ati_remote_close; |
649 | 634 | ||
650 | idev->name = ati_remote->name; | 635 | idev->name = ati_remote->name; |
651 | idev->phys = ati_remote->phys; | 636 | idev->phys = ati_remote->phys; |
652 | 637 | ||
653 | idev->id.bustype = BUS_USB; | 638 | idev->id.bustype = BUS_USB; |
654 | idev->id.vendor = le16_to_cpu(ati_remote->udev->descriptor.idVendor); | 639 | idev->id.vendor = le16_to_cpu(ati_remote->udev->descriptor.idVendor); |
655 | idev->id.product = le16_to_cpu(ati_remote->udev->descriptor.idProduct); | 640 | idev->id.product = le16_to_cpu(ati_remote->udev->descriptor.idProduct); |
656 | idev->id.version = le16_to_cpu(ati_remote->udev->descriptor.bcdDevice); | 641 | idev->id.version = le16_to_cpu(ati_remote->udev->descriptor.bcdDevice); |
@@ -660,27 +645,27 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
660 | { | 645 | { |
661 | struct usb_device *udev = ati_remote->udev; | 646 | struct usb_device *udev = ati_remote->udev; |
662 | int pipe, maxp; | 647 | int pipe, maxp; |
663 | 648 | ||
664 | init_waitqueue_head(&ati_remote->wait); | 649 | init_waitqueue_head(&ati_remote->wait); |
665 | 650 | ||
666 | /* Set up irq_urb */ | 651 | /* Set up irq_urb */ |
667 | pipe = usb_rcvintpipe(udev, ati_remote->endpoint_in->bEndpointAddress); | 652 | pipe = usb_rcvintpipe(udev, ati_remote->endpoint_in->bEndpointAddress); |
668 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 653 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
669 | maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; | 654 | maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; |
670 | 655 | ||
671 | usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf, | 656 | usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf, |
672 | maxp, ati_remote_irq_in, ati_remote, | 657 | maxp, ati_remote_irq_in, ati_remote, |
673 | ati_remote->endpoint_in->bInterval); | 658 | ati_remote->endpoint_in->bInterval); |
674 | ati_remote->irq_urb->transfer_dma = ati_remote->inbuf_dma; | 659 | ati_remote->irq_urb->transfer_dma = ati_remote->inbuf_dma; |
675 | ati_remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 660 | ati_remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
676 | 661 | ||
677 | /* Set up out_urb */ | 662 | /* Set up out_urb */ |
678 | pipe = usb_sndintpipe(udev, ati_remote->endpoint_out->bEndpointAddress); | 663 | pipe = usb_sndintpipe(udev, ati_remote->endpoint_out->bEndpointAddress); |
679 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 664 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
680 | maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; | 665 | maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; |
681 | 666 | ||
682 | usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf, | 667 | usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf, |
683 | maxp, ati_remote_irq_out, ati_remote, | 668 | maxp, ati_remote_irq_out, ati_remote, |
684 | ati_remote->endpoint_out->bInterval); | 669 | ati_remote->endpoint_out->bInterval); |
685 | ati_remote->out_urb->transfer_dma = ati_remote->outbuf_dma; | 670 | ati_remote->out_urb->transfer_dma = ati_remote->outbuf_dma; |
686 | ati_remote->out_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 671 | ati_remote->out_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
@@ -688,11 +673,11 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
688 | /* send initialization strings */ | 673 | /* send initialization strings */ |
689 | if ((ati_remote_sendpacket(ati_remote, 0x8004, init1)) || | 674 | if ((ati_remote_sendpacket(ati_remote, 0x8004, init1)) || |
690 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { | 675 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { |
691 | dev_err(&ati_remote->interface->dev, | 676 | dev_err(&ati_remote->interface->dev, |
692 | "Initializing ati_remote hardware failed.\n"); | 677 | "Initializing ati_remote hardware failed.\n"); |
693 | return 1; | 678 | return 1; |
694 | } | 679 | } |
695 | 680 | ||
696 | return 0; | 681 | return 0; |
697 | } | 682 | } |
698 | 683 | ||
@@ -769,7 +754,7 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de | |||
769 | 754 | ||
770 | if (!strlen(ati_remote->name)) | 755 | if (!strlen(ati_remote->name)) |
771 | sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", | 756 | sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", |
772 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), | 757 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), |
773 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); | 758 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); |
774 | 759 | ||
775 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ | 760 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ |
@@ -781,11 +766,11 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de | |||
781 | ati_remote_input_init(ati_remote); | 766 | ati_remote_input_init(ati_remote); |
782 | input_register_device(&ati_remote->idev); | 767 | input_register_device(&ati_remote->idev); |
783 | 768 | ||
784 | dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", | 769 | dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", |
785 | ati_remote->name, path); | 770 | ati_remote->name, path); |
786 | 771 | ||
787 | usb_set_intfdata(interface, ati_remote); | 772 | usb_set_intfdata(interface, ati_remote); |
788 | 773 | ||
789 | error: | 774 | error: |
790 | if (retval) | 775 | if (retval) |
791 | ati_remote_delete(ati_remote); | 776 | ati_remote_delete(ati_remote); |
@@ -800,18 +785,14 @@ static void ati_remote_disconnect(struct usb_interface *interface) | |||
800 | { | 785 | { |
801 | struct ati_remote *ati_remote; | 786 | struct ati_remote *ati_remote; |
802 | 787 | ||
803 | down(&disconnect_sem); | ||
804 | |||
805 | ati_remote = usb_get_intfdata(interface); | 788 | ati_remote = usb_get_intfdata(interface); |
806 | usb_set_intfdata(interface, NULL); | 789 | usb_set_intfdata(interface, NULL); |
807 | if (!ati_remote) { | 790 | if (!ati_remote) { |
808 | warn("%s - null device?\n", __FUNCTION__); | 791 | warn("%s - null device?\n", __FUNCTION__); |
809 | return; | 792 | return; |
810 | } | 793 | } |
811 | |||
812 | ati_remote_delete(ati_remote); | ||
813 | 794 | ||
814 | up(&disconnect_sem); | 795 | ati_remote_delete(ati_remote); |
815 | } | 796 | } |
816 | 797 | ||
817 | /* | 798 | /* |
@@ -820,7 +801,7 @@ static void ati_remote_disconnect(struct usb_interface *interface) | |||
820 | static int __init ati_remote_init(void) | 801 | static int __init ati_remote_init(void) |
821 | { | 802 | { |
822 | int result; | 803 | int result; |
823 | 804 | ||
824 | result = usb_register(&ati_remote_driver); | 805 | result = usb_register(&ati_remote_driver); |
825 | if (result) | 806 | if (result) |
826 | err("usb_register error #%d\n", result); | 807 | err("usb_register error #%d\n", result); |
@@ -838,8 +819,8 @@ static void __exit ati_remote_exit(void) | |||
838 | usb_deregister(&ati_remote_driver); | 819 | usb_deregister(&ati_remote_driver); |
839 | } | 820 | } |
840 | 821 | ||
841 | /* | 822 | /* |
842 | * module specification | 823 | * module specification |
843 | */ | 824 | */ |
844 | 825 | ||
845 | module_init(ati_remote_init); | 826 | module_init(ati_remote_init); |
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 740dec1f521d..100b49bd1d3e 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -232,7 +232,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign | |||
232 | report->size += parser->global.report_size * parser->global.report_count; | 232 | report->size += parser->global.report_size * parser->global.report_count; |
233 | 233 | ||
234 | if (!parser->local.usage_index) /* Ignore padding fields */ | 234 | if (!parser->local.usage_index) /* Ignore padding fields */ |
235 | return 0; | 235 | return 0; |
236 | 236 | ||
237 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); | 237 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); |
238 | 238 | ||
@@ -765,7 +765,7 @@ static __inline__ __u32 s32ton(__s32 value, unsigned n) | |||
765 | static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) | 765 | static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) |
766 | { | 766 | { |
767 | report += (offset >> 5) << 2; offset &= 31; | 767 | report += (offset >> 5) << 2; offset &= 31; |
768 | return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1 << n) - 1); | 768 | return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1ULL << n) - 1); |
769 | } | 769 | } |
770 | 770 | ||
771 | static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) | 771 | static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) |
@@ -1233,6 +1233,13 @@ int hid_wait_io(struct hid_device *hid) | |||
1233 | return 0; | 1233 | return 0; |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle) | ||
1237 | { | ||
1238 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1239 | HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, (idle << 8) | report, | ||
1240 | ifnum, NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
1241 | } | ||
1242 | |||
1236 | static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, | 1243 | static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, |
1237 | unsigned char type, void *buf, int size) | 1244 | unsigned char type, void *buf, int size) |
1238 | { | 1245 | { |
@@ -1301,10 +1308,6 @@ void hid_init_reports(struct hid_device *hid) | |||
1301 | 1308 | ||
1302 | if (err) | 1309 | if (err) |
1303 | warn("timeout initializing reports\n"); | 1310 | warn("timeout initializing reports\n"); |
1304 | |||
1305 | usb_control_msg(hid->dev, usb_sndctrlpipe(hid->dev, 0), | ||
1306 | HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, | ||
1307 | hid->ifnum, NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
1308 | } | 1311 | } |
1309 | 1312 | ||
1310 | #define USB_VENDOR_ID_WACOM 0x056a | 1313 | #define USB_VENDOR_ID_WACOM 0x056a |
@@ -1318,6 +1321,10 @@ void hid_init_reports(struct hid_device *hid) | |||
1318 | #define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 | 1321 | #define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 |
1319 | #define USB_DEVICE_ID_WACOM_CINTIQ 0x003F | 1322 | #define USB_DEVICE_ID_WACOM_CINTIQ 0x003F |
1320 | 1323 | ||
1324 | #define USB_VENDOR_ID_ACECAD 0x0460 | ||
1325 | #define USB_DEVICE_ID_ACECAD_FLAIR 0x0004 | ||
1326 | #define USB_DEVICE_ID_ACECAD_302 0x0008 | ||
1327 | |||
1321 | #define USB_VENDOR_ID_KBGEAR 0x084e | 1328 | #define USB_VENDOR_ID_KBGEAR 0x084e |
1322 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 | 1329 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 |
1323 | 1330 | ||
@@ -1502,6 +1509,9 @@ static struct hid_blacklist { | |||
1502 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1509 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
1503 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1510 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
1504 | 1511 | ||
1512 | { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE }, | ||
1513 | { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE }, | ||
1514 | |||
1505 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, | 1515 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, |
1506 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, | 1516 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, |
1507 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, | 1517 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, |
@@ -1590,6 +1600,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1590 | return NULL; | 1600 | return NULL; |
1591 | } | 1601 | } |
1592 | 1602 | ||
1603 | hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0); | ||
1604 | |||
1593 | if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { | 1605 | if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { |
1594 | dbg("reading report descriptor failed"); | 1606 | dbg("reading report descriptor failed"); |
1595 | kfree(rdesc); | 1607 | kfree(rdesc); |
@@ -1635,7 +1647,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1635 | /* Change the polling interval of mice. */ | 1647 | /* Change the polling interval of mice. */ |
1636 | if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) | 1648 | if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) |
1637 | interval = hid_mousepoll_interval; | 1649 | interval = hid_mousepoll_interval; |
1638 | 1650 | ||
1639 | if (endpoint->bEndpointAddress & USB_DIR_IN) { | 1651 | if (endpoint->bEndpointAddress & USB_DIR_IN) { |
1640 | if (hid->urbin) | 1652 | if (hid->urbin) |
1641 | continue; | 1653 | continue; |
diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 2b91705740a7..52437e5e2e78 100644 --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h | |||
@@ -67,7 +67,7 @@ static const struct hid_usage_entry hid_usage_table[] = { | |||
67 | {0, 0x44, "Vbry"}, | 67 | {0, 0x44, "Vbry"}, |
68 | {0, 0x45, "Vbrz"}, | 68 | {0, 0x45, "Vbrz"}, |
69 | {0, 0x46, "Vno"}, | 69 | {0, 0x46, "Vno"}, |
70 | {0, 0x80, "SystemControl"}, | 70 | {0, 0x80, "SystemControl"}, |
71 | {0, 0x81, "SystemPowerDown"}, | 71 | {0, 0x81, "SystemPowerDown"}, |
72 | {0, 0x82, "SystemSleep"}, | 72 | {0, 0x82, "SystemSleep"}, |
73 | {0, 0x83, "SystemWakeUp"}, | 73 | {0, 0x83, "SystemWakeUp"}, |
@@ -347,7 +347,7 @@ __inline__ static void tab(int n) { | |||
347 | 347 | ||
348 | static void hid_dump_field(struct hid_field *field, int n) { | 348 | static void hid_dump_field(struct hid_field *field, int n) { |
349 | int j; | 349 | int j; |
350 | 350 | ||
351 | if (field->physical) { | 351 | if (field->physical) { |
352 | tab(n); | 352 | tab(n); |
353 | printk("Physical("); | 353 | printk("Physical("); |
@@ -408,7 +408,7 @@ static void hid_dump_field(struct hid_field *field, int n) { | |||
408 | printk("%s", units[sys][i]); | 408 | printk("%s", units[sys][i]); |
409 | if(nibble != 1) { | 409 | if(nibble != 1) { |
410 | /* This is a _signed_ nibble(!) */ | 410 | /* This is a _signed_ nibble(!) */ |
411 | 411 | ||
412 | int val = nibble & 0x7; | 412 | int val = nibble & 0x7; |
413 | if(nibble & 0x08) | 413 | if(nibble & 0x08) |
414 | val = -((0x7 & ~val) +1); | 414 | val = -((0x7 & ~val) +1); |
@@ -443,7 +443,7 @@ static void __attribute__((unused)) hid_dump_device(struct hid_device *device) { | |||
443 | struct list_head *list; | 443 | struct list_head *list; |
444 | unsigned i,k; | 444 | unsigned i,k; |
445 | static char *table[] = {"INPUT", "OUTPUT", "FEATURE"}; | 445 | static char *table[] = {"INPUT", "OUTPUT", "FEATURE"}; |
446 | 446 | ||
447 | for (i = 0; i < HID_REPORT_TYPES; i++) { | 447 | for (i = 0; i < HID_REPORT_TYPES; i++) { |
448 | report_enum = device->report_enum + i; | 448 | report_enum = device->report_enum + i; |
449 | list = report_enum->report_list.next; | 449 | list = report_enum->report_list.next; |
@@ -664,8 +664,8 @@ static char *keys[KEY_MAX + 1] = { | |||
664 | static char *relatives[REL_MAX + 1] = { | 664 | static char *relatives[REL_MAX + 1] = { |
665 | [REL_X] = "X", [REL_Y] = "Y", | 665 | [REL_X] = "X", [REL_Y] = "Y", |
666 | [REL_Z] = "Z", [REL_HWHEEL] = "HWheel", | 666 | [REL_Z] = "Z", [REL_HWHEEL] = "HWheel", |
667 | [REL_DIAL] = "Dial", [REL_WHEEL] = "Wheel", | 667 | [REL_DIAL] = "Dial", [REL_WHEEL] = "Wheel", |
668 | [REL_MISC] = "Misc", | 668 | [REL_MISC] = "Misc", |
669 | }; | 669 | }; |
670 | 670 | ||
671 | static char *absolutes[ABS_MAX + 1] = { | 671 | static char *absolutes[ABS_MAX + 1] = { |
@@ -690,9 +690,9 @@ static char *misc[MSC_MAX + 1] = { | |||
690 | }; | 690 | }; |
691 | 691 | ||
692 | static char *leds[LED_MAX + 1] = { | 692 | static char *leds[LED_MAX + 1] = { |
693 | [LED_NUML] = "NumLock", [LED_CAPSL] = "CapsLock", | 693 | [LED_NUML] = "NumLock", [LED_CAPSL] = "CapsLock", |
694 | [LED_SCROLLL] = "ScrollLock", [LED_COMPOSE] = "Compose", | 694 | [LED_SCROLLL] = "ScrollLock", [LED_COMPOSE] = "Compose", |
695 | [LED_KANA] = "Kana", [LED_SLEEP] = "Sleep", | 695 | [LED_KANA] = "Kana", [LED_SLEEP] = "Sleep", |
696 | [LED_SUSPEND] = "Suspend", [LED_MUTE] = "Mute", | 696 | [LED_SUSPEND] = "Suspend", [LED_MUTE] = "Mute", |
697 | [LED_MISC] = "Misc", | 697 | [LED_MISC] = "Misc", |
698 | }; | 698 | }; |
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 5553c3553e9d..9ac1e9095334 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c | |||
@@ -164,7 +164,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
164 | case HID_GD_X: case HID_GD_Y: case HID_GD_Z: | 164 | case HID_GD_X: case HID_GD_Y: case HID_GD_Z: |
165 | case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: | 165 | case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: |
166 | case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL: | 166 | case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL: |
167 | if (field->flags & HID_MAIN_ITEM_RELATIVE) | 167 | if (field->flags & HID_MAIN_ITEM_RELATIVE) |
168 | map_rel(usage->hid & 0xf); | 168 | map_rel(usage->hid & 0xf); |
169 | else | 169 | else |
170 | map_abs(usage->hid & 0xf); | 170 | map_abs(usage->hid & 0xf); |
@@ -297,7 +297,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
297 | case HID_UP_MSVENDOR: | 297 | case HID_UP_MSVENDOR: |
298 | 298 | ||
299 | goto ignore; | 299 | goto ignore; |
300 | 300 | ||
301 | case HID_UP_PID: | 301 | case HID_UP_PID: |
302 | 302 | ||
303 | set_bit(EV_FF, input->evbit); | 303 | set_bit(EV_FF, input->evbit); |
@@ -349,7 +349,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
349 | goto ignore; | 349 | goto ignore; |
350 | 350 | ||
351 | if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && | 351 | if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && |
352 | (usage->type == EV_REL) && (usage->code == REL_WHEEL)) | 352 | (usage->type == EV_REL) && (usage->code == REL_WHEEL)) |
353 | set_bit(REL_HWHEEL, bit); | 353 | set_bit(REL_HWHEEL, bit); |
354 | 354 | ||
355 | if (((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005)) | 355 | if (((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005)) |
@@ -365,11 +365,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
365 | a = field->logical_minimum = 0; | 365 | a = field->logical_minimum = 0; |
366 | b = field->logical_maximum = 255; | 366 | b = field->logical_maximum = 255; |
367 | } | 367 | } |
368 | 368 | ||
369 | if (field->application == HID_GD_GAMEPAD || field->application == HID_GD_JOYSTICK) | 369 | if (field->application == HID_GD_GAMEPAD || field->application == HID_GD_JOYSTICK) |
370 | input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); | 370 | input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); |
371 | else input_set_abs_params(input, usage->code, a, b, 0, 0); | 371 | else input_set_abs_params(input, usage->code, a, b, 0, 0); |
372 | 372 | ||
373 | } | 373 | } |
374 | 374 | ||
375 | if (usage->hat_min < usage->hat_max || usage->hat_dir) { | 375 | if (usage->hat_min < usage->hat_max || usage->hat_dir) { |
@@ -420,7 +420,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | 422 | ||
423 | if (usage->hat_min < usage->hat_max || usage->hat_dir) { | 423 | if (usage->hat_min < usage->hat_max || usage->hat_dir) { |
424 | int hat_dir = usage->hat_dir; | 424 | int hat_dir = usage->hat_dir; |
425 | if (!hat_dir) | 425 | if (!hat_dir) |
426 | hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1; | 426 | hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1; |
@@ -551,7 +551,7 @@ int hidinput_connect(struct hid_device *hid) | |||
551 | for (i = 0; i < hid->maxcollection; i++) | 551 | for (i = 0; i < hid->maxcollection; i++) |
552 | if (hid->collection[i].type == HID_COLLECTION_APPLICATION || | 552 | if (hid->collection[i].type == HID_COLLECTION_APPLICATION || |
553 | hid->collection[i].type == HID_COLLECTION_PHYSICAL) | 553 | hid->collection[i].type == HID_COLLECTION_PHYSICAL) |
554 | if (IS_INPUT_APPLICATION(hid->collection[i].usage)) | 554 | if (IS_INPUT_APPLICATION(hid->collection[i].usage)) |
555 | break; | 555 | break; |
556 | 556 | ||
557 | if (i == hid->maxcollection) | 557 | if (i == hid->maxcollection) |
@@ -592,7 +592,7 @@ int hidinput_connect(struct hid_device *hid) | |||
592 | for (j = 0; j < report->field[i]->maxusage; j++) | 592 | for (j = 0; j < report->field[i]->maxusage; j++) |
593 | hidinput_configure_usage(hidinput, report->field[i], | 593 | hidinput_configure_usage(hidinput, report->field[i], |
594 | report->field[i]->usage + j); | 594 | report->field[i]->usage + j); |
595 | 595 | ||
596 | if (hid->quirks & HID_QUIRK_MULTI_INPUT) { | 596 | if (hid->quirks & HID_QUIRK_MULTI_INPUT) { |
597 | /* This will leave hidinput NULL, so that it | 597 | /* This will leave hidinput NULL, so that it |
598 | * allocates another one if we have more inputs on | 598 | * allocates another one if we have more inputs on |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index 0d7404bab92f..0c4c77aa31ea 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
@@ -94,7 +94,7 @@ struct lgff_device { | |||
94 | isn't really necessary */ | 94 | isn't really necessary */ |
95 | 95 | ||
96 | unsigned long flags[1]; /* Contains various information about the | 96 | unsigned long flags[1]; /* Contains various information about the |
97 | state of the driver for this device */ | 97 | state of the driver for this device */ |
98 | 98 | ||
99 | struct timer_list timer; | 99 | struct timer_list timer; |
100 | }; | 100 | }; |
@@ -234,7 +234,7 @@ static struct hid_report* hid_lgff_duplicate_report(struct hid_report* report) | |||
234 | kfree(ret); | 234 | kfree(ret); |
235 | return NULL; | 235 | return NULL; |
236 | } | 236 | } |
237 | memset(ret->field[0]->value, 0, sizeof(s32[8])); | 237 | memset(ret->field[0]->value, 0, sizeof(s32[8])); |
238 | 238 | ||
239 | return ret; | 239 | return ret; |
240 | } | 240 | } |
@@ -295,11 +295,11 @@ static int hid_lgff_event(struct hid_device *hid, struct input_dev* input, | |||
295 | unsigned long flags; | 295 | unsigned long flags; |
296 | 296 | ||
297 | if (type != EV_FF) return -EINVAL; | 297 | if (type != EV_FF) return -EINVAL; |
298 | if (!LGFF_CHECK_OWNERSHIP(code, lgff)) return -EACCES; | 298 | if (!LGFF_CHECK_OWNERSHIP(code, lgff)) return -EACCES; |
299 | if (value < 0) return -EINVAL; | 299 | if (value < 0) return -EINVAL; |
300 | 300 | ||
301 | spin_lock_irqsave(&lgff->lock, flags); | 301 | spin_lock_irqsave(&lgff->lock, flags); |
302 | 302 | ||
303 | if (value > 0) { | 303 | if (value > 0) { |
304 | if (test_bit(EFFECT_STARTED, effect->flags)) { | 304 | if (test_bit(EFFECT_STARTED, effect->flags)) { |
305 | spin_unlock_irqrestore(&lgff->lock, flags); | 305 | spin_unlock_irqrestore(&lgff->lock, flags); |
@@ -345,7 +345,7 @@ static int hid_lgff_flush(struct input_dev *dev, struct file *file) | |||
345 | and perform ioctls on the same fd all at the same time */ | 345 | and perform ioctls on the same fd all at the same time */ |
346 | if ( current->pid == lgff->effects[i].owner | 346 | if ( current->pid == lgff->effects[i].owner |
347 | && test_bit(EFFECT_USED, lgff->effects[i].flags)) { | 347 | && test_bit(EFFECT_USED, lgff->effects[i].flags)) { |
348 | 348 | ||
349 | if (hid_lgff_erase(dev, i)) | 349 | if (hid_lgff_erase(dev, i)) |
350 | warn("erase effect %d failed", i); | 350 | warn("erase effect %d failed", i); |
351 | } | 351 | } |
@@ -378,7 +378,7 @@ static int hid_lgff_upload_effect(struct input_dev* input, | |||
378 | struct lgff_effect new; | 378 | struct lgff_effect new; |
379 | int id; | 379 | int id; |
380 | unsigned long flags; | 380 | unsigned long flags; |
381 | 381 | ||
382 | dbg("ioctl rumble"); | 382 | dbg("ioctl rumble"); |
383 | 383 | ||
384 | if (!test_bit(effect->type, input->ffbit)) return -EINVAL; | 384 | if (!test_bit(effect->type, input->ffbit)) return -EINVAL; |
@@ -441,7 +441,7 @@ static void hid_lgff_timer(unsigned long timer_data) | |||
441 | 441 | ||
442 | spin_lock_irqsave(&lgff->lock, flags); | 442 | spin_lock_irqsave(&lgff->lock, flags); |
443 | 443 | ||
444 | for (i=0; i<LGFF_EFFECTS; ++i) { | 444 | for (i=0; i<LGFF_EFFECTS; ++i) { |
445 | struct lgff_effect* effect = lgff->effects +i; | 445 | struct lgff_effect* effect = lgff->effects +i; |
446 | 446 | ||
447 | if (test_bit(EFFECT_PLAYING, effect->flags)) { | 447 | if (test_bit(EFFECT_PLAYING, effect->flags)) { |
@@ -491,7 +491,7 @@ static void hid_lgff_timer(unsigned long timer_data) | |||
491 | set_bit(EFFECT_PLAYING, lgff->effects[i].flags); | 491 | set_bit(EFFECT_PLAYING, lgff->effects[i].flags); |
492 | } | 492 | } |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||
496 | #define CLAMP(x) if (x < 0) x = 0; if (x > 0xff) x = 0xff | 496 | #define CLAMP(x) if (x < 0) x = 0; if (x > 0xff) x = 0xff |
497 | 497 | ||
@@ -524,5 +524,5 @@ static void hid_lgff_timer(unsigned long timer_data) | |||
524 | add_timer(&lgff->timer); | 524 | add_timer(&lgff->timer); |
525 | } | 525 | } |
526 | 526 | ||
527 | spin_unlock_irqrestore(&lgff->lock, flags); | 527 | spin_unlock_irqrestore(&lgff->lock, flags); |
528 | } | 528 | } |
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index 6d9329c698d9..c1b6b69bc4a4 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h | |||
@@ -118,7 +118,7 @@ struct hid_item { | |||
118 | #define HID_MAIN_ITEM_CONSTANT 0x001 | 118 | #define HID_MAIN_ITEM_CONSTANT 0x001 |
119 | #define HID_MAIN_ITEM_VARIABLE 0x002 | 119 | #define HID_MAIN_ITEM_VARIABLE 0x002 |
120 | #define HID_MAIN_ITEM_RELATIVE 0x004 | 120 | #define HID_MAIN_ITEM_RELATIVE 0x004 |
121 | #define HID_MAIN_ITEM_WRAP 0x008 | 121 | #define HID_MAIN_ITEM_WRAP 0x008 |
122 | #define HID_MAIN_ITEM_NONLINEAR 0x010 | 122 | #define HID_MAIN_ITEM_NONLINEAR 0x010 |
123 | #define HID_MAIN_ITEM_NO_PREFERRED 0x020 | 123 | #define HID_MAIN_ITEM_NO_PREFERRED 0x020 |
124 | #define HID_MAIN_ITEM_NULL_STATE 0x040 | 124 | #define HID_MAIN_ITEM_NULL_STATE 0x040 |
@@ -172,14 +172,14 @@ struct hid_item { | |||
172 | #define HID_USAGE_PAGE 0xffff0000 | 172 | #define HID_USAGE_PAGE 0xffff0000 |
173 | 173 | ||
174 | #define HID_UP_UNDEFINED 0x00000000 | 174 | #define HID_UP_UNDEFINED 0x00000000 |
175 | #define HID_UP_GENDESK 0x00010000 | 175 | #define HID_UP_GENDESK 0x00010000 |
176 | #define HID_UP_KEYBOARD 0x00070000 | 176 | #define HID_UP_KEYBOARD 0x00070000 |
177 | #define HID_UP_LED 0x00080000 | 177 | #define HID_UP_LED 0x00080000 |
178 | #define HID_UP_BUTTON 0x00090000 | 178 | #define HID_UP_BUTTON 0x00090000 |
179 | #define HID_UP_ORDINAL 0x000a0000 | 179 | #define HID_UP_ORDINAL 0x000a0000 |
180 | #define HID_UP_CONSUMER 0x000c0000 | 180 | #define HID_UP_CONSUMER 0x000c0000 |
181 | #define HID_UP_DIGITIZER 0x000d0000 | 181 | #define HID_UP_DIGITIZER 0x000d0000 |
182 | #define HID_UP_PID 0x000f0000 | 182 | #define HID_UP_PID 0x000f0000 |
183 | #define HID_UP_HPVENDOR 0xff7f0000 | 183 | #define HID_UP_HPVENDOR 0xff7f0000 |
184 | #define HID_UP_MSVENDOR 0xff000000 | 184 | #define HID_UP_MSVENDOR 0xff000000 |
185 | 185 | ||
@@ -406,7 +406,7 @@ struct hid_device { /* device report descriptor */ | |||
406 | dma_addr_t outbuf_dma; /* Output buffer dma */ | 406 | dma_addr_t outbuf_dma; /* Output buffer dma */ |
407 | spinlock_t outlock; /* Output fifo spinlock */ | 407 | spinlock_t outlock; /* Output fifo spinlock */ |
408 | 408 | ||
409 | unsigned claimed; /* Claimed by hidinput, hiddev? */ | 409 | unsigned claimed; /* Claimed by hidinput, hiddev? */ |
410 | unsigned quirks; /* Various quirks the device can pull on us */ | 410 | unsigned quirks; /* Various quirks the device can pull on us */ |
411 | 411 | ||
412 | struct list_head inputs; /* The list of inputs */ | 412 | struct list_head inputs; /* The list of inputs */ |
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 96b7c9067951..4c13331b5f41 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c | |||
@@ -95,7 +95,7 @@ hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo) | |||
95 | return NULL; | 95 | return NULL; |
96 | rinfo->report_id = ((struct hid_report *) list)->id; | 96 | rinfo->report_id = ((struct hid_report *) list)->id; |
97 | break; | 97 | break; |
98 | 98 | ||
99 | case HID_REPORT_ID_NEXT: | 99 | case HID_REPORT_ID_NEXT: |
100 | list = (struct list_head *) | 100 | list = (struct list_head *) |
101 | report_enum->report_id_hash[rinfo->report_id & HID_REPORT_ID_MASK]; | 101 | report_enum->report_id_hash[rinfo->report_id & HID_REPORT_ID_MASK]; |
@@ -106,7 +106,7 @@ hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo) | |||
106 | return NULL; | 106 | return NULL; |
107 | rinfo->report_id = ((struct hid_report *) list)->id; | 107 | rinfo->report_id = ((struct hid_report *) list)->id; |
108 | break; | 108 | break; |
109 | 109 | ||
110 | default: | 110 | default: |
111 | return NULL; | 111 | return NULL; |
112 | } | 112 | } |
@@ -158,7 +158,7 @@ static void hiddev_send_event(struct hid_device *hid, | |||
158 | if (uref->field_index != HID_FIELD_INDEX_NONE || | 158 | if (uref->field_index != HID_FIELD_INDEX_NONE || |
159 | (list->flags & HIDDEV_FLAG_REPORT) != 0) { | 159 | (list->flags & HIDDEV_FLAG_REPORT) != 0) { |
160 | list->buffer[list->head] = *uref; | 160 | list->buffer[list->head] = *uref; |
161 | list->head = (list->head + 1) & | 161 | list->head = (list->head + 1) & |
162 | (HIDDEV_BUFFER_SIZE - 1); | 162 | (HIDDEV_BUFFER_SIZE - 1); |
163 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 163 | kill_fasync(&list->fasync, SIGIO, POLL_IN); |
164 | } | 164 | } |
@@ -179,9 +179,9 @@ void hiddev_hid_event(struct hid_device *hid, struct hid_field *field, | |||
179 | unsigned type = field->report_type; | 179 | unsigned type = field->report_type; |
180 | struct hiddev_usage_ref uref; | 180 | struct hiddev_usage_ref uref; |
181 | 181 | ||
182 | uref.report_type = | 182 | uref.report_type = |
183 | (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : | 183 | (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : |
184 | ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : | 184 | ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : |
185 | ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); | 185 | ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); |
186 | uref.report_id = field->report->id; | 186 | uref.report_id = field->report->id; |
187 | uref.field_index = field->index; | 187 | uref.field_index = field->index; |
@@ -199,9 +199,9 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report) | |||
199 | struct hiddev_usage_ref uref; | 199 | struct hiddev_usage_ref uref; |
200 | 200 | ||
201 | memset(&uref, 0, sizeof(uref)); | 201 | memset(&uref, 0, sizeof(uref)); |
202 | uref.report_type = | 202 | uref.report_type = |
203 | (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : | 203 | (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : |
204 | ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : | 204 | ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : |
205 | ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); | 205 | ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); |
206 | uref.report_id = report->id; | 206 | uref.report_id = report->id; |
207 | uref.field_index = HID_FIELD_INDEX_NONE; | 207 | uref.field_index = HID_FIELD_INDEX_NONE; |
@@ -236,7 +236,7 @@ static int hiddev_release(struct inode * inode, struct file * file) | |||
236 | *listptr = (*listptr)->next; | 236 | *listptr = (*listptr)->next; |
237 | 237 | ||
238 | if (!--list->hiddev->open) { | 238 | if (!--list->hiddev->open) { |
239 | if (list->hiddev->exist) | 239 | if (list->hiddev->exist) |
240 | hid_close(list->hiddev->hid); | 240 | hid_close(list->hiddev->hid); |
241 | else | 241 | else |
242 | kfree(list->hiddev); | 242 | kfree(list->hiddev); |
@@ -303,7 +303,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun | |||
303 | if (list->head == list->tail) { | 303 | if (list->head == list->tail) { |
304 | add_wait_queue(&list->hiddev->wait, &wait); | 304 | add_wait_queue(&list->hiddev->wait, &wait); |
305 | set_current_state(TASK_INTERRUPTIBLE); | 305 | set_current_state(TASK_INTERRUPTIBLE); |
306 | 306 | ||
307 | while (list->head == list->tail) { | 307 | while (list->head == list->tail) { |
308 | if (file->f_flags & O_NONBLOCK) { | 308 | if (file->f_flags & O_NONBLOCK) { |
309 | retval = -EAGAIN; | 309 | retval = -EAGAIN; |
@@ -317,7 +317,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun | |||
317 | retval = -EIO; | 317 | retval = -EIO; |
318 | break; | 318 | break; |
319 | } | 319 | } |
320 | 320 | ||
321 | schedule(); | 321 | schedule(); |
322 | } | 322 | } |
323 | 323 | ||
@@ -329,7 +329,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun | |||
329 | return retval; | 329 | return retval; |
330 | 330 | ||
331 | 331 | ||
332 | while (list->head != list->tail && | 332 | while (list->head != list->tail && |
333 | retval + event_size <= count) { | 333 | retval + event_size <= count) { |
334 | if ((list->flags & HIDDEV_FLAG_UREF) == 0) { | 334 | if ((list->flags & HIDDEV_FLAG_UREF) == 0) { |
335 | if (list->buffer[list->tail].field_index != | 335 | if (list->buffer[list->tail].field_index != |
@@ -405,10 +405,10 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
405 | return -EINVAL; | 405 | return -EINVAL; |
406 | 406 | ||
407 | for (i = 0; i < hid->maxcollection; i++) | 407 | for (i = 0; i < hid->maxcollection; i++) |
408 | if (hid->collection[i].type == | 408 | if (hid->collection[i].type == |
409 | HID_COLLECTION_APPLICATION && arg-- == 0) | 409 | HID_COLLECTION_APPLICATION && arg-- == 0) |
410 | break; | 410 | break; |
411 | 411 | ||
412 | if (i == hid->maxcollection) | 412 | if (i == hid->maxcollection) |
413 | return -EINVAL; | 413 | return -EINVAL; |
414 | 414 | ||
@@ -562,7 +562,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
562 | if (!uref_multi) | 562 | if (!uref_multi) |
563 | return -ENOMEM; | 563 | return -ENOMEM; |
564 | uref = &uref_multi->uref; | 564 | uref = &uref_multi->uref; |
565 | if (copy_from_user(uref, user_arg, sizeof(*uref))) | 565 | if (copy_from_user(uref, user_arg, sizeof(*uref))) |
566 | goto fault; | 566 | goto fault; |
567 | 567 | ||
568 | rinfo.report_type = uref->report_type; | 568 | rinfo.report_type = uref->report_type; |
@@ -595,7 +595,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
595 | return -ENOMEM; | 595 | return -ENOMEM; |
596 | uref = &uref_multi->uref; | 596 | uref = &uref_multi->uref; |
597 | if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) { | 597 | if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) { |
598 | if (copy_from_user(uref_multi, user_arg, | 598 | if (copy_from_user(uref_multi, user_arg, |
599 | sizeof(*uref_multi))) | 599 | sizeof(*uref_multi))) |
600 | goto fault; | 600 | goto fault; |
601 | } else { | 601 | } else { |
@@ -603,7 +603,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
603 | goto fault; | 603 | goto fault; |
604 | } | 604 | } |
605 | 605 | ||
606 | if (cmd != HIDIOCGUSAGE && | 606 | if (cmd != HIDIOCGUSAGE && |
607 | cmd != HIDIOCGUSAGES && | 607 | cmd != HIDIOCGUSAGES && |
608 | uref->report_type == HID_REPORT_TYPE_INPUT) | 608 | uref->report_type == HID_REPORT_TYPE_INPUT) |
609 | goto inval; | 609 | goto inval; |
@@ -651,16 +651,16 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
651 | return field->usage[uref->usage_index].collection_index; | 651 | return field->usage[uref->usage_index].collection_index; |
652 | case HIDIOCGUSAGES: | 652 | case HIDIOCGUSAGES: |
653 | for (i = 0; i < uref_multi->num_values; i++) | 653 | for (i = 0; i < uref_multi->num_values; i++) |
654 | uref_multi->values[i] = | 654 | uref_multi->values[i] = |
655 | field->value[uref->usage_index + i]; | 655 | field->value[uref->usage_index + i]; |
656 | if (copy_to_user(user_arg, uref_multi, | 656 | if (copy_to_user(user_arg, uref_multi, |
657 | sizeof(*uref_multi))) | 657 | sizeof(*uref_multi))) |
658 | goto fault; | 658 | goto fault; |
659 | goto goodreturn; | 659 | goto goodreturn; |
660 | case HIDIOCSUSAGES: | 660 | case HIDIOCSUSAGES: |
661 | for (i = 0; i < uref_multi->num_values; i++) | 661 | for (i = 0; i < uref_multi->num_values; i++) |
662 | field->value[uref->usage_index + i] = | 662 | field->value[uref->usage_index + i] = |
663 | uref_multi->values[i]; | 663 | uref_multi->values[i]; |
664 | goto goodreturn; | 664 | goto goodreturn; |
665 | } | 665 | } |
666 | 666 | ||
@@ -670,7 +670,7 @@ goodreturn: | |||
670 | fault: | 670 | fault: |
671 | kfree(uref_multi); | 671 | kfree(uref_multi); |
672 | return -EFAULT; | 672 | return -EFAULT; |
673 | inval: | 673 | inval: |
674 | kfree(uref_multi); | 674 | kfree(uref_multi); |
675 | return -EINVAL; | 675 | return -EINVAL; |
676 | 676 | ||
@@ -734,7 +734,7 @@ static struct usb_class_driver hiddev_class = { | |||
734 | .name = "usb/hid/hiddev%d", | 734 | .name = "usb/hid/hiddev%d", |
735 | .fops = &hiddev_fops, | 735 | .fops = &hiddev_fops, |
736 | .mode = S_IFCHR | S_IRUGO | S_IWUSR, | 736 | .mode = S_IFCHR | S_IRUGO | S_IWUSR, |
737 | .minor_base = HIDDEV_MINOR_BASE, | 737 | .minor_base = HIDDEV_MINOR_BASE, |
738 | }; | 738 | }; |
739 | 739 | ||
740 | /* | 740 | /* |
@@ -747,7 +747,7 @@ int hiddev_connect(struct hid_device *hid) | |||
747 | int retval; | 747 | int retval; |
748 | 748 | ||
749 | for (i = 0; i < hid->maxcollection; i++) | 749 | for (i = 0; i < hid->maxcollection; i++) |
750 | if (hid->collection[i].type == | 750 | if (hid->collection[i].type == |
751 | HID_COLLECTION_APPLICATION && | 751 | HID_COLLECTION_APPLICATION && |
752 | !IS_INPUT_APPLICATION(hid->collection[i].usage)) | 752 | !IS_INPUT_APPLICATION(hid->collection[i].usage)) |
753 | break; | 753 | break; |
@@ -755,11 +755,11 @@ int hiddev_connect(struct hid_device *hid) | |||
755 | if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) | 755 | if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) |
756 | return -1; | 756 | return -1; |
757 | 757 | ||
758 | if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) | 758 | if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) |
759 | return -1; | 759 | return -1; |
760 | memset(hiddev, 0, sizeof(struct hiddev)); | 760 | memset(hiddev, 0, sizeof(struct hiddev)); |
761 | 761 | ||
762 | retval = usb_register_dev(hid->intf, &hiddev_class); | 762 | retval = usb_register_dev(hid->intf, &hiddev_class); |
763 | if (retval) { | 763 | if (retval) { |
764 | err("Not able to get a minor for this device."); | 764 | err("Not able to get a minor for this device."); |
765 | kfree(hiddev); | 765 | kfree(hiddev); |
@@ -768,12 +768,12 @@ int hiddev_connect(struct hid_device *hid) | |||
768 | 768 | ||
769 | init_waitqueue_head(&hiddev->wait); | 769 | init_waitqueue_head(&hiddev->wait); |
770 | 770 | ||
771 | hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; | 771 | hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; |
772 | 772 | ||
773 | hiddev->hid = hid; | 773 | hiddev->hid = hid; |
774 | hiddev->exist = 1; | 774 | hiddev->exist = 1; |
775 | 775 | ||
776 | hid->minor = hid->intf->minor; | 776 | hid->minor = hid->intf->minor; |
777 | hid->hiddev = hiddev; | 777 | hid->hiddev = hiddev; |
778 | 778 | ||
779 | return 0; | 779 | return 0; |
@@ -818,7 +818,7 @@ void hiddev_disconnect(struct hid_device *hid) | |||
818 | /* We never attach in this manner, and rely on HID to connect us. This | 818 | /* We never attach in this manner, and rely on HID to connect us. This |
819 | * is why there is no disconnect routine defined in the usb_driver either. | 819 | * is why there is no disconnect routine defined in the usb_driver either. |
820 | */ | 820 | */ |
821 | static int hiddev_usbd_probe(struct usb_interface *intf, | 821 | static int hiddev_usbd_probe(struct usb_interface *intf, |
822 | const struct usb_device_id *hiddev_info) | 822 | const struct usb_device_id *hiddev_info) |
823 | { | 823 | { |
824 | return -ENODEV; | 824 | return -ENODEV; |
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c new file mode 100644 index 000000000000..47dec6a1b344 --- /dev/null +++ b/drivers/usb/input/itmtouch.c | |||
@@ -0,0 +1,268 @@ | |||
1 | /****************************************************************************** | ||
2 | * itmtouch.c -- Driver for ITM touchscreen panel | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation; either version 2 of the | ||
7 | * License, or (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | * | ||
18 | * Based upon original work by Chris Collins <xfire-itmtouch@xware.cx>. | ||
19 | * | ||
20 | * Kudos to ITM for providing me with the datasheet for the panel, | ||
21 | * even though it was a day later than I had finished writing this | ||
22 | * driver. | ||
23 | * | ||
24 | * It has meant that I've been able to correct my interpretation of the | ||
25 | * protocol packets however. | ||
26 | * | ||
27 | * CC -- 2003/9/29 | ||
28 | * | ||
29 | * History | ||
30 | * 1.0 & 1.1 2003 (CC) vojtech@suse.cz | ||
31 | * Original version for 2.4.x kernels | ||
32 | * | ||
33 | * 1.2 02/03/2005 (HCE) hc@mivu.no | ||
34 | * Complete rewrite to support Linux 2.6.10, thanks to mtouchusb.c for hints. | ||
35 | * Unfortunately no calibration support at this time. | ||
36 | * | ||
37 | * 1.2.1 09/03/2005 (HCE) hc@mivu.no | ||
38 | * Code cleanup and adjusting syntax to start matching kernel standards | ||
39 | * | ||
40 | *****************************************************************************/ | ||
41 | |||
42 | #include <linux/config.h> | ||
43 | |||
44 | #ifdef CONFIG_USB_DEBUG | ||
45 | #define DEBUG | ||
46 | #else | ||
47 | #undef DEBUG | ||
48 | #endif | ||
49 | |||
50 | #include <linux/kernel.h> | ||
51 | #include <linux/slab.h> | ||
52 | #include <linux/input.h> | ||
53 | #include <linux/module.h> | ||
54 | #include <linux/init.h> | ||
55 | #include <linux/usb.h> | ||
56 | |||
57 | /* only an 8 byte buffer necessary for a single packet */ | ||
58 | #define ITM_BUFSIZE 8 | ||
59 | #define PATH_SIZE 64 | ||
60 | |||
61 | #define USB_VENDOR_ID_ITMINC 0x0403 | ||
62 | #define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9 | ||
63 | |||
64 | #define DRIVER_AUTHOR "Hans-Christian Egtvedt <hc@mivu.no>" | ||
65 | #define DRIVER_VERSION "v1.2.1" | ||
66 | #define DRIVER_DESC "USB ITM Inc Touch Panel Driver" | ||
67 | #define DRIVER_LICENSE "GPL" | ||
68 | |||
69 | MODULE_AUTHOR( DRIVER_AUTHOR ); | ||
70 | MODULE_DESCRIPTION( DRIVER_DESC ); | ||
71 | MODULE_LICENSE( DRIVER_LICENSE ); | ||
72 | |||
73 | struct itmtouch_dev { | ||
74 | struct usb_device *usbdev; /* usb device */ | ||
75 | struct input_dev inputdev; /* input device */ | ||
76 | struct urb *readurb; /* urb */ | ||
77 | char rbuf[ITM_BUFSIZE]; /* data */ | ||
78 | int users; | ||
79 | char name[128]; | ||
80 | char phys[64]; | ||
81 | }; | ||
82 | |||
83 | static struct usb_device_id itmtouch_ids [] = { | ||
84 | { USB_DEVICE(USB_VENDOR_ID_ITMINC, USB_PRODUCT_ID_TOUCHPANEL) }, | ||
85 | { } | ||
86 | }; | ||
87 | |||
88 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) | ||
89 | { | ||
90 | struct itmtouch_dev * itmtouch = urb->context; | ||
91 | unsigned char *data = urb->transfer_buffer; | ||
92 | struct input_dev *dev = &itmtouch->inputdev; | ||
93 | int retval; | ||
94 | |||
95 | switch (urb->status) { | ||
96 | case 0: | ||
97 | /* success */ | ||
98 | break; | ||
99 | case -ETIMEDOUT: | ||
100 | /* this urb is timing out */ | ||
101 | dbg("%s - urb timed out - was the device unplugged?", | ||
102 | __FUNCTION__); | ||
103 | return; | ||
104 | case -ECONNRESET: | ||
105 | case -ENOENT: | ||
106 | case -ESHUTDOWN: | ||
107 | /* this urb is terminated, clean up */ | ||
108 | dbg("%s - urb shutting down with status: %d", | ||
109 | __FUNCTION__, urb->status); | ||
110 | return; | ||
111 | default: | ||
112 | dbg("%s - nonzero urb status received: %d", | ||
113 | __FUNCTION__, urb->status); | ||
114 | goto exit; | ||
115 | } | ||
116 | |||
117 | input_regs(dev, regs); | ||
118 | |||
119 | /* if pressure has been released, then don't report X/Y */ | ||
120 | if (data[7] & 0x20) { | ||
121 | input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F)); | ||
122 | input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F)); | ||
123 | } | ||
124 | |||
125 | input_report_abs(dev, ABS_PRESSURE, (data[2] & 1) << 7 | (data[5] & 0x7F)); | ||
126 | input_report_key(dev, BTN_TOUCH, ~data[7] & 0x20); | ||
127 | input_sync(dev); | ||
128 | |||
129 | exit: | ||
130 | retval = usb_submit_urb (urb, GFP_ATOMIC); | ||
131 | if (retval) | ||
132 | printk(KERN_ERR "%s - usb_submit_urb failed with result: %d", | ||
133 | __FUNCTION__, retval); | ||
134 | } | ||
135 | |||
136 | static int itmtouch_open(struct input_dev *input) | ||
137 | { | ||
138 | struct itmtouch_dev *itmtouch = input->private; | ||
139 | |||
140 | itmtouch->readurb->dev = itmtouch->usbdev; | ||
141 | |||
142 | if (usb_submit_urb(itmtouch->readurb, GFP_KERNEL)) | ||
143 | return -EIO; | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static void itmtouch_close(struct input_dev *input) | ||
149 | { | ||
150 | struct itmtouch_dev *itmtouch = input->private; | ||
151 | |||
152 | usb_kill_urb(itmtouch->readurb); | ||
153 | } | ||
154 | |||
155 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
156 | { | ||
157 | struct itmtouch_dev *itmtouch; | ||
158 | struct usb_host_interface *interface; | ||
159 | struct usb_endpoint_descriptor *endpoint; | ||
160 | struct usb_device *udev = interface_to_usbdev(intf); | ||
161 | unsigned int pipe; | ||
162 | unsigned int maxp; | ||
163 | char path[PATH_SIZE]; | ||
164 | |||
165 | interface = intf->cur_altsetting; | ||
166 | endpoint = &interface->endpoint[0].desc; | ||
167 | |||
168 | if (!(itmtouch = kcalloc(1, sizeof(struct itmtouch_dev), GFP_KERNEL))) { | ||
169 | err("%s - Out of memory.", __FUNCTION__); | ||
170 | return -ENOMEM; | ||
171 | } | ||
172 | |||
173 | itmtouch->usbdev = udev; | ||
174 | |||
175 | itmtouch->inputdev.private = itmtouch; | ||
176 | itmtouch->inputdev.open = itmtouch_open; | ||
177 | itmtouch->inputdev.close = itmtouch_close; | ||
178 | |||
179 | usb_make_path(udev, path, PATH_SIZE); | ||
180 | |||
181 | itmtouch->inputdev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
182 | itmtouch->inputdev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
183 | itmtouch->inputdev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
184 | |||
185 | itmtouch->inputdev.name = itmtouch->name; | ||
186 | itmtouch->inputdev.phys = itmtouch->phys; | ||
187 | itmtouch->inputdev.id.bustype = BUS_USB; | ||
188 | itmtouch->inputdev.id.vendor = udev->descriptor.idVendor; | ||
189 | itmtouch->inputdev.id.product = udev->descriptor.idProduct; | ||
190 | itmtouch->inputdev.id.version = udev->descriptor.bcdDevice; | ||
191 | itmtouch->inputdev.dev = &intf->dev; | ||
192 | |||
193 | if (!strlen(itmtouch->name)) | ||
194 | sprintf(itmtouch->name, "USB ITM touchscreen"); | ||
195 | |||
196 | /* device limits */ | ||
197 | /* as specified by the ITM datasheet, X and Y are 12bit, | ||
198 | * Z (pressure) is 8 bit. However, the fields are defined up | ||
199 | * to 14 bits for future possible expansion. | ||
200 | */ | ||
201 | input_set_abs_params(&itmtouch->inputdev, ABS_X, 0, 0x0FFF, 2, 0); | ||
202 | input_set_abs_params(&itmtouch->inputdev, ABS_Y, 0, 0x0FFF, 2, 0); | ||
203 | input_set_abs_params(&itmtouch->inputdev, ABS_PRESSURE, 0, 0xFF, 2, 0); | ||
204 | |||
205 | /* initialise the URB so we can read from the transport stream */ | ||
206 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); | ||
207 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | ||
208 | |||
209 | if (maxp > ITM_BUFSIZE) | ||
210 | maxp = ITM_BUFSIZE; | ||
211 | |||
212 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); | ||
213 | |||
214 | if (!itmtouch->readurb) { | ||
215 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); | ||
216 | kfree(itmtouch); | ||
217 | return -ENOMEM; | ||
218 | } | ||
219 | |||
220 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, | ||
221 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); | ||
222 | |||
223 | input_register_device(&itmtouch->inputdev); | ||
224 | |||
225 | printk(KERN_INFO "itmtouch: %s registered on %s\n", itmtouch->name, path); | ||
226 | usb_set_intfdata(intf, itmtouch); | ||
227 | |||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static void itmtouch_disconnect(struct usb_interface *intf) | ||
232 | { | ||
233 | struct itmtouch_dev *itmtouch = usb_get_intfdata(intf); | ||
234 | |||
235 | usb_set_intfdata(intf, NULL); | ||
236 | |||
237 | if (itmtouch) { | ||
238 | input_unregister_device(&itmtouch->inputdev); | ||
239 | usb_kill_urb(itmtouch->readurb); | ||
240 | usb_free_urb(itmtouch->readurb); | ||
241 | kfree(itmtouch); | ||
242 | } | ||
243 | } | ||
244 | |||
245 | MODULE_DEVICE_TABLE(usb, itmtouch_ids); | ||
246 | |||
247 | static struct usb_driver itmtouch_driver = { | ||
248 | .owner = THIS_MODULE, | ||
249 | .name = "itmtouch", | ||
250 | .probe = itmtouch_probe, | ||
251 | .disconnect = itmtouch_disconnect, | ||
252 | .id_table = itmtouch_ids, | ||
253 | }; | ||
254 | |||
255 | static int __init itmtouch_init(void) | ||
256 | { | ||
257 | info(DRIVER_DESC " " DRIVER_VERSION); | ||
258 | info(DRIVER_AUTHOR); | ||
259 | return usb_register(&itmtouch_driver); | ||
260 | } | ||
261 | |||
262 | static void __exit itmtouch_exit(void) | ||
263 | { | ||
264 | usb_deregister(&itmtouch_driver); | ||
265 | } | ||
266 | |||
267 | module_init(itmtouch_init); | ||
268 | module_exit(itmtouch_exit); | ||
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index a68c5b4e7b37..d2f0f90a9bcd 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
@@ -36,7 +36,6 @@ struct kbtab { | |||
36 | struct input_dev dev; | 36 | struct input_dev dev; |
37 | struct usb_device *usbdev; | 37 | struct usb_device *usbdev; |
38 | struct urb *irq; | 38 | struct urb *irq; |
39 | int open; | ||
40 | int x, y; | 39 | int x, y; |
41 | int button; | 40 | int button; |
42 | int pressure; | 41 | int pressure; |
@@ -79,12 +78,12 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs) | |||
79 | /*input_report_key(dev, BTN_TOUCH , data[0] & 0x01);*/ | 78 | /*input_report_key(dev, BTN_TOUCH , data[0] & 0x01);*/ |
80 | input_report_key(dev, BTN_RIGHT, data[0] & 0x02); | 79 | input_report_key(dev, BTN_RIGHT, data[0] & 0x02); |
81 | 80 | ||
82 | if( -1 == kb_pressure_click){ | 81 | if (-1 == kb_pressure_click) { |
83 | input_report_abs(dev, ABS_PRESSURE, kbtab->pressure); | 82 | input_report_abs(dev, ABS_PRESSURE, kbtab->pressure); |
84 | } else { | 83 | } else { |
85 | input_report_key(dev, BTN_LEFT, (kbtab->pressure > kb_pressure_click) ? 1 : 0); | 84 | input_report_key(dev, BTN_LEFT, (kbtab->pressure > kb_pressure_click) ? 1 : 0); |
86 | }; | 85 | }; |
87 | 86 | ||
88 | input_sync(dev); | 87 | input_sync(dev); |
89 | 88 | ||
90 | exit: | 89 | exit: |
@@ -105,14 +104,9 @@ static int kbtab_open(struct input_dev *dev) | |||
105 | { | 104 | { |
106 | struct kbtab *kbtab = dev->private; | 105 | struct kbtab *kbtab = dev->private; |
107 | 106 | ||
108 | if (kbtab->open++) | ||
109 | return 0; | ||
110 | |||
111 | kbtab->irq->dev = kbtab->usbdev; | 107 | kbtab->irq->dev = kbtab->usbdev; |
112 | if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) { | 108 | if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) |
113 | kbtab->open--; | ||
114 | return -EIO; | 109 | return -EIO; |
115 | } | ||
116 | 110 | ||
117 | return 0; | 111 | return 0; |
118 | } | 112 | } |
@@ -121,8 +115,7 @@ static void kbtab_close(struct input_dev *dev) | |||
121 | { | 115 | { |
122 | struct kbtab *kbtab = dev->private; | 116 | struct kbtab *kbtab = dev->private; |
123 | 117 | ||
124 | if (!--kbtab->open) | 118 | usb_kill_urb(kbtab->irq); |
125 | usb_kill_urb(kbtab->irq); | ||
126 | } | 119 | } |
127 | 120 | ||
128 | static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *id) | 121 | static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *id) |
@@ -161,7 +154,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
161 | kbtab->dev.absmax[ABS_X] = 0x2000; | 154 | kbtab->dev.absmax[ABS_X] = 0x2000; |
162 | kbtab->dev.absmax[ABS_Y] = 0x1750; | 155 | kbtab->dev.absmax[ABS_Y] = 0x1750; |
163 | kbtab->dev.absmax[ABS_PRESSURE] = 0xff; | 156 | kbtab->dev.absmax[ABS_PRESSURE] = 0xff; |
164 | 157 | ||
165 | kbtab->dev.absfuzz[ABS_X] = 4; | 158 | kbtab->dev.absfuzz[ABS_X] = 4; |
166 | kbtab->dev.absfuzz[ABS_Y] = 4; | 159 | kbtab->dev.absfuzz[ABS_Y] = 4; |
167 | 160 | ||
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c index ab1a2a30ce7c..09b5cc7c66de 100644 --- a/drivers/usb/input/mtouchusb.c +++ b/drivers/usb/input/mtouchusb.c | |||
@@ -42,9 +42,9 @@ | |||
42 | #include <linux/config.h> | 42 | #include <linux/config.h> |
43 | 43 | ||
44 | #ifdef CONFIG_USB_DEBUG | 44 | #ifdef CONFIG_USB_DEBUG |
45 | #define DEBUG | 45 | #define DEBUG |
46 | #else | 46 | #else |
47 | #undef DEBUG | 47 | #undef DEBUG |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
@@ -93,275 +93,255 @@ module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR); | |||
93 | MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)"); | 93 | MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)"); |
94 | 94 | ||
95 | struct mtouch_usb { | 95 | struct mtouch_usb { |
96 | unsigned char *data; | 96 | unsigned char *data; |
97 | dma_addr_t data_dma; | 97 | dma_addr_t data_dma; |
98 | struct urb *irq; | 98 | struct urb *irq; |
99 | struct usb_device *udev; | 99 | struct usb_device *udev; |
100 | struct input_dev input; | 100 | struct input_dev input; |
101 | int open; | 101 | char name[128]; |
102 | char name[128]; | 102 | char phys[64]; |
103 | char phys[64]; | ||
104 | }; | 103 | }; |
105 | 104 | ||
106 | static struct usb_device_id mtouchusb_devices [] = { | 105 | static struct usb_device_id mtouchusb_devices[] = { |
107 | { USB_DEVICE(0x0596, 0x0001) }, | 106 | { USB_DEVICE(0x0596, 0x0001) }, |
108 | { } | 107 | { } |
109 | }; | 108 | }; |
110 | 109 | ||
111 | static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) | 110 | static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) |
112 | { | 111 | { |
113 | struct mtouch_usb *mtouch = urb->context; | 112 | struct mtouch_usb *mtouch = urb->context; |
114 | int retval; | 113 | int retval; |
115 | 114 | ||
116 | switch (urb->status) { | 115 | switch (urb->status) { |
117 | case 0: | 116 | case 0: |
118 | /* success */ | 117 | /* success */ |
119 | break; | 118 | break; |
120 | case -ETIMEDOUT: | 119 | case -ETIMEDOUT: |
121 | /* this urb is timing out */ | 120 | /* this urb is timing out */ |
122 | dbg("%s - urb timed out - was the device unplugged?", | 121 | dbg("%s - urb timed out - was the device unplugged?", |
123 | __FUNCTION__); | 122 | __FUNCTION__); |
124 | return; | 123 | return; |
125 | case -ECONNRESET: | 124 | case -ECONNRESET: |
126 | case -ENOENT: | 125 | case -ENOENT: |
127 | case -ESHUTDOWN: | 126 | case -ESHUTDOWN: |
128 | /* this urb is terminated, clean up */ | 127 | /* this urb is terminated, clean up */ |
129 | dbg("%s - urb shutting down with status: %d", | 128 | dbg("%s - urb shutting down with status: %d", |
130 | __FUNCTION__, urb->status); | 129 | __FUNCTION__, urb->status); |
131 | return; | 130 | return; |
132 | default: | 131 | default: |
133 | dbg("%s - nonzero urb status received: %d", | 132 | dbg("%s - nonzero urb status received: %d", |
134 | __FUNCTION__, urb->status); | 133 | __FUNCTION__, urb->status); |
135 | goto exit; | 134 | goto exit; |
136 | } | 135 | } |
137 | 136 | ||
138 | input_regs(&mtouch->input, regs); | 137 | input_regs(&mtouch->input, regs); |
139 | input_report_key(&mtouch->input, BTN_TOUCH, | 138 | input_report_key(&mtouch->input, BTN_TOUCH, |
140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); | 139 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); |
141 | input_report_abs(&mtouch->input, ABS_X, | 140 | input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); |
142 | MTOUCHUSB_GET_XC(mtouch->data)); | 141 | input_report_abs(&mtouch->input, ABS_Y, |
143 | input_report_abs(&mtouch->input, ABS_Y, | ||
144 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) | 142 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) |
145 | - MTOUCHUSB_GET_YC(mtouch->data)); | 143 | - MTOUCHUSB_GET_YC(mtouch->data)); |
146 | input_sync(&mtouch->input); | 144 | input_sync(&mtouch->input); |
147 | 145 | ||
148 | exit: | 146 | exit: |
149 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 147 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
150 | if (retval) | 148 | if (retval) |
151 | err ("%s - usb_submit_urb failed with result: %d", | 149 | err("%s - usb_submit_urb failed with result: %d", |
152 | __FUNCTION__, retval); | 150 | __FUNCTION__, retval); |
153 | } | 151 | } |
154 | 152 | ||
155 | static int mtouchusb_open (struct input_dev *input) | 153 | static int mtouchusb_open(struct input_dev *input) |
156 | { | 154 | { |
157 | struct mtouch_usb *mtouch = input->private; | 155 | struct mtouch_usb *mtouch = input->private; |
158 | 156 | ||
159 | if (mtouch->open++) | 157 | mtouch->irq->dev = mtouch->udev; |
160 | return 0; | ||
161 | 158 | ||
162 | mtouch->irq->dev = mtouch->udev; | 159 | if (usb_submit_urb(mtouch->irq, GFP_ATOMIC)) |
160 | return -EIO; | ||
163 | 161 | ||
164 | if (usb_submit_urb (mtouch->irq, GFP_ATOMIC)) { | 162 | return 0; |
165 | mtouch->open--; | ||
166 | return -EIO; | ||
167 | } | ||
168 | |||
169 | return 0; | ||
170 | } | 163 | } |
171 | 164 | ||
172 | static void mtouchusb_close (struct input_dev *input) | 165 | static void mtouchusb_close(struct input_dev *input) |
173 | { | 166 | { |
174 | struct mtouch_usb *mtouch = input->private; | 167 | struct mtouch_usb *mtouch = input->private; |
175 | 168 | ||
176 | if (!--mtouch->open) | 169 | usb_kill_urb(mtouch->irq); |
177 | usb_kill_urb (mtouch->irq); | ||
178 | } | 170 | } |
179 | 171 | ||
180 | static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) | 172 | static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) |
181 | { | 173 | { |
182 | dbg("%s - called", __FUNCTION__); | 174 | dbg("%s - called", __FUNCTION__); |
183 | 175 | ||
184 | mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, | 176 | mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, |
185 | SLAB_ATOMIC, &mtouch->data_dma); | 177 | SLAB_ATOMIC, &mtouch->data_dma); |
186 | 178 | ||
187 | if (!mtouch->data) | 179 | if (!mtouch->data) |
188 | return -1; | 180 | return -1; |
189 | 181 | ||
190 | return 0; | 182 | return 0; |
191 | } | 183 | } |
192 | 184 | ||
193 | static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) | 185 | static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) |
194 | { | 186 | { |
195 | dbg("%s - called", __FUNCTION__); | 187 | dbg("%s - called", __FUNCTION__); |
196 | 188 | ||
197 | if (mtouch->data) | 189 | if (mtouch->data) |
198 | usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE, | 190 | usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE, |
199 | mtouch->data, mtouch->data_dma); | 191 | mtouch->data, mtouch->data_dma); |
200 | } | 192 | } |
201 | 193 | ||
202 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) | 194 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
203 | { | 195 | { |
204 | struct mtouch_usb *mtouch; | 196 | struct mtouch_usb *mtouch; |
205 | struct usb_host_interface *interface; | 197 | struct usb_host_interface *interface; |
206 | struct usb_endpoint_descriptor *endpoint; | 198 | struct usb_endpoint_descriptor *endpoint; |
207 | struct usb_device *udev = interface_to_usbdev (intf); | 199 | struct usb_device *udev = interface_to_usbdev(intf); |
208 | char path[64]; | 200 | char path[64]; |
209 | int nRet; | 201 | int nRet; |
210 | 202 | ||
211 | dbg("%s - called", __FUNCTION__); | 203 | dbg("%s - called", __FUNCTION__); |
212 | 204 | ||
213 | dbg("%s - setting interface", __FUNCTION__); | 205 | dbg("%s - setting interface", __FUNCTION__); |
214 | interface = intf->cur_altsetting; | 206 | interface = intf->cur_altsetting; |
215 | 207 | ||
216 | dbg("%s - setting endpoint", __FUNCTION__); | 208 | dbg("%s - setting endpoint", __FUNCTION__); |
217 | endpoint = &interface->endpoint[0].desc; | 209 | endpoint = &interface->endpoint[0].desc; |
218 | 210 | ||
219 | if (!(mtouch = kmalloc (sizeof (struct mtouch_usb), GFP_KERNEL))) { | 211 | if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { |
220 | err("%s - Out of memory.", __FUNCTION__); | 212 | err("%s - Out of memory.", __FUNCTION__); |
221 | return -ENOMEM; | 213 | return -ENOMEM; |
222 | } | 214 | } |
223 | 215 | ||
224 | memset(mtouch, 0, sizeof(struct mtouch_usb)); | 216 | memset(mtouch, 0, sizeof(struct mtouch_usb)); |
225 | mtouch->udev = udev; | 217 | mtouch->udev = udev; |
226 | 218 | ||
227 | dbg("%s - allocating buffers", __FUNCTION__); | 219 | dbg("%s - allocating buffers", __FUNCTION__); |
228 | if (mtouchusb_alloc_buffers(udev, mtouch)) { | 220 | if (mtouchusb_alloc_buffers(udev, mtouch)) { |
229 | mtouchusb_free_buffers(udev, mtouch); | 221 | mtouchusb_free_buffers(udev, mtouch); |
230 | kfree(mtouch); | 222 | kfree(mtouch); |
231 | return -ENOMEM; | 223 | return -ENOMEM; |
232 | } | 224 | } |
233 | 225 | ||
234 | mtouch->input.private = mtouch; | 226 | mtouch->input.private = mtouch; |
235 | mtouch->input.open = mtouchusb_open; | 227 | mtouch->input.open = mtouchusb_open; |
236 | mtouch->input.close = mtouchusb_close; | 228 | mtouch->input.close = mtouchusb_close; |
237 | 229 | ||
238 | usb_make_path(udev, path, 64); | 230 | usb_make_path(udev, path, 64); |
239 | sprintf(mtouch->phys, "%s/input0", path); | 231 | sprintf(mtouch->phys, "%s/input0", path); |
240 | 232 | ||
241 | mtouch->input.name = mtouch->name; | 233 | mtouch->input.name = mtouch->name; |
242 | mtouch->input.phys = mtouch->phys; | 234 | mtouch->input.phys = mtouch->phys; |
243 | mtouch->input.id.bustype = BUS_USB; | 235 | mtouch->input.id.bustype = BUS_USB; |
244 | mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); | 236 | mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); |
245 | mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct); | 237 | mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct); |
246 | mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); | 238 | mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); |
247 | mtouch->input.dev = &intf->dev; | 239 | mtouch->input.dev = &intf->dev; |
248 | 240 | ||
249 | mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 241 | mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
250 | mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | 242 | mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); |
251 | mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 243 | mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); |
252 | 244 | ||
253 | /* Used to Scale Compensated Data and Flip Y */ | 245 | /* Used to Scale Compensated Data and Flip Y */ |
254 | mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; | 246 | mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; |
255 | mtouch->input.absmax[ABS_X] = raw_coordinates ? \ | 247 | mtouch->input.absmax[ABS_X] = raw_coordinates ? |
256 | MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; | 248 | MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; |
257 | mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; | 249 | mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; |
258 | mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; | 250 | mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; |
259 | mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; | 251 | mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; |
260 | mtouch->input.absmax[ABS_Y] = raw_coordinates ? \ | 252 | mtouch->input.absmax[ABS_Y] = raw_coordinates ? |
261 | MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; | 253 | MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; |
262 | mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; | 254 | mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; |
263 | mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; | 255 | mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; |
264 | 256 | ||
265 | if (udev->manufacturer) | 257 | if (udev->manufacturer) |
266 | strcat(mtouch->name, udev->manufacturer); | 258 | strcat(mtouch->name, udev->manufacturer); |
267 | if (udev->product) | 259 | if (udev->product) |
268 | sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); | 260 | sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); |
269 | 261 | ||
270 | if (!strlen(mtouch->name)) | 262 | if (!strlen(mtouch->name)) |
271 | sprintf(mtouch->name, "USB Touchscreen %04x:%04x", | 263 | sprintf(mtouch->name, "USB Touchscreen %04x:%04x", |
272 | mtouch->input.id.vendor, mtouch->input.id.product); | 264 | mtouch->input.id.vendor, mtouch->input.id.product); |
273 | 265 | ||
274 | nRet = usb_control_msg(mtouch->udev, | 266 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
275 | usb_rcvctrlpipe(udev, 0), | 267 | MTOUCHUSB_RESET, |
276 | MTOUCHUSB_RESET, | 268 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
277 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 269 | 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); |
278 | 1, | 270 | dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", |
279 | 0, | 271 | __FUNCTION__, nRet); |
280 | NULL, | 272 | |
281 | 0, | 273 | dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__); |
282 | USB_CTRL_SET_TIMEOUT); | 274 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
283 | dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", | 275 | if (!mtouch->irq) { |
284 | __FUNCTION__, nRet); | 276 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); |
285 | 277 | mtouchusb_free_buffers(udev, mtouch); | |
286 | dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__); | 278 | kfree(mtouch); |
287 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 279 | return -ENOMEM; |
288 | if (!mtouch->irq) { | 280 | } |
289 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); | 281 | |
290 | mtouchusb_free_buffers(udev, mtouch); | 282 | dbg("%s - usb_fill_int_urb", __FUNCTION__); |
291 | kfree(mtouch); | 283 | usb_fill_int_urb(mtouch->irq, mtouch->udev, |
292 | return -ENOMEM; | 284 | usb_rcvintpipe(mtouch->udev, 0x81), |
293 | } | 285 | mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE, |
294 | 286 | mtouchusb_irq, mtouch, endpoint->bInterval); | |
295 | dbg("%s - usb_fill_int_urb", __FUNCTION__); | 287 | |
296 | usb_fill_int_urb(mtouch->irq, | 288 | dbg("%s - input_register_device", __FUNCTION__); |
297 | mtouch->udev, | 289 | input_register_device(&mtouch->input); |
298 | usb_rcvintpipe(mtouch->udev, 0x81), | 290 | |
299 | mtouch->data, | 291 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
300 | MTOUCHUSB_REPORT_DATA_SIZE, | 292 | MTOUCHUSB_ASYNC_REPORT, |
301 | mtouchusb_irq, | 293 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
302 | mtouch, | 294 | 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); |
303 | endpoint->bInterval); | 295 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", |
304 | 296 | __FUNCTION__, nRet); | |
305 | dbg("%s - input_register_device", __FUNCTION__); | 297 | |
306 | input_register_device(&mtouch->input); | 298 | printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); |
307 | 299 | usb_set_intfdata(intf, mtouch); | |
308 | nRet = usb_control_msg(mtouch->udev, | 300 | |
309 | usb_rcvctrlpipe(udev, 0), | 301 | return 0; |
310 | MTOUCHUSB_ASYNC_REPORT, | ||
311 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
312 | 1, | ||
313 | 1, | ||
314 | NULL, | ||
315 | 0, | ||
316 | USB_CTRL_SET_TIMEOUT); | ||
317 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", | ||
318 | __FUNCTION__, nRet); | ||
319 | |||
320 | printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); | ||
321 | usb_set_intfdata(intf, mtouch); | ||
322 | |||
323 | return 0; | ||
324 | } | 302 | } |
325 | 303 | ||
326 | static void mtouchusb_disconnect(struct usb_interface *intf) | 304 | static void mtouchusb_disconnect(struct usb_interface *intf) |
327 | { | 305 | { |
328 | struct mtouch_usb *mtouch = usb_get_intfdata (intf); | 306 | struct mtouch_usb *mtouch = usb_get_intfdata(intf); |
329 | 307 | ||
330 | dbg("%s - called", __FUNCTION__); | 308 | dbg("%s - called", __FUNCTION__); |
331 | usb_set_intfdata(intf, NULL); | 309 | usb_set_intfdata(intf, NULL); |
332 | if (mtouch) { | 310 | if (mtouch) { |
333 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); | 311 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); |
334 | usb_kill_urb(mtouch->irq); | 312 | usb_kill_urb(mtouch->irq); |
335 | input_unregister_device(&mtouch->input); | 313 | input_unregister_device(&mtouch->input); |
336 | usb_free_urb(mtouch->irq); | 314 | usb_free_urb(mtouch->irq); |
337 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); | 315 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); |
338 | kfree(mtouch); | 316 | kfree(mtouch); |
339 | } | 317 | } |
340 | } | 318 | } |
341 | 319 | ||
342 | MODULE_DEVICE_TABLE (usb, mtouchusb_devices); | 320 | MODULE_DEVICE_TABLE(usb, mtouchusb_devices); |
343 | 321 | ||
344 | static struct usb_driver mtouchusb_driver = { | 322 | static struct usb_driver mtouchusb_driver = { |
345 | .owner = THIS_MODULE, | 323 | .owner = THIS_MODULE, |
346 | .name = "mtouchusb", | 324 | .name = "mtouchusb", |
347 | .probe = mtouchusb_probe, | 325 | .probe = mtouchusb_probe, |
348 | .disconnect = mtouchusb_disconnect, | 326 | .disconnect = mtouchusb_disconnect, |
349 | .id_table = mtouchusb_devices, | 327 | .id_table = mtouchusb_devices, |
350 | }; | 328 | }; |
351 | 329 | ||
352 | static int __init mtouchusb_init(void) { | 330 | static int __init mtouchusb_init(void) |
353 | dbg("%s - called", __FUNCTION__); | 331 | { |
354 | return usb_register(&mtouchusb_driver); | 332 | dbg("%s - called", __FUNCTION__); |
333 | return usb_register(&mtouchusb_driver); | ||
355 | } | 334 | } |
356 | 335 | ||
357 | static void __exit mtouchusb_cleanup(void) { | 336 | static void __exit mtouchusb_cleanup(void) |
358 | dbg("%s - called", __FUNCTION__); | 337 | { |
359 | usb_deregister(&mtouchusb_driver); | 338 | dbg("%s - called", __FUNCTION__); |
339 | usb_deregister(&mtouchusb_driver); | ||
360 | } | 340 | } |
361 | 341 | ||
362 | module_init(mtouchusb_init); | 342 | module_init(mtouchusb_init); |
363 | module_exit(mtouchusb_cleanup); | 343 | module_exit(mtouchusb_cleanup); |
364 | 344 | ||
365 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 345 | MODULE_AUTHOR(DRIVER_AUTHOR); |
366 | MODULE_DESCRIPTION( DRIVER_DESC ); | 346 | MODULE_DESCRIPTION(DRIVER_DESC); |
367 | MODULE_LICENSE("GPL"); | 347 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index 7fa2f9b9fb69..3975b309d55f 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * back to the host when polled by the USB controller. | 10 | * back to the host when polled by the USB controller. |
11 | * | 11 | * |
12 | * Testing with the knob I have has shown that it measures approximately 94 "clicks" | 12 | * Testing with the knob I have has shown that it measures approximately 94 "clicks" |
13 | * for one full rotation. Testing with my High Speed Rotation Actuator (ok, it was | 13 | * for one full rotation. Testing with my High Speed Rotation Actuator (ok, it was |
14 | * a variable speed cordless electric drill) has shown that the device can measure | 14 | * a variable speed cordless electric drill) has shown that the device can measure |
15 | * speeds of up to 7 clicks either clockwise or anticlockwise between pollings from | 15 | * speeds of up to 7 clicks either clockwise or anticlockwise between pollings from |
16 | * the host. If it counts more than 7 clicks before it is polled, it will wrap back | 16 | * the host. If it counts more than 7 clicks before it is polled, it will wrap back |
@@ -120,9 +120,9 @@ exit: | |||
120 | /* Decide if we need to issue a control message and do so. Must be called with pm->lock taken */ | 120 | /* Decide if we need to issue a control message and do so. Must be called with pm->lock taken */ |
121 | static void powermate_sync_state(struct powermate_device *pm) | 121 | static void powermate_sync_state(struct powermate_device *pm) |
122 | { | 122 | { |
123 | if (pm->requires_update == 0) | 123 | if (pm->requires_update == 0) |
124 | return; /* no updates are required */ | 124 | return; /* no updates are required */ |
125 | if (pm->config->status == -EINPROGRESS) | 125 | if (pm->config->status == -EINPROGRESS) |
126 | return; /* an update is already in progress; it'll issue this update when it completes */ | 126 | return; /* an update is already in progress; it'll issue this update when it completes */ |
127 | 127 | ||
128 | if (pm->requires_update & UPDATE_PULSE_ASLEEP){ | 128 | if (pm->requires_update & UPDATE_PULSE_ASLEEP){ |
@@ -142,7 +142,7 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
142 | 2: multiply the speed | 142 | 2: multiply the speed |
143 | the argument only has an effect for operations 0 and 2, and ranges between | 143 | the argument only has an effect for operations 0 and 2, and ranges between |
144 | 1 (least effect) to 255 (maximum effect). | 144 | 1 (least effect) to 255 (maximum effect). |
145 | 145 | ||
146 | thus, several states are equivalent and are coalesced into one state. | 146 | thus, several states are equivalent and are coalesced into one state. |
147 | 147 | ||
148 | we map this onto a range from 0 to 510, with: | 148 | we map this onto a range from 0 to 510, with: |
@@ -151,7 +151,7 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
151 | 256 -- 510 -- use multiple (510 = fastest). | 151 | 256 -- 510 -- use multiple (510 = fastest). |
152 | 152 | ||
153 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. | 153 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. |
154 | */ | 154 | */ |
155 | if (pm->pulse_speed < 255){ | 155 | if (pm->pulse_speed < 255){ |
156 | op = 0; // divide | 156 | op = 0; // divide |
157 | arg = 255 - pm->pulse_speed; | 157 | arg = 255 - pm->pulse_speed; |
@@ -199,14 +199,14 @@ static void powermate_config_complete(struct urb *urb, struct pt_regs *regs) | |||
199 | 199 | ||
200 | if (urb->status) | 200 | if (urb->status) |
201 | printk(KERN_ERR "powermate: config urb returned %d\n", urb->status); | 201 | printk(KERN_ERR "powermate: config urb returned %d\n", urb->status); |
202 | 202 | ||
203 | spin_lock_irqsave(&pm->lock, flags); | 203 | spin_lock_irqsave(&pm->lock, flags); |
204 | powermate_sync_state(pm); | 204 | powermate_sync_state(pm); |
205 | spin_unlock_irqrestore(&pm->lock, flags); | 205 | spin_unlock_irqrestore(&pm->lock, flags); |
206 | } | 206 | } |
207 | 207 | ||
208 | /* Set the LED up as described and begin the sync with the hardware if required */ | 208 | /* Set the LED up as described and begin the sync with the hardware if required */ |
209 | static void powermate_pulse_led(struct powermate_device *pm, int static_brightness, int pulse_speed, | 209 | static void powermate_pulse_led(struct powermate_device *pm, int static_brightness, int pulse_speed, |
210 | int pulse_table, int pulse_asleep, int pulse_awake) | 210 | int pulse_table, int pulse_asleep, int pulse_awake) |
211 | { | 211 | { |
212 | unsigned long flags; | 212 | unsigned long flags; |
@@ -229,7 +229,7 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne | |||
229 | /* mark state updates which are required */ | 229 | /* mark state updates which are required */ |
230 | if (static_brightness != pm->static_brightness){ | 230 | if (static_brightness != pm->static_brightness){ |
231 | pm->static_brightness = static_brightness; | 231 | pm->static_brightness = static_brightness; |
232 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; | 232 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; |
233 | } | 233 | } |
234 | if (pulse_asleep != pm->pulse_asleep){ | 234 | if (pulse_asleep != pm->pulse_asleep){ |
235 | pm->pulse_asleep = pulse_asleep; | 235 | pm->pulse_asleep = pulse_asleep; |
@@ -246,7 +246,7 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne | |||
246 | } | 246 | } |
247 | 247 | ||
248 | powermate_sync_state(pm); | 248 | powermate_sync_state(pm); |
249 | 249 | ||
250 | spin_unlock_irqrestore(&pm->lock, flags); | 250 | spin_unlock_irqrestore(&pm->lock, flags); |
251 | } | 251 | } |
252 | 252 | ||
@@ -257,19 +257,19 @@ static int powermate_input_event(struct input_dev *dev, unsigned int type, unsig | |||
257 | struct powermate_device *pm = dev->private; | 257 | struct powermate_device *pm = dev->private; |
258 | 258 | ||
259 | if (type == EV_MSC && code == MSC_PULSELED){ | 259 | if (type == EV_MSC && code == MSC_PULSELED){ |
260 | /* | 260 | /* |
261 | bits 0- 7: 8 bits: LED brightness | 261 | bits 0- 7: 8 bits: LED brightness |
262 | bits 8-16: 9 bits: pulsing speed modifier (0 ... 510); 0-254 = slower, 255 = standard, 256-510 = faster. | 262 | bits 8-16: 9 bits: pulsing speed modifier (0 ... 510); 0-254 = slower, 255 = standard, 256-510 = faster. |
263 | bits 17-18: 2 bits: pulse table (0, 1, 2 valid) | 263 | bits 17-18: 2 bits: pulse table (0, 1, 2 valid) |
264 | bit 19: 1 bit : pulse whilst asleep? | 264 | bit 19: 1 bit : pulse whilst asleep? |
265 | bit 20: 1 bit : pulse constantly? | 265 | bit 20: 1 bit : pulse constantly? |
266 | */ | 266 | */ |
267 | int static_brightness = command & 0xFF; // bits 0-7 | 267 | int static_brightness = command & 0xFF; // bits 0-7 |
268 | int pulse_speed = (command >> 8) & 0x1FF; // bits 8-16 | 268 | int pulse_speed = (command >> 8) & 0x1FF; // bits 8-16 |
269 | int pulse_table = (command >> 17) & 0x3; // bits 17-18 | 269 | int pulse_table = (command >> 17) & 0x3; // bits 17-18 |
270 | int pulse_asleep = (command >> 19) & 0x1; // bit 19 | 270 | int pulse_asleep = (command >> 19) & 0x1; // bit 19 |
271 | int pulse_awake = (command >> 20) & 0x1; // bit 20 | 271 | int pulse_awake = (command >> 20) & 0x1; // bit 20 |
272 | 272 | ||
273 | powermate_pulse_led(pm, static_brightness, pulse_speed, pulse_table, pulse_asleep, pulse_awake); | 273 | powermate_pulse_led(pm, static_brightness, pulse_speed, pulse_table, pulse_asleep, pulse_awake); |
274 | } | 274 | } |
275 | 275 | ||
@@ -378,7 +378,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
378 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | 378 | switch (le16_to_cpu(udev->descriptor.idProduct)) { |
379 | case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; | 379 | case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; |
380 | case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; | 380 | case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; |
381 | default: | 381 | default: |
382 | pm->input.name = pm_name_soundknob; | 382 | pm->input.name = pm_name_soundknob; |
383 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | 383 | printk(KERN_WARNING "powermate: unknown product id %04x\n", |
384 | le16_to_cpu(udev->descriptor.idProduct)); | 384 | le16_to_cpu(udev->descriptor.idProduct)); |
@@ -402,11 +402,11 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
402 | usb_make_path(udev, path, 64); | 402 | usb_make_path(udev, path, 64); |
403 | snprintf(pm->phys, 64, "%s/input0", path); | 403 | snprintf(pm->phys, 64, "%s/input0", path); |
404 | printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys); | 404 | printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys); |
405 | 405 | ||
406 | /* force an update of everything */ | 406 | /* force an update of everything */ |
407 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; | 407 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; |
408 | powermate_pulse_led(pm, 0x80, 255, 0, 1, 0); // set default pulse parameters | 408 | powermate_pulse_led(pm, 0x80, 255, 0, 1, 0); // set default pulse parameters |
409 | 409 | ||
410 | usb_set_intfdata(intf, pm); | 410 | usb_set_intfdata(intf, pm); |
411 | return 0; | 411 | return 0; |
412 | } | 412 | } |
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index a71f1bbd0a17..386595ee21c0 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c | |||
@@ -69,7 +69,6 @@ struct touchkit_usb { | |||
69 | struct urb *irq; | 69 | struct urb *irq; |
70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
71 | struct input_dev input; | 71 | struct input_dev input; |
72 | int open; | ||
73 | char name[128]; | 72 | char name[128]; |
74 | char phys[64]; | 73 | char phys[64]; |
75 | }; | 74 | }; |
@@ -134,15 +133,10 @@ static int touchkit_open(struct input_dev *input) | |||
134 | { | 133 | { |
135 | struct touchkit_usb *touchkit = input->private; | 134 | struct touchkit_usb *touchkit = input->private; |
136 | 135 | ||
137 | if (touchkit->open++) | ||
138 | return 0; | ||
139 | |||
140 | touchkit->irq->dev = touchkit->udev; | 136 | touchkit->irq->dev = touchkit->udev; |
141 | 137 | ||
142 | if (usb_submit_urb(touchkit->irq, GFP_ATOMIC)) { | 138 | if (usb_submit_urb(touchkit->irq, GFP_ATOMIC)) |
143 | touchkit->open--; | ||
144 | return -EIO; | 139 | return -EIO; |
145 | } | ||
146 | 140 | ||
147 | return 0; | 141 | return 0; |
148 | } | 142 | } |
@@ -151,8 +145,7 @@ static void touchkit_close(struct input_dev *input) | |||
151 | { | 145 | { |
152 | struct touchkit_usb *touchkit = input->private; | 146 | struct touchkit_usb *touchkit = input->private; |
153 | 147 | ||
154 | if (!--touchkit->open) | 148 | usb_kill_urb(touchkit->irq); |
155 | usb_kill_urb(touchkit->irq); | ||
156 | } | 149 | } |
157 | 150 | ||
158 | static int touchkit_alloc_buffers(struct usb_device *udev, | 151 | static int touchkit_alloc_buffers(struct usb_device *udev, |
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c index 7038fb9d1ced..f35db1974c42 100644 --- a/drivers/usb/input/usbkbd.c +++ b/drivers/usb/input/usbkbd.c | |||
@@ -9,18 +9,18 @@ | |||
9 | /* | 9 | /* |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2 of the License, or | 12 | * the Free Software Foundation; either version 2 of the License, or |
13 | * (at your option) any later version. | 13 | * (at your option) any later version. |
14 | * | 14 | * |
15 | * This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | * | 19 | * |
20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
21 | * along with this program; if not, write to the Free Software | 21 | * along with this program; if not, write to the Free Software |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | * | 23 | * |
24 | * Should you need to contact me, the author, you can do so either by | 24 | * Should you need to contact me, the author, you can do so either by |
25 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: | 25 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: |
26 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | 26 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
@@ -72,7 +72,6 @@ struct usb_kbd { | |||
72 | unsigned char newleds; | 72 | unsigned char newleds; |
73 | char name[128]; | 73 | char name[128]; |
74 | char phys[64]; | 74 | char phys[64]; |
75 | int open; | ||
76 | 75 | ||
77 | unsigned char *new; | 76 | unsigned char *new; |
78 | struct usb_ctrlrequest *cr; | 77 | struct usb_ctrlrequest *cr; |
@@ -166,7 +165,7 @@ static void usb_kbd_led(struct urb *urb, struct pt_regs *regs) | |||
166 | 165 | ||
167 | if (urb->status) | 166 | if (urb->status) |
168 | warn("led urb status %d received", urb->status); | 167 | warn("led urb status %d received", urb->status); |
169 | 168 | ||
170 | if (*(kbd->leds) == kbd->newleds) | 169 | if (*(kbd->leds) == kbd->newleds) |
171 | return; | 170 | return; |
172 | 171 | ||
@@ -180,14 +179,9 @@ static int usb_kbd_open(struct input_dev *dev) | |||
180 | { | 179 | { |
181 | struct usb_kbd *kbd = dev->private; | 180 | struct usb_kbd *kbd = dev->private; |
182 | 181 | ||
183 | if (kbd->open++) | ||
184 | return 0; | ||
185 | |||
186 | kbd->irq->dev = kbd->usbdev; | 182 | kbd->irq->dev = kbd->usbdev; |
187 | if (usb_submit_urb(kbd->irq, GFP_KERNEL)) { | 183 | if (usb_submit_urb(kbd->irq, GFP_KERNEL)) |
188 | kbd->open--; | ||
189 | return -EIO; | 184 | return -EIO; |
190 | } | ||
191 | 185 | ||
192 | return 0; | 186 | return 0; |
193 | } | 187 | } |
@@ -196,8 +190,7 @@ static void usb_kbd_close(struct input_dev *dev) | |||
196 | { | 190 | { |
197 | struct usb_kbd *kbd = dev->private; | 191 | struct usb_kbd *kbd = dev->private; |
198 | 192 | ||
199 | if (!--kbd->open) | 193 | usb_kill_urb(kbd->irq); |
200 | usb_kill_urb(kbd->irq); | ||
201 | } | 194 | } |
202 | 195 | ||
203 | static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) | 196 | static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) |
@@ -230,7 +223,7 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) | |||
230 | usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); | 223 | usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); |
231 | } | 224 | } |
232 | 225 | ||
233 | static int usb_kbd_probe(struct usb_interface *iface, | 226 | static int usb_kbd_probe(struct usb_interface *iface, |
234 | const struct usb_device_id *id) | 227 | const struct usb_device_id *id) |
235 | { | 228 | { |
236 | struct usb_device * dev = interface_to_usbdev(iface); | 229 | struct usb_device * dev = interface_to_usbdev(iface); |
@@ -272,7 +265,7 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
272 | for (i = 0; i < 255; i++) | 265 | for (i = 0; i < 255; i++) |
273 | set_bit(usb_kbd_keycode[i], kbd->dev.keybit); | 266 | set_bit(usb_kbd_keycode[i], kbd->dev.keybit); |
274 | clear_bit(0, kbd->dev.keybit); | 267 | clear_bit(0, kbd->dev.keybit); |
275 | 268 | ||
276 | kbd->dev.private = kbd; | 269 | kbd->dev.private = kbd; |
277 | kbd->dev.event = usb_kbd_event; | 270 | kbd->dev.event = usb_kbd_event; |
278 | kbd->dev.open = usb_kbd_open; | 271 | kbd->dev.open = usb_kbd_open; |
@@ -294,7 +287,7 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
294 | sprintf(kbd->phys, "%s/input0", path); | 287 | sprintf(kbd->phys, "%s/input0", path); |
295 | 288 | ||
296 | kbd->dev.name = kbd->name; | 289 | kbd->dev.name = kbd->name; |
297 | kbd->dev.phys = kbd->phys; | 290 | kbd->dev.phys = kbd->phys; |
298 | kbd->dev.id.bustype = BUS_USB; | 291 | kbd->dev.id.bustype = BUS_USB; |
299 | kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); | 292 | kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); |
300 | kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); | 293 | kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); |
@@ -329,7 +322,7 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
329 | static void usb_kbd_disconnect(struct usb_interface *intf) | 322 | static void usb_kbd_disconnect(struct usb_interface *intf) |
330 | { | 323 | { |
331 | struct usb_kbd *kbd = usb_get_intfdata (intf); | 324 | struct usb_kbd *kbd = usb_get_intfdata (intf); |
332 | 325 | ||
333 | usb_set_intfdata(intf, NULL); | 326 | usb_set_intfdata(intf, NULL); |
334 | if (kbd) { | 327 | if (kbd) { |
335 | usb_kill_urb(kbd->irq); | 328 | usb_kill_urb(kbd->irq); |
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c index 01155bbddd43..1ec41b5effe6 100644 --- a/drivers/usb/input/usbmouse.c +++ b/drivers/usb/input/usbmouse.c | |||
@@ -9,18 +9,18 @@ | |||
9 | /* | 9 | /* |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2 of the License, or | 12 | * the Free Software Foundation; either version 2 of the License, or |
13 | * (at your option) any later version. | 13 | * (at your option) any later version. |
14 | * | 14 | * |
15 | * This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | * | 19 | * |
20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
21 | * along with this program; if not, write to the Free Software | 21 | * along with this program; if not, write to the Free Software |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | * | 23 | * |
24 | * Should you need to contact me, the author, you can do so either by | 24 | * Should you need to contact me, the author, you can do so either by |
25 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: | 25 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: |
26 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | 26 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
@@ -51,7 +51,6 @@ struct usb_mouse { | |||
51 | struct usb_device *usbdev; | 51 | struct usb_device *usbdev; |
52 | struct input_dev dev; | 52 | struct input_dev dev; |
53 | struct urb *irq; | 53 | struct urb *irq; |
54 | int open; | ||
55 | 54 | ||
56 | signed char *data; | 55 | signed char *data; |
57 | dma_addr_t data_dma; | 56 | dma_addr_t data_dma; |
@@ -101,14 +100,9 @@ static int usb_mouse_open(struct input_dev *dev) | |||
101 | { | 100 | { |
102 | struct usb_mouse *mouse = dev->private; | 101 | struct usb_mouse *mouse = dev->private; |
103 | 102 | ||
104 | if (mouse->open++) | ||
105 | return 0; | ||
106 | |||
107 | mouse->irq->dev = mouse->usbdev; | 103 | mouse->irq->dev = mouse->usbdev; |
108 | if (usb_submit_urb(mouse->irq, GFP_KERNEL)) { | 104 | if (usb_submit_urb(mouse->irq, GFP_KERNEL)) |
109 | mouse->open--; | ||
110 | return -EIO; | 105 | return -EIO; |
111 | } | ||
112 | 106 | ||
113 | return 0; | 107 | return 0; |
114 | } | 108 | } |
@@ -117,8 +111,7 @@ static void usb_mouse_close(struct input_dev *dev) | |||
117 | { | 111 | { |
118 | struct usb_mouse *mouse = dev->private; | 112 | struct usb_mouse *mouse = dev->private; |
119 | 113 | ||
120 | if (!--mouse->open) | 114 | usb_kill_urb(mouse->irq); |
121 | usb_kill_urb(mouse->irq); | ||
122 | } | 115 | } |
123 | 116 | ||
124 | static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) | 117 | static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) |
@@ -132,19 +125,19 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
132 | 125 | ||
133 | interface = intf->cur_altsetting; | 126 | interface = intf->cur_altsetting; |
134 | 127 | ||
135 | if (interface->desc.bNumEndpoints != 1) | 128 | if (interface->desc.bNumEndpoints != 1) |
136 | return -ENODEV; | 129 | return -ENODEV; |
137 | 130 | ||
138 | endpoint = &interface->endpoint[0].desc; | 131 | endpoint = &interface->endpoint[0].desc; |
139 | if (!(endpoint->bEndpointAddress & 0x80)) | 132 | if (!(endpoint->bEndpointAddress & 0x80)) |
140 | return -ENODEV; | 133 | return -ENODEV; |
141 | if ((endpoint->bmAttributes & 3) != 3) | 134 | if ((endpoint->bmAttributes & 3) != 3) |
142 | return -ENODEV; | 135 | return -ENODEV; |
143 | 136 | ||
144 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 137 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
145 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 138 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
146 | 139 | ||
147 | if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) | 140 | if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) |
148 | return -ENOMEM; | 141 | return -ENOMEM; |
149 | memset(mouse, 0, sizeof(struct usb_mouse)); | 142 | memset(mouse, 0, sizeof(struct usb_mouse)); |
150 | 143 | ||
@@ -209,7 +202,7 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
209 | static void usb_mouse_disconnect(struct usb_interface *intf) | 202 | static void usb_mouse_disconnect(struct usb_interface *intf) |
210 | { | 203 | { |
211 | struct usb_mouse *mouse = usb_get_intfdata (intf); | 204 | struct usb_mouse *mouse = usb_get_intfdata (intf); |
212 | 205 | ||
213 | usb_set_intfdata(intf, NULL); | 206 | usb_set_intfdata(intf, NULL); |
214 | if (mouse) { | 207 | if (mouse) { |
215 | usb_kill_urb(mouse->irq); | 208 | usb_kill_urb(mouse->irq); |
@@ -238,7 +231,7 @@ static struct usb_driver usb_mouse_driver = { | |||
238 | static int __init usb_mouse_init(void) | 231 | static int __init usb_mouse_init(void) |
239 | { | 232 | { |
240 | int retval = usb_register(&usb_mouse_driver); | 233 | int retval = usb_register(&usb_mouse_driver); |
241 | if (retval == 0) | 234 | if (retval == 0) |
242 | info(DRIVER_VERSION ":" DRIVER_DESC); | 235 | info(DRIVER_VERSION ":" DRIVER_DESC); |
243 | return retval; | 236 | return retval; |
244 | } | 237 | } |
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c index fec04dda088e..f6b34af66b3d 100644 --- a/drivers/usb/input/wacom.c +++ b/drivers/usb/input/wacom.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * Copyright (c) 2000 Daniel Egger <egger@suse.de> | 9 | * Copyright (c) 2000 Daniel Egger <egger@suse.de> |
10 | * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> | 10 | * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> |
11 | * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be> | 11 | * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be> |
12 | * Copyright (c) 2002-2004 Ping Cheng <pingc@wacom.com> | 12 | * Copyright (c) 2002-2005 Ping Cheng <pingc@wacom.com> |
13 | * | 13 | * |
14 | * ChangeLog: | 14 | * ChangeLog: |
15 | * v0.1 (vp) - Initial release | 15 | * v0.1 (vp) - Initial release |
@@ -18,7 +18,7 @@ | |||
18 | * v0.4 (sm) - Support for more Intuos models, menustrip | 18 | * v0.4 (sm) - Support for more Intuos models, menustrip |
19 | * relative mode, proximity. | 19 | * relative mode, proximity. |
20 | * v0.5 (vp) - Big cleanup, nifty features removed, | 20 | * v0.5 (vp) - Big cleanup, nifty features removed, |
21 | * they belong in userspace | 21 | * they belong in userspace |
22 | * v1.8 (vp) - Submit URB only when operating, moved to CVS, | 22 | * v1.8 (vp) - Submit URB only when operating, moved to CVS, |
23 | * use input_report_key instead of report_btn and | 23 | * use input_report_key instead of report_btn and |
24 | * other cleanups | 24 | * other cleanups |
@@ -51,6 +51,9 @@ | |||
51 | * - Cleanups here and there | 51 | * - Cleanups here and there |
52 | * v1.30.1 (pi) - Added Graphire3 support | 52 | * v1.30.1 (pi) - Added Graphire3 support |
53 | * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ... | 53 | * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ... |
54 | * v1.43 (pc) - Added support for Cintiq 21UX | ||
55 | - Fixed a Graphire bug | ||
56 | - Merged wacom_intuos3_irq into wacom_intuos_irq | ||
54 | */ | 57 | */ |
55 | 58 | ||
56 | /* | 59 | /* |
@@ -72,7 +75,7 @@ | |||
72 | /* | 75 | /* |
73 | * Version Information | 76 | * Version Information |
74 | */ | 77 | */ |
75 | #define DRIVER_VERSION "v1.40" | 78 | #define DRIVER_VERSION "v1.43" |
76 | #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" | 79 | #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" |
77 | #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" | 80 | #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" |
78 | #define DRIVER_LICENSE "GPL" | 81 | #define DRIVER_LICENSE "GPL" |
@@ -83,6 +86,16 @@ MODULE_LICENSE(DRIVER_LICENSE); | |||
83 | 86 | ||
84 | #define USB_VENDOR_ID_WACOM 0x056a | 87 | #define USB_VENDOR_ID_WACOM 0x056a |
85 | 88 | ||
89 | enum { | ||
90 | PENPARTNER = 0, | ||
91 | GRAPHIRE, | ||
92 | PL, | ||
93 | INTUOS, | ||
94 | INTUOS3, | ||
95 | CINTIQ, | ||
96 | MAX_TYPE | ||
97 | }; | ||
98 | |||
86 | struct wacom_features { | 99 | struct wacom_features { |
87 | char *name; | 100 | char *name; |
88 | int pktlen; | 101 | int pktlen; |
@@ -102,7 +115,6 @@ struct wacom { | |||
102 | struct urb *irq; | 115 | struct urb *irq; |
103 | struct wacom_features *features; | 116 | struct wacom_features *features; |
104 | int tool[2]; | 117 | int tool[2]; |
105 | int open; | ||
106 | __u32 serial[2]; | 118 | __u32 serial[2]; |
107 | char phys[32]; | 119 | char phys[32]; |
108 | }; | 120 | }; |
@@ -149,7 +161,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
149 | prox = data[1] & 0x40; | 161 | prox = data[1] & 0x40; |
150 | 162 | ||
151 | input_regs(dev, regs); | 163 | input_regs(dev, regs); |
152 | 164 | ||
153 | if (prox) { | 165 | if (prox) { |
154 | 166 | ||
155 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); | 167 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); |
@@ -166,8 +178,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
166 | if (!wacom->tool[0]) { | 178 | if (!wacom->tool[0]) { |
167 | /* Going into proximity select tool */ | 179 | /* Going into proximity select tool */ |
168 | wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | 180 | wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
169 | } | 181 | } else { |
170 | else { | ||
171 | /* was entered with stylus2 pressed */ | 182 | /* was entered with stylus2 pressed */ |
172 | if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) { | 183 | if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) { |
173 | /* report out proximity for previous tool */ | 184 | /* report out proximity for previous tool */ |
@@ -182,16 +193,15 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
182 | wacom->tool[1] = BTN_TOOL_PEN; | 193 | wacom->tool[1] = BTN_TOOL_PEN; |
183 | } | 194 | } |
184 | input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */ | 195 | input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */ |
185 | input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 7) | ((__u32)(data[1] & 0x03) << 14)); | 196 | input_report_abs(dev, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); |
186 | input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 7) | ((__u32)(data[4] & 0x03) << 14)); | 197 | input_report_abs(dev, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); |
187 | input_report_abs(dev, ABS_PRESSURE, pressure); | 198 | input_report_abs(dev, ABS_PRESSURE, pressure); |
188 | 199 | ||
189 | input_report_key(dev, BTN_TOUCH, data[4] & 0x08); | 200 | input_report_key(dev, BTN_TOUCH, data[4] & 0x08); |
190 | input_report_key(dev, BTN_STYLUS, data[4] & 0x10); | 201 | input_report_key(dev, BTN_STYLUS, data[4] & 0x10); |
191 | /* Only allow the stylus2 button to be reported for the pen tool. */ | 202 | /* Only allow the stylus2 button to be reported for the pen tool. */ |
192 | input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20)); | 203 | input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20)); |
193 | } | 204 | } else { |
194 | else { | ||
195 | /* report proximity-out of a (valid) tool */ | 205 | /* report proximity-out of a (valid) tool */ |
196 | if (wacom->tool[1] != BTN_TOOL_RUBBER) { | 206 | if (wacom->tool[1] != BTN_TOOL_RUBBER) { |
197 | /* Unknown tool selected default to pen tool */ | 207 | /* Unknown tool selected default to pen tool */ |
@@ -203,7 +213,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
203 | wacom->tool[0] = prox; /* Save proximity state */ | 213 | wacom->tool[0] = prox; /* Save proximity state */ |
204 | input_sync(dev); | 214 | input_sync(dev); |
205 | 215 | ||
206 | exit: | 216 | exit: |
207 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 217 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
208 | if (retval) | 218 | if (retval) |
209 | err ("%s - usb_submit_urb failed with result %d", | 219 | err ("%s - usb_submit_urb failed with result %d", |
@@ -232,20 +242,16 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs) | |||
232 | goto exit; | 242 | goto exit; |
233 | } | 243 | } |
234 | 244 | ||
235 | if (data[0] != 2) | 245 | if (data[0] != 2) { |
236 | { | ||
237 | printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]); | 246 | printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]); |
238 | goto exit; | 247 | goto exit; |
239 | } | 248 | } |
240 | 249 | ||
241 | input_regs(dev, regs); | 250 | input_regs(dev, regs); |
242 | if (data[1] & 0x04) | 251 | if (data[1] & 0x04) { |
243 | { | ||
244 | input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20); | 252 | input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20); |
245 | input_report_key(dev, BTN_TOUCH, data[1] & 0x08); | 253 | input_report_key(dev, BTN_TOUCH, data[1] & 0x08); |
246 | } | 254 | } else { |
247 | else | ||
248 | { | ||
249 | input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20); | 255 | input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20); |
250 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); | 256 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); |
251 | } | 257 | } |
@@ -257,7 +263,7 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs) | |||
257 | 263 | ||
258 | input_sync(dev); | 264 | input_sync(dev); |
259 | 265 | ||
260 | exit: | 266 | exit: |
261 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 267 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
262 | if (retval) | 268 | if (retval) |
263 | err ("%s - usb_submit_urb failed with result %d", | 269 | err ("%s - usb_submit_urb failed with result %d", |
@@ -300,7 +306,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs) | |||
300 | input_report_key(dev, BTN_STYLUS, (data[5] & 0x40)); | 306 | input_report_key(dev, BTN_STYLUS, (data[5] & 0x40)); |
301 | input_sync(dev); | 307 | input_sync(dev); |
302 | 308 | ||
303 | exit: | 309 | exit: |
304 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 310 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
305 | if (retval) | 311 | if (retval) |
306 | err ("%s - usb_submit_urb failed with result %d", | 312 | err ("%s - usb_submit_urb failed with result %d", |
@@ -340,47 +346,47 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
340 | 346 | ||
341 | input_regs(dev, regs); | 347 | input_regs(dev, regs); |
342 | 348 | ||
343 | switch ((data[1] >> 5) & 3) { | 349 | if (data[1] & 0x10) { /* in prox */ |
344 | 350 | ||
345 | case 0: /* Pen */ | 351 | switch ((data[1] >> 5) & 3) { |
346 | input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80); | ||
347 | break; | ||
348 | 352 | ||
349 | case 1: /* Rubber */ | 353 | case 0: /* Pen */ |
350 | input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80); | 354 | wacom->tool[0] = BTN_TOOL_PEN; |
351 | break; | 355 | break; |
352 | |||
353 | case 2: /* Mouse with wheel */ | ||
354 | input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); | ||
355 | input_report_rel(dev, REL_WHEEL, (signed char) data[6]); | ||
356 | /* fall through */ | ||
357 | 356 | ||
358 | case 3: /* Mouse without wheel */ | 357 | case 1: /* Rubber */ |
359 | input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24); | 358 | wacom->tool[0] = BTN_TOOL_RUBBER; |
360 | input_report_key(dev, BTN_LEFT, data[1] & 0x01); | 359 | break; |
361 | input_report_key(dev, BTN_RIGHT, data[1] & 0x02); | ||
362 | input_report_abs(dev, ABS_DISTANCE, data[7]); | ||
363 | 360 | ||
364 | input_report_abs(dev, ABS_X, x); | 361 | case 2: /* Mouse with wheel */ |
365 | input_report_abs(dev, ABS_Y, y); | 362 | input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); |
363 | input_report_rel(dev, REL_WHEEL, (signed char) data[6]); | ||
364 | /* fall through */ | ||
366 | 365 | ||
367 | input_sync(dev); | 366 | case 3: /* Mouse without wheel */ |
368 | goto exit; | 367 | wacom->tool[0] = BTN_TOOL_MOUSE; |
368 | input_report_key(dev, BTN_LEFT, data[1] & 0x01); | ||
369 | input_report_key(dev, BTN_RIGHT, data[1] & 0x02); | ||
370 | input_report_abs(dev, ABS_DISTANCE, data[7]); | ||
371 | break; | ||
372 | } | ||
369 | } | 373 | } |
370 | 374 | ||
371 | if (data[1] & 0x80) { | 375 | if (data[1] & 0x80) { |
372 | input_report_abs(dev, ABS_X, x); | 376 | input_report_abs(dev, ABS_X, x); |
373 | input_report_abs(dev, ABS_Y, y); | 377 | input_report_abs(dev, ABS_Y, y); |
374 | } | 378 | } |
379 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { | ||
380 | input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6])); | ||
381 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); | ||
382 | input_report_key(dev, BTN_STYLUS, data[1] & 0x02); | ||
383 | input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); | ||
384 | } | ||
375 | 385 | ||
376 | input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6])); | 386 | input_report_key(dev, wacom->tool[0], data[1] & 0x10); |
377 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); | ||
378 | input_report_key(dev, BTN_STYLUS, data[1] & 0x02); | ||
379 | input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); | ||
380 | |||
381 | input_sync(dev); | 387 | input_sync(dev); |
382 | 388 | ||
383 | exit: | 389 | exit: |
384 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 390 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
385 | if (retval) | 391 | if (retval) |
386 | err ("%s - usb_submit_urb failed with result %d", | 392 | err ("%s - usb_submit_urb failed with result %d", |
@@ -398,14 +404,13 @@ static int wacom_intuos_inout(struct urb *urb) | |||
398 | idx = data[1] & 0x01; | 404 | idx = data[1] & 0x01; |
399 | 405 | ||
400 | /* Enter report */ | 406 | /* Enter report */ |
401 | if ((data[1] & 0xfc) == 0xc0) | 407 | if ((data[1] & 0xfc) == 0xc0) { |
402 | { | ||
403 | /* serial number of the tool */ | 408 | /* serial number of the tool */ |
404 | wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 28) + | 409 | wacom->serial[idx] = ((data[3] & 0x0f) << 28) + |
405 | ((__u32)data[4] << 20) + ((__u32)data[5] << 12) + | 410 | (data[4] << 20) + (data[5] << 12) + |
406 | ((__u32)data[6] << 4) + (data[7] >> 4); | 411 | (data[6] << 4) + (data[7] >> 4); |
407 | 412 | ||
408 | switch (((__u32)data[2] << 4) | (data[3] >> 4)) { | 413 | switch ((data[2] << 4) | (data[3] >> 4)) { |
409 | case 0x812: /* Inking pen */ | 414 | case 0x812: /* Inking pen */ |
410 | case 0x801: /* Intuos3 Inking pen */ | 415 | case 0x801: /* Intuos3 Inking pen */ |
411 | case 0x012: | 416 | case 0x012: |
@@ -449,7 +454,7 @@ static int wacom_intuos_inout(struct urb *urb) | |||
449 | case 0x112: | 454 | case 0x112: |
450 | case 0x913: /* Intuos3 Airbrush */ | 455 | case 0x913: /* Intuos3 Airbrush */ |
451 | wacom->tool[idx] = BTN_TOOL_AIRBRUSH; | 456 | wacom->tool[idx] = BTN_TOOL_AIRBRUSH; |
452 | break; /* Airbrush */ | 457 | break; |
453 | default: /* Unknown tool */ | 458 | default: /* Unknown tool */ |
454 | wacom->tool[idx] = BTN_TOOL_PEN; | 459 | wacom->tool[idx] = BTN_TOOL_PEN; |
455 | } | 460 | } |
@@ -478,9 +483,8 @@ static void wacom_intuos_general(struct urb *urb) | |||
478 | unsigned int t; | 483 | unsigned int t; |
479 | 484 | ||
480 | /* general pen packet */ | 485 | /* general pen packet */ |
481 | if ((data[1] & 0xb8) == 0xa0) | 486 | if ((data[1] & 0xb8) == 0xa0) { |
482 | { | 487 | t = (data[6] << 2) | ((data[7] >> 6) & 3); |
483 | t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3); | ||
484 | input_report_abs(dev, ABS_PRESSURE, t); | 488 | input_report_abs(dev, ABS_PRESSURE, t); |
485 | input_report_abs(dev, ABS_TILT_X, | 489 | input_report_abs(dev, ABS_TILT_X, |
486 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); | 490 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); |
@@ -491,10 +495,9 @@ static void wacom_intuos_general(struct urb *urb) | |||
491 | } | 495 | } |
492 | 496 | ||
493 | /* airbrush second packet */ | 497 | /* airbrush second packet */ |
494 | if ((data[1] & 0xbc) == 0xb4) | 498 | if ((data[1] & 0xbc) == 0xb4) { |
495 | { | ||
496 | input_report_abs(dev, ABS_WHEEL, | 499 | input_report_abs(dev, ABS_WHEEL, |
497 | ((__u32)data[6] << 2) | ((data[7] >> 6) & 3)); | 500 | (data[6] << 2) | ((data[7] >> 6) & 3)); |
498 | input_report_abs(dev, ABS_TILT_X, | 501 | input_report_abs(dev, ABS_TILT_X, |
499 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); | 502 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); |
500 | input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f); | 503 | input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f); |
@@ -526,7 +529,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs) | |||
526 | goto exit; | 529 | goto exit; |
527 | } | 530 | } |
528 | 531 | ||
529 | if (data[0] != 2 && data[0] != 5 && data[0] != 6) { | 532 | if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) { |
530 | dbg("wacom_intuos_irq: received unknown report #%d", data[0]); | 533 | dbg("wacom_intuos_irq: received unknown report #%d", data[0]); |
531 | goto exit; | 534 | goto exit; |
532 | } | 535 | } |
@@ -536,107 +539,10 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs) | |||
536 | /* tool number */ | 539 | /* tool number */ |
537 | idx = data[1] & 0x01; | 540 | idx = data[1] & 0x01; |
538 | 541 | ||
539 | /* process in/out prox events */ | ||
540 | if (wacom_intuos_inout(urb)) goto exit; | ||
541 | |||
542 | input_report_abs(dev, ABS_X, be16_to_cpu(*(__be16 *) &data[2])); | ||
543 | input_report_abs(dev, ABS_Y, be16_to_cpu(*(__be16 *) &data[4])); | ||
544 | input_report_abs(dev, ABS_DISTANCE, data[9]); | ||
545 | |||
546 | /* process general packets */ | ||
547 | wacom_intuos_general(urb); | ||
548 | |||
549 | if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { /* 4D mouse or Lens cursor packets */ | ||
550 | |||
551 | if (data[1] & 0x02) { /* Rotation packet */ | ||
552 | |||
553 | t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7); | ||
554 | input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ? ((t - 1) / 2) : -t / 2); | ||
555 | |||
556 | } else { | ||
557 | |||
558 | if ((data[1] & 0x10) == 0) { /* 4D mouse packets */ | ||
559 | |||
560 | input_report_key(dev, BTN_LEFT, data[8] & 0x01); | ||
561 | input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); | ||
562 | input_report_key(dev, BTN_RIGHT, data[8] & 0x04); | ||
563 | |||
564 | input_report_key(dev, BTN_SIDE, data[8] & 0x20); | ||
565 | input_report_key(dev, BTN_EXTRA, data[8] & 0x10); | ||
566 | t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3); | ||
567 | input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); | ||
568 | |||
569 | } else { | ||
570 | if (wacom->tool[idx] == BTN_TOOL_MOUSE) { /* 2D mouse packets */ | ||
571 | input_report_key(dev, BTN_LEFT, data[8] & 0x04); | ||
572 | input_report_key(dev, BTN_MIDDLE, data[8] & 0x08); | ||
573 | input_report_key(dev, BTN_RIGHT, data[8] & 0x10); | ||
574 | input_report_rel(dev, REL_WHEEL, | ||
575 | (-(__u32)(data[8] & 0x01) + (__u32)((data[8] & 0x02) >> 1))); | ||
576 | } | ||
577 | else { /* Lens cursor packets */ | ||
578 | input_report_key(dev, BTN_LEFT, data[8] & 0x01); | ||
579 | input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); | ||
580 | input_report_key(dev, BTN_RIGHT, data[8] & 0x04); | ||
581 | input_report_key(dev, BTN_SIDE, data[8] & 0x10); | ||
582 | input_report_key(dev, BTN_EXTRA, data[8] & 0x08); | ||
583 | } | ||
584 | } | ||
585 | } | ||
586 | } | ||
587 | |||
588 | input_report_key(dev, wacom->tool[idx], 1); | ||
589 | input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | ||
590 | input_sync(dev); | ||
591 | |||
592 | exit: | ||
593 | retval = usb_submit_urb (urb, GFP_ATOMIC); | ||
594 | if (retval) | ||
595 | err ("%s - usb_submit_urb failed with result %d", | ||
596 | __FUNCTION__, retval); | ||
597 | } | ||
598 | |||
599 | static void wacom_intuos3_irq(struct urb *urb, struct pt_regs *regs) | ||
600 | { | ||
601 | struct wacom *wacom = urb->context; | ||
602 | unsigned char *data = wacom->data; | ||
603 | struct input_dev *dev = &wacom->dev; | ||
604 | unsigned int t; | ||
605 | int idx, retval; | ||
606 | |||
607 | switch (urb->status) { | ||
608 | case 0: | ||
609 | /* success */ | ||
610 | break; | ||
611 | case -ECONNRESET: | ||
612 | case -ENOENT: | ||
613 | case -ESHUTDOWN: | ||
614 | /* this urb is terminated, clean up */ | ||
615 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); | ||
616 | return; | ||
617 | default: | ||
618 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); | ||
619 | goto exit; | ||
620 | } | ||
621 | |||
622 | /* check for valid report */ | ||
623 | if (data[0] != 2 && data[0] != 5 && data[0] != 12) | ||
624 | { | ||
625 | printk(KERN_INFO "wacom_intuos3_irq: received unknown report #%d\n", data[0]); | ||
626 | goto exit; | ||
627 | } | ||
628 | |||
629 | input_regs(dev, regs); | ||
630 | |||
631 | /* tool index is always 0 here since there is no dual input tool */ | ||
632 | idx = data[1] & 0x01; | ||
633 | |||
634 | /* pad packets. Works as a second tool and is always in prox */ | 542 | /* pad packets. Works as a second tool and is always in prox */ |
635 | if (data[0] == 12) | 543 | if (data[0] == 12) { |
636 | { | ||
637 | /* initiate the pad as a device */ | 544 | /* initiate the pad as a device */ |
638 | if (wacom->tool[1] != BTN_TOOL_FINGER) | 545 | if (wacom->tool[1] != BTN_TOOL_FINGER) { |
639 | { | ||
640 | wacom->tool[1] = BTN_TOOL_FINGER; | 546 | wacom->tool[1] = BTN_TOOL_FINGER; |
641 | input_report_key(dev, wacom->tool[1], 1); | 547 | input_report_key(dev, wacom->tool[1], 1); |
642 | } | 548 | } |
@@ -656,37 +562,78 @@ static void wacom_intuos3_irq(struct urb *urb, struct pt_regs *regs) | |||
656 | } | 562 | } |
657 | 563 | ||
658 | /* process in/out prox events */ | 564 | /* process in/out prox events */ |
659 | if (wacom_intuos_inout(urb)) goto exit; | 565 | if (wacom_intuos_inout(urb)) |
566 | goto exit; | ||
660 | 567 | ||
661 | input_report_abs(dev, ABS_X, ((__u32)data[2] << 9) | ((__u32)data[3] << 1) | ((data[9] >> 1) & 1)); | 568 | /* Cintiq doesn't send data when RDY bit isn't set */ |
662 | input_report_abs(dev, ABS_Y, ((__u32)data[4] << 9) | ((__u32)data[5] << 1) | (data[9] & 1)); | 569 | if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40)) |
663 | input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); | 570 | return; |
571 | |||
572 | if (wacom->features->type >= INTUOS3) { | ||
573 | input_report_abs(dev, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); | ||
574 | input_report_abs(dev, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); | ||
575 | input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); | ||
576 | } else { | ||
577 | input_report_abs(dev, ABS_X, be16_to_cpu(*(__be16 *) &data[2])); | ||
578 | input_report_abs(dev, ABS_Y, be16_to_cpu(*(__be16 *) &data[4])); | ||
579 | input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); | ||
580 | } | ||
664 | 581 | ||
665 | /* process general packets */ | 582 | /* process general packets */ |
666 | wacom_intuos_general(urb); | 583 | wacom_intuos_general(urb); |
667 | 584 | ||
668 | if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) | 585 | /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */ |
669 | { | 586 | if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { |
670 | /* Marker pen rotation packet. Reported as wheel due to valuator limitation */ | 587 | |
671 | if (data[1] & 0x02) | 588 | if (data[1] & 0x02) { |
672 | { | 589 | /* Rotation packet */ |
673 | t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7); | 590 | if (wacom->features->type >= INTUOS3) { |
674 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : | 591 | /* I3 marker pen rotation reported as wheel |
675 | ((t-1) / 2 + 450)) : (450 - t / 2) ; | 592 | * due to valuator limitation |
676 | input_report_abs(dev, ABS_WHEEL, t); | 593 | */ |
677 | } | 594 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
595 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : | ||
596 | ((t-1) / 2 + 450)) : (450 - t / 2) ; | ||
597 | input_report_abs(dev, ABS_WHEEL, t); | ||
598 | } else { | ||
599 | /* 4D mouse rotation packet */ | ||
600 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | ||
601 | input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ? | ||
602 | ((t - 1) / 2) : -t / 2); | ||
603 | } | ||
678 | 604 | ||
679 | /* 2D mouse packets */ | 605 | } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) { |
680 | if (wacom->tool[idx] == BTN_TOOL_MOUSE) | 606 | /* 4D mouse packet */ |
681 | { | 607 | input_report_key(dev, BTN_LEFT, data[8] & 0x01); |
608 | input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); | ||
609 | input_report_key(dev, BTN_RIGHT, data[8] & 0x04); | ||
610 | |||
611 | input_report_key(dev, BTN_SIDE, data[8] & 0x20); | ||
612 | input_report_key(dev, BTN_EXTRA, data[8] & 0x10); | ||
613 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | ||
614 | input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); | ||
615 | |||
616 | } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { | ||
617 | /* 2D mouse packet */ | ||
682 | input_report_key(dev, BTN_LEFT, data[8] & 0x04); | 618 | input_report_key(dev, BTN_LEFT, data[8] & 0x04); |
683 | input_report_key(dev, BTN_MIDDLE, data[8] & 0x08); | 619 | input_report_key(dev, BTN_MIDDLE, data[8] & 0x08); |
684 | input_report_key(dev, BTN_RIGHT, data[8] & 0x10); | 620 | input_report_key(dev, BTN_RIGHT, data[8] & 0x10); |
685 | input_report_key(dev, BTN_SIDE, data[8] & 0x40); | 621 | input_report_rel(dev, REL_WHEEL, ((data[8] & 0x02) >> 1) |
686 | input_report_key(dev, BTN_EXTRA, data[8] & 0x20); | 622 | - (data[8] & 0x01)); |
687 | /* mouse wheel is positive when rolled backwards */ | 623 | |
688 | input_report_rel(dev, REL_WHEEL, ((__u32)((data[8] & 0x02) >> 1) | 624 | /* I3 2D mouse side buttons */ |
689 | - (__u32)(data[8] & 0x01))); | 625 | if (wacom->features->type == INTUOS3) { |
626 | input_report_key(dev, BTN_SIDE, data[8] & 0x40); | ||
627 | input_report_key(dev, BTN_EXTRA, data[8] & 0x20); | ||
628 | } | ||
629 | |||
630 | } else if (wacom->features->type < INTUOS3) { | ||
631 | /* Lens cursor packets */ | ||
632 | input_report_key(dev, BTN_LEFT, data[8] & 0x01); | ||
633 | input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); | ||
634 | input_report_key(dev, BTN_RIGHT, data[8] & 0x04); | ||
635 | input_report_key(dev, BTN_SIDE, data[8] & 0x10); | ||
636 | input_report_key(dev, BTN_EXTRA, data[8] & 0x08); | ||
690 | } | 637 | } |
691 | } | 638 | } |
692 | 639 | ||
@@ -702,35 +649,36 @@ exit: | |||
702 | } | 649 | } |
703 | 650 | ||
704 | static struct wacom_features wacom_features[] = { | 651 | static struct wacom_features wacom_features[] = { |
705 | { "Wacom Penpartner", 7, 5040, 3780, 255, 32, 0, wacom_penpartner_irq }, | 652 | { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_penpartner_irq }, |
706 | { "Wacom Graphire", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq }, | 653 | { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
707 | { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq }, | 654 | { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
708 | { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, 1, wacom_graphire_irq }, | 655 | { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
709 | { "Wacom Graphire3", 8, 10208, 7424, 511, 32, 1, wacom_graphire_irq }, | 656 | { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
710 | { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, 1, wacom_graphire_irq }, | 657 | { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
711 | { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq }, | 658 | { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, |
712 | { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq }, | 659 | { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, |
713 | { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq }, | 660 | { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, |
714 | { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq }, | 661 | { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, |
715 | { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq }, | 662 | { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, |
716 | { "Wacom PL400", 8, 5408, 4056, 255, 32, 3, wacom_pl_irq }, | 663 | { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_pl_irq }, |
717 | { "Wacom PL500", 8, 6144, 4608, 255, 32, 3, wacom_pl_irq }, | 664 | { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_pl_irq }, |
718 | { "Wacom PL600", 8, 6126, 4604, 255, 32, 3, wacom_pl_irq }, | 665 | { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_pl_irq }, |
719 | { "Wacom PL600SX", 8, 6260, 5016, 255, 32, 3, wacom_pl_irq }, | 666 | { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_pl_irq }, |
720 | { "Wacom PL550", 8, 6144, 4608, 511, 32, 3, wacom_pl_irq }, | 667 | { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_pl_irq }, |
721 | { "Wacom PL800", 8, 7220, 5780, 511, 32, 3, wacom_pl_irq }, | 668 | { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_pl_irq }, |
722 | { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq }, | 669 | { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, |
723 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq }, | 670 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, |
724 | { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq }, | 671 | { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, |
725 | { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq }, | 672 | { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, |
726 | { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq }, | 673 | { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, |
727 | { "Wacom Volito", 8, 5104, 3712, 511, 32, 1, wacom_graphire_irq }, | 674 | { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
728 | { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, 3, wacom_ptu_irq }, | 675 | { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL, wacom_ptu_irq }, |
729 | { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, 4, wacom_intuos3_irq }, | 676 | { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_intuos_irq }, |
730 | { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, 4, wacom_intuos3_irq }, | 677 | { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_intuos_irq }, |
731 | { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, 4, wacom_intuos3_irq }, | 678 | { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_intuos_irq }, |
732 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq }, | 679 | { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_intuos_irq }, |
733 | { } | 680 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, |
681 | { } | ||
734 | }; | 682 | }; |
735 | 683 | ||
736 | static struct usb_device_id wacom_ids[] = { | 684 | static struct usb_device_id wacom_ids[] = { |
@@ -761,6 +709,7 @@ static struct usb_device_id wacom_ids[] = { | |||
761 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, | 709 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, |
762 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, | 710 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, |
763 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, | 711 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, |
712 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, | ||
764 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, | 713 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, |
765 | { } | 714 | { } |
766 | }; | 715 | }; |
@@ -771,14 +720,9 @@ static int wacom_open(struct input_dev *dev) | |||
771 | { | 720 | { |
772 | struct wacom *wacom = dev->private; | 721 | struct wacom *wacom = dev->private; |
773 | 722 | ||
774 | if (wacom->open++) | ||
775 | return 0; | ||
776 | |||
777 | wacom->irq->dev = wacom->usbdev; | 723 | wacom->irq->dev = wacom->usbdev; |
778 | if (usb_submit_urb(wacom->irq, GFP_KERNEL)) { | 724 | if (usb_submit_urb(wacom->irq, GFP_KERNEL)) |
779 | wacom->open--; | ||
780 | return -EIO; | 725 | return -EIO; |
781 | } | ||
782 | 726 | ||
783 | return 0; | 727 | return 0; |
784 | } | 728 | } |
@@ -787,8 +731,7 @@ static void wacom_close(struct input_dev *dev) | |||
787 | { | 731 | { |
788 | struct wacom *wacom = dev->private; | 732 | struct wacom *wacom = dev->private; |
789 | 733 | ||
790 | if (!--wacom->open) | 734 | usb_kill_urb(wacom->irq); |
791 | usb_kill_urb(wacom->irq); | ||
792 | } | 735 | } |
793 | 736 | ||
794 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) | 737 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) |
@@ -823,32 +766,33 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
823 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | 766 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); |
824 | 767 | ||
825 | switch (wacom->features->type) { | 768 | switch (wacom->features->type) { |
826 | case 1: | 769 | case GRAPHIRE: |
827 | wacom->dev.evbit[0] |= BIT(EV_REL); | 770 | wacom->dev.evbit[0] |= BIT(EV_REL); |
828 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 771 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); |
829 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); | 772 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); |
830 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 773 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
831 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); | 774 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); |
832 | break; | 775 | break; |
833 | 776 | ||
834 | case 4: /* new functions for Intuos3 */ | 777 | case INTUOS3: |
778 | case CINTIQ: | ||
835 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | 779 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); |
836 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); | 780 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); |
837 | wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); | 781 | wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); |
838 | /* fall through */ | 782 | /* fall through */ |
839 | 783 | ||
840 | case 2: | 784 | case INTUOS: |
841 | wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); | 785 | wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); |
842 | wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); | 786 | wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); |
843 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 787 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); |
844 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 788 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
845 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) | 789 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) |
846 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); | 790 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); |
847 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); | 791 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); |
848 | break; | 792 | break; |
849 | 793 | ||
850 | case 3: | 794 | case PL: |
851 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); | 795 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); |
852 | break; | 796 | break; |
853 | } | 797 | } |
854 | 798 | ||
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index d65edb22e545..a7fa1b17dcfe 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c | |||
@@ -104,13 +104,12 @@ MODULE_DEVICE_TABLE (usb, xpad_table); | |||
104 | struct usb_xpad { | 104 | struct usb_xpad { |
105 | struct input_dev dev; /* input device interface */ | 105 | struct input_dev dev; /* input device interface */ |
106 | struct usb_device *udev; /* usb device */ | 106 | struct usb_device *udev; /* usb device */ |
107 | 107 | ||
108 | struct urb *irq_in; /* urb for interrupt in report */ | 108 | struct urb *irq_in; /* urb for interrupt in report */ |
109 | unsigned char *idata; /* input data */ | 109 | unsigned char *idata; /* input data */ |
110 | dma_addr_t idata_dma; | 110 | dma_addr_t idata_dma; |
111 | 111 | ||
112 | char phys[65]; /* physical device path */ | 112 | char phys[65]; /* physical device path */ |
113 | int open_count; /* reference count */ | ||
114 | }; | 113 | }; |
115 | 114 | ||
116 | /* | 115 | /* |
@@ -128,35 +127,35 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d | |||
128 | struct input_dev *dev = &xpad->dev; | 127 | struct input_dev *dev = &xpad->dev; |
129 | 128 | ||
130 | input_regs(dev, regs); | 129 | input_regs(dev, regs); |
131 | 130 | ||
132 | /* left stick */ | 131 | /* left stick */ |
133 | input_report_abs(dev, ABS_X, (__s16) (((__s16)data[13] << 8) | data[12])); | 132 | input_report_abs(dev, ABS_X, (__s16) (((__s16)data[13] << 8) | data[12])); |
134 | input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[15] << 8) | data[14])); | 133 | input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[15] << 8) | data[14])); |
135 | 134 | ||
136 | /* right stick */ | 135 | /* right stick */ |
137 | input_report_abs(dev, ABS_RX, (__s16) (((__s16)data[17] << 8) | data[16])); | 136 | input_report_abs(dev, ABS_RX, (__s16) (((__s16)data[17] << 8) | data[16])); |
138 | input_report_abs(dev, ABS_RY, (__s16) (((__s16)data[19] << 8) | data[18])); | 137 | input_report_abs(dev, ABS_RY, (__s16) (((__s16)data[19] << 8) | data[18])); |
139 | 138 | ||
140 | /* triggers left/right */ | 139 | /* triggers left/right */ |
141 | input_report_abs(dev, ABS_Z, data[10]); | 140 | input_report_abs(dev, ABS_Z, data[10]); |
142 | input_report_abs(dev, ABS_RZ, data[11]); | 141 | input_report_abs(dev, ABS_RZ, data[11]); |
143 | 142 | ||
144 | /* digital pad */ | 143 | /* digital pad */ |
145 | input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); | 144 | input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); |
146 | input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); | 145 | input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); |
147 | 146 | ||
148 | /* start/back buttons and stick press left/right */ | 147 | /* start/back buttons and stick press left/right */ |
149 | input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4); | 148 | input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4); |
150 | input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5); | 149 | input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5); |
151 | input_report_key(dev, BTN_THUMBL, (data[2] & 0x40) >> 6); | 150 | input_report_key(dev, BTN_THUMBL, (data[2] & 0x40) >> 6); |
152 | input_report_key(dev, BTN_THUMBR, data[2] >> 7); | 151 | input_report_key(dev, BTN_THUMBR, data[2] >> 7); |
153 | 152 | ||
154 | /* "analog" buttons A, B, X, Y */ | 153 | /* "analog" buttons A, B, X, Y */ |
155 | input_report_key(dev, BTN_A, data[4]); | 154 | input_report_key(dev, BTN_A, data[4]); |
156 | input_report_key(dev, BTN_B, data[5]); | 155 | input_report_key(dev, BTN_B, data[5]); |
157 | input_report_key(dev, BTN_X, data[6]); | 156 | input_report_key(dev, BTN_X, data[6]); |
158 | input_report_key(dev, BTN_Y, data[7]); | 157 | input_report_key(dev, BTN_Y, data[7]); |
159 | 158 | ||
160 | /* "analog" buttons black, white */ | 159 | /* "analog" buttons black, white */ |
161 | input_report_key(dev, BTN_C, data[8]); | 160 | input_report_key(dev, BTN_C, data[8]); |
162 | input_report_key(dev, BTN_Z, data[9]); | 161 | input_report_key(dev, BTN_Z, data[9]); |
@@ -168,7 +167,7 @@ static void xpad_irq_in(struct urb *urb, struct pt_regs *regs) | |||
168 | { | 167 | { |
169 | struct usb_xpad *xpad = urb->context; | 168 | struct usb_xpad *xpad = urb->context; |
170 | int retval; | 169 | int retval; |
171 | 170 | ||
172 | switch (urb->status) { | 171 | switch (urb->status) { |
173 | case 0: | 172 | case 0: |
174 | /* success */ | 173 | /* success */ |
@@ -183,7 +182,7 @@ static void xpad_irq_in(struct urb *urb, struct pt_regs *regs) | |||
183 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); | 182 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); |
184 | goto exit; | 183 | goto exit; |
185 | } | 184 | } |
186 | 185 | ||
187 | xpad_process_packet(xpad, 0, xpad->idata, regs); | 186 | xpad_process_packet(xpad, 0, xpad->idata, regs); |
188 | 187 | ||
189 | exit: | 188 | exit: |
@@ -196,25 +195,19 @@ exit: | |||
196 | static int xpad_open (struct input_dev *dev) | 195 | static int xpad_open (struct input_dev *dev) |
197 | { | 196 | { |
198 | struct usb_xpad *xpad = dev->private; | 197 | struct usb_xpad *xpad = dev->private; |
199 | 198 | ||
200 | if (xpad->open_count++) | ||
201 | return 0; | ||
202 | |||
203 | xpad->irq_in->dev = xpad->udev; | 199 | xpad->irq_in->dev = xpad->udev; |
204 | if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) { | 200 | if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) |
205 | xpad->open_count--; | ||
206 | return -EIO; | 201 | return -EIO; |
207 | } | 202 | |
208 | |||
209 | return 0; | 203 | return 0; |
210 | } | 204 | } |
211 | 205 | ||
212 | static void xpad_close (struct input_dev *dev) | 206 | static void xpad_close (struct input_dev *dev) |
213 | { | 207 | { |
214 | struct usb_xpad *xpad = dev->private; | 208 | struct usb_xpad *xpad = dev->private; |
215 | 209 | ||
216 | if (!--xpad->open_count) | 210 | usb_kill_urb(xpad->irq_in); |
217 | usb_kill_urb(xpad->irq_in); | ||
218 | } | 211 | } |
219 | 212 | ||
220 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) | 213 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) |
@@ -224,19 +217,19 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
224 | struct usb_endpoint_descriptor *ep_irq_in; | 217 | struct usb_endpoint_descriptor *ep_irq_in; |
225 | char path[64]; | 218 | char path[64]; |
226 | int i; | 219 | int i; |
227 | 220 | ||
228 | for (i = 0; xpad_device[i].idVendor; i++) { | 221 | for (i = 0; xpad_device[i].idVendor; i++) { |
229 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && | 222 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && |
230 | (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) | 223 | (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) |
231 | break; | 224 | break; |
232 | } | 225 | } |
233 | 226 | ||
234 | if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { | 227 | if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { |
235 | err("cannot allocate memory for new pad"); | 228 | err("cannot allocate memory for new pad"); |
236 | return -ENOMEM; | 229 | return -ENOMEM; |
237 | } | 230 | } |
238 | memset(xpad, 0, sizeof(struct usb_xpad)); | 231 | memset(xpad, 0, sizeof(struct usb_xpad)); |
239 | 232 | ||
240 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, | 233 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, |
241 | SLAB_ATOMIC, &xpad->idata_dma); | 234 | SLAB_ATOMIC, &xpad->idata_dma); |
242 | if (!xpad->idata) { | 235 | if (!xpad->idata) { |
@@ -251,18 +244,18 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
251 | kfree(xpad); | 244 | kfree(xpad); |
252 | return -ENOMEM; | 245 | return -ENOMEM; |
253 | } | 246 | } |
254 | 247 | ||
255 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; | 248 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; |
256 | 249 | ||
257 | usb_fill_int_urb(xpad->irq_in, udev, | 250 | usb_fill_int_urb(xpad->irq_in, udev, |
258 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | 251 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), |
259 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | 252 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, |
260 | xpad, ep_irq_in->bInterval); | 253 | xpad, ep_irq_in->bInterval); |
261 | xpad->irq_in->transfer_dma = xpad->idata_dma; | 254 | xpad->irq_in->transfer_dma = xpad->idata_dma; |
262 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 255 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
263 | 256 | ||
264 | xpad->udev = udev; | 257 | xpad->udev = udev; |
265 | 258 | ||
266 | xpad->dev.id.bustype = BUS_USB; | 259 | xpad->dev.id.bustype = BUS_USB; |
267 | xpad->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); | 260 | xpad->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); |
268 | xpad->dev.id.product = le16_to_cpu(udev->descriptor.idProduct); | 261 | xpad->dev.id.product = le16_to_cpu(udev->descriptor.idProduct); |
@@ -273,21 +266,21 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
273 | xpad->dev.phys = xpad->phys; | 266 | xpad->dev.phys = xpad->phys; |
274 | xpad->dev.open = xpad_open; | 267 | xpad->dev.open = xpad_open; |
275 | xpad->dev.close = xpad_close; | 268 | xpad->dev.close = xpad_close; |
276 | 269 | ||
277 | usb_make_path(udev, path, 64); | 270 | usb_make_path(udev, path, 64); |
278 | snprintf(xpad->phys, 64, "%s/input0", path); | 271 | snprintf(xpad->phys, 64, "%s/input0", path); |
279 | 272 | ||
280 | xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 273 | xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
281 | 274 | ||
282 | for (i = 0; xpad_btn[i] >= 0; i++) | 275 | for (i = 0; xpad_btn[i] >= 0; i++) |
283 | set_bit(xpad_btn[i], xpad->dev.keybit); | 276 | set_bit(xpad_btn[i], xpad->dev.keybit); |
284 | 277 | ||
285 | for (i = 0; xpad_abs[i] >= 0; i++) { | 278 | for (i = 0; xpad_abs[i] >= 0; i++) { |
286 | 279 | ||
287 | signed short t = xpad_abs[i]; | 280 | signed short t = xpad_abs[i]; |
288 | 281 | ||
289 | set_bit(t, xpad->dev.absbit); | 282 | set_bit(t, xpad->dev.absbit); |
290 | 283 | ||
291 | switch (t) { | 284 | switch (t) { |
292 | case ABS_X: | 285 | case ABS_X: |
293 | case ABS_Y: | 286 | case ABS_Y: |
@@ -310,11 +303,11 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
310 | break; | 303 | break; |
311 | } | 304 | } |
312 | } | 305 | } |
313 | 306 | ||
314 | input_register_device(&xpad->dev); | 307 | input_register_device(&xpad->dev); |
315 | 308 | ||
316 | printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); | 309 | printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); |
317 | 310 | ||
318 | usb_set_intfdata(intf, xpad); | 311 | usb_set_intfdata(intf, xpad); |
319 | return 0; | 312 | return 0; |
320 | } | 313 | } |
@@ -322,7 +315,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
322 | static void xpad_disconnect(struct usb_interface *intf) | 315 | static void xpad_disconnect(struct usb_interface *intf) |
323 | { | 316 | { |
324 | struct usb_xpad *xpad = usb_get_intfdata (intf); | 317 | struct usb_xpad *xpad = usb_get_intfdata (intf); |
325 | 318 | ||
326 | usb_set_intfdata(intf, NULL); | 319 | usb_set_intfdata(intf, NULL); |
327 | if (xpad) { | 320 | if (xpad) { |
328 | usb_kill_urb(xpad->irq_in); | 321 | usb_kill_urb(xpad->irq_in); |
diff --git a/fs/Makefile b/fs/Makefile index fc92e59e9faf..20edcf28bfd2 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -10,6 +10,7 @@ obj-y := open.o read_write.o file_table.o buffer.o bio.o super.o \ | |||
10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ | 10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ |
11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ | 11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ |
12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ | 12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ |
13 | ioprio.o | ||
13 | 14 | ||
14 | obj-$(CONFIG_EPOLL) += eventpoll.o | 15 | obj-$(CONFIG_EPOLL) += eventpoll.o |
15 | obj-$(CONFIG_COMPAT) += compat.o | 16 | obj-$(CONFIG_COMPAT) += compat.o |
diff --git a/fs/ioprio.c b/fs/ioprio.c new file mode 100644 index 000000000000..663e420636d6 --- /dev/null +++ b/fs/ioprio.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * fs/ioprio.c | ||
3 | * | ||
4 | * Copyright (C) 2004 Jens Axboe <axboe@suse.de> | ||
5 | * | ||
6 | * Helper functions for setting/querying io priorities of processes. The | ||
7 | * system calls closely mimmick getpriority/setpriority, see the man page for | ||
8 | * those. The prio argument is a composite of prio class and prio data, where | ||
9 | * the data argument has meaning within that class. The standard scheduling | ||
10 | * classes have 8 distinct prio levels, with 0 being the highest prio and 7 | ||
11 | * being the lowest. | ||
12 | * | ||
13 | * IOW, setting BE scheduling class with prio 2 is done ala: | ||
14 | * | ||
15 | * unsigned int prio = (IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT) | 2; | ||
16 | * | ||
17 | * ioprio_set(PRIO_PROCESS, pid, prio); | ||
18 | * | ||
19 | * See also Documentation/block/ioprio.txt | ||
20 | * | ||
21 | */ | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/ioprio.h> | ||
24 | #include <linux/blkdev.h> | ||
25 | |||
26 | static int set_task_ioprio(struct task_struct *task, int ioprio) | ||
27 | { | ||
28 | struct io_context *ioc; | ||
29 | |||
30 | if (task->uid != current->euid && | ||
31 | task->uid != current->uid && !capable(CAP_SYS_NICE)) | ||
32 | return -EPERM; | ||
33 | |||
34 | task_lock(task); | ||
35 | |||
36 | task->ioprio = ioprio; | ||
37 | |||
38 | ioc = task->io_context; | ||
39 | if (ioc && ioc->set_ioprio) | ||
40 | ioc->set_ioprio(ioc, ioprio); | ||
41 | |||
42 | task_unlock(task); | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | asmlinkage int sys_ioprio_set(int which, int who, int ioprio) | ||
47 | { | ||
48 | int class = IOPRIO_PRIO_CLASS(ioprio); | ||
49 | int data = IOPRIO_PRIO_DATA(ioprio); | ||
50 | struct task_struct *p, *g; | ||
51 | struct user_struct *user; | ||
52 | int ret; | ||
53 | |||
54 | switch (class) { | ||
55 | case IOPRIO_CLASS_RT: | ||
56 | if (!capable(CAP_SYS_ADMIN)) | ||
57 | return -EPERM; | ||
58 | /* fall through, rt has prio field too */ | ||
59 | case IOPRIO_CLASS_BE: | ||
60 | if (data >= IOPRIO_BE_NR || data < 0) | ||
61 | return -EINVAL; | ||
62 | |||
63 | break; | ||
64 | case IOPRIO_CLASS_IDLE: | ||
65 | break; | ||
66 | default: | ||
67 | return -EINVAL; | ||
68 | } | ||
69 | |||
70 | ret = -ESRCH; | ||
71 | read_lock_irq(&tasklist_lock); | ||
72 | switch (which) { | ||
73 | case IOPRIO_WHO_PROCESS: | ||
74 | if (!who) | ||
75 | p = current; | ||
76 | else | ||
77 | p = find_task_by_pid(who); | ||
78 | if (p) | ||
79 | ret = set_task_ioprio(p, ioprio); | ||
80 | break; | ||
81 | case IOPRIO_WHO_PGRP: | ||
82 | if (!who) | ||
83 | who = process_group(current); | ||
84 | do_each_task_pid(who, PIDTYPE_PGID, p) { | ||
85 | ret = set_task_ioprio(p, ioprio); | ||
86 | if (ret) | ||
87 | break; | ||
88 | } while_each_task_pid(who, PIDTYPE_PGID, p); | ||
89 | break; | ||
90 | case IOPRIO_WHO_USER: | ||
91 | if (!who) | ||
92 | user = current->user; | ||
93 | else | ||
94 | user = find_user(who); | ||
95 | |||
96 | if (!user) | ||
97 | break; | ||
98 | |||
99 | do_each_thread(g, p) { | ||
100 | if (p->uid != who) | ||
101 | continue; | ||
102 | ret = set_task_ioprio(p, ioprio); | ||
103 | if (ret) | ||
104 | break; | ||
105 | } while_each_thread(g, p); | ||
106 | |||
107 | if (who) | ||
108 | free_uid(user); | ||
109 | break; | ||
110 | default: | ||
111 | ret = -EINVAL; | ||
112 | } | ||
113 | |||
114 | read_unlock_irq(&tasklist_lock); | ||
115 | return ret; | ||
116 | } | ||
117 | |||
118 | asmlinkage int sys_ioprio_get(int which, int who) | ||
119 | { | ||
120 | struct task_struct *g, *p; | ||
121 | struct user_struct *user; | ||
122 | int ret = -ESRCH; | ||
123 | |||
124 | read_lock_irq(&tasklist_lock); | ||
125 | switch (which) { | ||
126 | case IOPRIO_WHO_PROCESS: | ||
127 | if (!who) | ||
128 | p = current; | ||
129 | else | ||
130 | p = find_task_by_pid(who); | ||
131 | if (p) | ||
132 | ret = p->ioprio; | ||
133 | break; | ||
134 | case IOPRIO_WHO_PGRP: | ||
135 | if (!who) | ||
136 | who = process_group(current); | ||
137 | do_each_task_pid(who, PIDTYPE_PGID, p) { | ||
138 | if (ret == -ESRCH) | ||
139 | ret = p->ioprio; | ||
140 | else | ||
141 | ret = ioprio_best(ret, p->ioprio); | ||
142 | } while_each_task_pid(who, PIDTYPE_PGID, p); | ||
143 | break; | ||
144 | case IOPRIO_WHO_USER: | ||
145 | if (!who) | ||
146 | user = current->user; | ||
147 | else | ||
148 | user = find_user(who); | ||
149 | |||
150 | if (!user) | ||
151 | break; | ||
152 | |||
153 | do_each_thread(g, p) { | ||
154 | if (p->uid != user->uid) | ||
155 | continue; | ||
156 | if (ret == -ESRCH) | ||
157 | ret = p->ioprio; | ||
158 | else | ||
159 | ret = ioprio_best(ret, p->ioprio); | ||
160 | } while_each_thread(g, p); | ||
161 | |||
162 | if (who) | ||
163 | free_uid(user); | ||
164 | break; | ||
165 | default: | ||
166 | ret = -EINVAL; | ||
167 | } | ||
168 | |||
169 | read_unlock_irq(&tasklist_lock); | ||
170 | return ret; | ||
171 | } | ||
172 | |||
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 7b87707acc36..d1bcf0da6728 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -645,18 +645,22 @@ struct buffer_chunk { | |||
645 | 645 | ||
646 | static void write_chunk(struct buffer_chunk *chunk) { | 646 | static void write_chunk(struct buffer_chunk *chunk) { |
647 | int i; | 647 | int i; |
648 | get_fs_excl(); | ||
648 | for (i = 0; i < chunk->nr ; i++) { | 649 | for (i = 0; i < chunk->nr ; i++) { |
649 | submit_logged_buffer(chunk->bh[i]) ; | 650 | submit_logged_buffer(chunk->bh[i]) ; |
650 | } | 651 | } |
651 | chunk->nr = 0; | 652 | chunk->nr = 0; |
653 | put_fs_excl(); | ||
652 | } | 654 | } |
653 | 655 | ||
654 | static void write_ordered_chunk(struct buffer_chunk *chunk) { | 656 | static void write_ordered_chunk(struct buffer_chunk *chunk) { |
655 | int i; | 657 | int i; |
658 | get_fs_excl(); | ||
656 | for (i = 0; i < chunk->nr ; i++) { | 659 | for (i = 0; i < chunk->nr ; i++) { |
657 | submit_ordered_buffer(chunk->bh[i]) ; | 660 | submit_ordered_buffer(chunk->bh[i]) ; |
658 | } | 661 | } |
659 | chunk->nr = 0; | 662 | chunk->nr = 0; |
663 | put_fs_excl(); | ||
660 | } | 664 | } |
661 | 665 | ||
662 | static int add_to_chunk(struct buffer_chunk *chunk, struct buffer_head *bh, | 666 | static int add_to_chunk(struct buffer_chunk *chunk, struct buffer_head *bh, |
@@ -918,6 +922,8 @@ static int flush_commit_list(struct super_block *s, struct reiserfs_journal_list | |||
918 | return 0 ; | 922 | return 0 ; |
919 | } | 923 | } |
920 | 924 | ||
925 | get_fs_excl(); | ||
926 | |||
921 | /* before we can put our commit blocks on disk, we have to make sure everyone older than | 927 | /* before we can put our commit blocks on disk, we have to make sure everyone older than |
922 | ** us is on disk too | 928 | ** us is on disk too |
923 | */ | 929 | */ |
@@ -1055,6 +1061,7 @@ put_jl: | |||
1055 | 1061 | ||
1056 | if (retval) | 1062 | if (retval) |
1057 | reiserfs_abort (s, retval, "Journal write error in %s", __FUNCTION__); | 1063 | reiserfs_abort (s, retval, "Journal write error in %s", __FUNCTION__); |
1064 | put_fs_excl(); | ||
1058 | return retval; | 1065 | return retval; |
1059 | } | 1066 | } |
1060 | 1067 | ||
@@ -1251,6 +1258,8 @@ static int flush_journal_list(struct super_block *s, | |||
1251 | return 0 ; | 1258 | return 0 ; |
1252 | } | 1259 | } |
1253 | 1260 | ||
1261 | get_fs_excl(); | ||
1262 | |||
1254 | /* if all the work is already done, get out of here */ | 1263 | /* if all the work is already done, get out of here */ |
1255 | if (atomic_read(&(jl->j_nonzerolen)) <= 0 && | 1264 | if (atomic_read(&(jl->j_nonzerolen)) <= 0 && |
1256 | atomic_read(&(jl->j_commit_left)) <= 0) { | 1265 | atomic_read(&(jl->j_commit_left)) <= 0) { |
@@ -1450,6 +1459,7 @@ flush_older_and_return: | |||
1450 | put_journal_list(s, jl); | 1459 | put_journal_list(s, jl); |
1451 | if (flushall) | 1460 | if (flushall) |
1452 | up(&journal->j_flush_sem); | 1461 | up(&journal->j_flush_sem); |
1462 | put_fs_excl(); | ||
1453 | return err ; | 1463 | return err ; |
1454 | } | 1464 | } |
1455 | 1465 | ||
@@ -2719,6 +2729,7 @@ relock: | |||
2719 | th->t_trans_id = journal->j_trans_id ; | 2729 | th->t_trans_id = journal->j_trans_id ; |
2720 | unlock_journal(p_s_sb) ; | 2730 | unlock_journal(p_s_sb) ; |
2721 | INIT_LIST_HEAD (&th->t_list); | 2731 | INIT_LIST_HEAD (&th->t_list); |
2732 | get_fs_excl(); | ||
2722 | return 0 ; | 2733 | return 0 ; |
2723 | 2734 | ||
2724 | out_fail: | 2735 | out_fail: |
@@ -3526,6 +3537,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, struct super_b | |||
3526 | BUG_ON (th->t_refcount > 1); | 3537 | BUG_ON (th->t_refcount > 1); |
3527 | BUG_ON (!th->t_trans_id); | 3538 | BUG_ON (!th->t_trans_id); |
3528 | 3539 | ||
3540 | put_fs_excl(); | ||
3529 | current->journal_info = th->t_handle_save; | 3541 | current->journal_info = th->t_handle_save; |
3530 | reiserfs_check_lock_depth(p_s_sb, "journal end"); | 3542 | reiserfs_check_lock_depth(p_s_sb, "journal end"); |
3531 | if (journal->j_len == 0) { | 3543 | if (journal->j_len == 0) { |
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h index 176413fb9ae3..e25e4c71a879 100644 --- a/include/asm-i386/unistd.h +++ b/include/asm-i386/unistd.h | |||
@@ -294,8 +294,10 @@ | |||
294 | #define __NR_add_key 286 | 294 | #define __NR_add_key 286 |
295 | #define __NR_request_key 287 | 295 | #define __NR_request_key 287 |
296 | #define __NR_keyctl 288 | 296 | #define __NR_keyctl 288 |
297 | #define __NR_ioprio_set 289 | ||
298 | #define __NR_ioprio_get 290 | ||
297 | 299 | ||
298 | #define NR_syscalls 289 | 300 | #define NR_syscalls 291 |
299 | 301 | ||
300 | /* | 302 | /* |
301 | * user-visible error numbers are in the range -1 - -128: see | 303 | * user-visible error numbers are in the range -1 - -128: see |
diff --git a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h index f7f43ec2483a..517f1649ee64 100644 --- a/include/asm-ia64/unistd.h +++ b/include/asm-ia64/unistd.h | |||
@@ -263,6 +263,8 @@ | |||
263 | #define __NR_add_key 1271 | 263 | #define __NR_add_key 1271 |
264 | #define __NR_request_key 1272 | 264 | #define __NR_request_key 1272 |
265 | #define __NR_keyctl 1273 | 265 | #define __NR_keyctl 1273 |
266 | #define __NR_ioprio_set 1274 | ||
267 | #define __NR_ioprio_get 1275 | ||
266 | #define __NR_set_zone_reclaim 1276 | 268 | #define __NR_set_zone_reclaim 1276 |
267 | 269 | ||
268 | #ifdef __KERNEL__ | 270 | #ifdef __KERNEL__ |
diff --git a/include/asm-ppc/unistd.h b/include/asm-ppc/unistd.h index cc51e5c9acc2..e8b79220b29c 100644 --- a/include/asm-ppc/unistd.h +++ b/include/asm-ppc/unistd.h | |||
@@ -277,8 +277,10 @@ | |||
277 | #define __NR_request_key 270 | 277 | #define __NR_request_key 270 |
278 | #define __NR_keyctl 271 | 278 | #define __NR_keyctl 271 |
279 | #define __NR_waitid 272 | 279 | #define __NR_waitid 272 |
280 | #define __NR_ioprio_set 273 | ||
281 | #define __NR_ioprio_get 274 | ||
280 | 282 | ||
281 | #define __NR_syscalls 273 | 283 | #define __NR_syscalls 275 |
282 | 284 | ||
283 | #define __NR(n) #n | 285 | #define __NR(n) #n |
284 | 286 | ||
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h index d767adcbf0ff..6560439a83e4 100644 --- a/include/asm-x86_64/unistd.h +++ b/include/asm-x86_64/unistd.h | |||
@@ -561,8 +561,12 @@ __SYSCALL(__NR_add_key, sys_add_key) | |||
561 | __SYSCALL(__NR_request_key, sys_request_key) | 561 | __SYSCALL(__NR_request_key, sys_request_key) |
562 | #define __NR_keyctl 250 | 562 | #define __NR_keyctl 250 |
563 | __SYSCALL(__NR_keyctl, sys_keyctl) | 563 | __SYSCALL(__NR_keyctl, sys_keyctl) |
564 | #define __NR_ioprio_set 251 | ||
565 | __SYSCALL(__NR_ioprio_set, sys_ioprio_set) | ||
566 | #define __NR_ioprio_get 252 | ||
567 | __SYSCALL(__NR_ioprio_get, sys_ioprio_get) | ||
564 | 568 | ||
565 | #define __NR_syscall_max __NR_keyctl | 569 | #define __NR_syscall_max __NR_ioprio_get |
566 | #ifndef __NO_STUBS | 570 | #ifndef __NO_STUBS |
567 | 571 | ||
568 | /* user-visible error numbers are in the range -1 - -4095 */ | 572 | /* user-visible error numbers are in the range -1 - -4095 */ |
diff --git a/include/linux/bio.h b/include/linux/bio.h index 038022763f09..36ef29fa0d8b 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/highmem.h> | 23 | #include <linux/highmem.h> |
24 | #include <linux/mempool.h> | 24 | #include <linux/mempool.h> |
25 | #include <linux/ioprio.h> | ||
25 | 26 | ||
26 | /* Platforms may set this to teach the BIO layer about IOMMU hardware. */ | 27 | /* Platforms may set this to teach the BIO layer about IOMMU hardware. */ |
27 | #include <asm/io.h> | 28 | #include <asm/io.h> |
@@ -150,6 +151,19 @@ struct bio { | |||
150 | #define BIO_RW_SYNC 4 | 151 | #define BIO_RW_SYNC 4 |
151 | 152 | ||
152 | /* | 153 | /* |
154 | * upper 16 bits of bi_rw define the io priority of this bio | ||
155 | */ | ||
156 | #define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS) | ||
157 | #define bio_prio(bio) ((bio)->bi_rw >> BIO_PRIO_SHIFT) | ||
158 | #define bio_prio_valid(bio) ioprio_valid(bio_prio(bio)) | ||
159 | |||
160 | #define bio_set_prio(bio, prio) do { \ | ||
161 | WARN_ON(prio >= (1 << IOPRIO_BITS)); \ | ||
162 | (bio)->bi_rw &= ((1UL << BIO_PRIO_SHIFT) - 1); \ | ||
163 | (bio)->bi_rw |= ((unsigned long) (prio) << BIO_PRIO_SHIFT); \ | ||
164 | } while (0) | ||
165 | |||
166 | /* | ||
153 | * various member access, note that bio_data should of course not be used | 167 | * various member access, note that bio_data should of course not be used |
154 | * on highmem page vectors | 168 | * on highmem page vectors |
155 | */ | 169 | */ |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index b54a0348a890..21a8674cd149 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -54,16 +54,23 @@ struct as_io_context { | |||
54 | 54 | ||
55 | struct cfq_queue; | 55 | struct cfq_queue; |
56 | struct cfq_io_context { | 56 | struct cfq_io_context { |
57 | void (*dtor)(struct cfq_io_context *); | ||
58 | void (*exit)(struct cfq_io_context *); | ||
59 | |||
60 | struct io_context *ioc; | ||
61 | |||
62 | /* | 57 | /* |
63 | * circular list of cfq_io_contexts belonging to a process io context | 58 | * circular list of cfq_io_contexts belonging to a process io context |
64 | */ | 59 | */ |
65 | struct list_head list; | 60 | struct list_head list; |
66 | struct cfq_queue *cfqq; | 61 | struct cfq_queue *cfqq; |
62 | void *key; | ||
63 | |||
64 | struct io_context *ioc; | ||
65 | |||
66 | unsigned long last_end_request; | ||
67 | unsigned long last_queue; | ||
68 | unsigned long ttime_total; | ||
69 | unsigned long ttime_samples; | ||
70 | unsigned long ttime_mean; | ||
71 | |||
72 | void (*dtor)(struct cfq_io_context *); | ||
73 | void (*exit)(struct cfq_io_context *); | ||
67 | }; | 74 | }; |
68 | 75 | ||
69 | /* | 76 | /* |
@@ -73,7 +80,9 @@ struct cfq_io_context { | |||
73 | */ | 80 | */ |
74 | struct io_context { | 81 | struct io_context { |
75 | atomic_t refcount; | 82 | atomic_t refcount; |
76 | pid_t pid; | 83 | struct task_struct *task; |
84 | |||
85 | int (*set_ioprio)(struct io_context *, unsigned int); | ||
77 | 86 | ||
78 | /* | 87 | /* |
79 | * For request batching | 88 | * For request batching |
@@ -81,8 +90,6 @@ struct io_context { | |||
81 | unsigned long last_waited; /* Time last woken after wait for request */ | 90 | unsigned long last_waited; /* Time last woken after wait for request */ |
82 | int nr_batch_requests; /* Number of requests left in the batch */ | 91 | int nr_batch_requests; /* Number of requests left in the batch */ |
83 | 92 | ||
84 | spinlock_t lock; | ||
85 | |||
86 | struct as_io_context *aic; | 93 | struct as_io_context *aic; |
87 | struct cfq_io_context *cic; | 94 | struct cfq_io_context *cic; |
88 | }; | 95 | }; |
@@ -134,6 +141,8 @@ struct request { | |||
134 | 141 | ||
135 | void *elevator_private; | 142 | void *elevator_private; |
136 | 143 | ||
144 | unsigned short ioprio; | ||
145 | |||
137 | int rq_status; /* should split this into a few status bits */ | 146 | int rq_status; /* should split this into a few status bits */ |
138 | struct gendisk *rq_disk; | 147 | struct gendisk *rq_disk; |
139 | int errors; | 148 | int errors; |
diff --git a/include/linux/elevator.h b/include/linux/elevator.h index ee54f81faad5..ea6bbc2d7407 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h | |||
@@ -16,9 +16,9 @@ typedef void (elevator_remove_req_fn) (request_queue_t *, struct request *); | |||
16 | typedef void (elevator_requeue_req_fn) (request_queue_t *, struct request *); | 16 | typedef void (elevator_requeue_req_fn) (request_queue_t *, struct request *); |
17 | typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); | 17 | typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); |
18 | typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); | 18 | typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); |
19 | typedef int (elevator_may_queue_fn) (request_queue_t *, int); | 19 | typedef int (elevator_may_queue_fn) (request_queue_t *, int, struct bio *); |
20 | 20 | ||
21 | typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, int); | 21 | typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, struct bio *, int); |
22 | typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); | 22 | typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); |
23 | typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); | 23 | typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); |
24 | 24 | ||
@@ -96,9 +96,9 @@ extern struct request *elv_former_request(request_queue_t *, struct request *); | |||
96 | extern struct request *elv_latter_request(request_queue_t *, struct request *); | 96 | extern struct request *elv_latter_request(request_queue_t *, struct request *); |
97 | extern int elv_register_queue(request_queue_t *q); | 97 | extern int elv_register_queue(request_queue_t *q); |
98 | extern void elv_unregister_queue(request_queue_t *q); | 98 | extern void elv_unregister_queue(request_queue_t *q); |
99 | extern int elv_may_queue(request_queue_t *, int); | 99 | extern int elv_may_queue(request_queue_t *, int, struct bio *); |
100 | extern void elv_completed_request(request_queue_t *, struct request *); | 100 | extern void elv_completed_request(request_queue_t *, struct request *); |
101 | extern int elv_set_request(request_queue_t *, struct request *, int); | 101 | extern int elv_set_request(request_queue_t *, struct request *, struct bio *, int); |
102 | extern void elv_put_request(request_queue_t *, struct request *); | 102 | extern void elv_put_request(request_queue_t *, struct request *); |
103 | 103 | ||
104 | /* | 104 | /* |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 3ae8e37bdfc8..047bde30836a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -213,6 +213,7 @@ extern int dir_notify_enable; | |||
213 | #include <linux/radix-tree.h> | 213 | #include <linux/radix-tree.h> |
214 | #include <linux/prio_tree.h> | 214 | #include <linux/prio_tree.h> |
215 | #include <linux/init.h> | 215 | #include <linux/init.h> |
216 | #include <linux/sched.h> | ||
216 | 217 | ||
217 | #include <asm/atomic.h> | 218 | #include <asm/atomic.h> |
218 | #include <asm/semaphore.h> | 219 | #include <asm/semaphore.h> |
@@ -822,16 +823,34 @@ enum { | |||
822 | #define vfs_check_frozen(sb, level) \ | 823 | #define vfs_check_frozen(sb, level) \ |
823 | wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level))) | 824 | wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level))) |
824 | 825 | ||
826 | static inline void get_fs_excl(void) | ||
827 | { | ||
828 | atomic_inc(¤t->fs_excl); | ||
829 | } | ||
830 | |||
831 | static inline void put_fs_excl(void) | ||
832 | { | ||
833 | atomic_dec(¤t->fs_excl); | ||
834 | } | ||
835 | |||
836 | static inline int has_fs_excl(void) | ||
837 | { | ||
838 | return atomic_read(¤t->fs_excl); | ||
839 | } | ||
840 | |||
841 | |||
825 | /* | 842 | /* |
826 | * Superblock locking. | 843 | * Superblock locking. |
827 | */ | 844 | */ |
828 | static inline void lock_super(struct super_block * sb) | 845 | static inline void lock_super(struct super_block * sb) |
829 | { | 846 | { |
847 | get_fs_excl(); | ||
830 | down(&sb->s_lock); | 848 | down(&sb->s_lock); |
831 | } | 849 | } |
832 | 850 | ||
833 | static inline void unlock_super(struct super_block * sb) | 851 | static inline void unlock_super(struct super_block * sb) |
834 | { | 852 | { |
853 | put_fs_excl(); | ||
835 | up(&sb->s_lock); | 854 | up(&sb->s_lock); |
836 | } | 855 | } |
837 | 856 | ||
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 03206a425d7a..c727c195a91a 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -81,6 +81,7 @@ extern struct group_info init_groups; | |||
81 | .mm = NULL, \ | 81 | .mm = NULL, \ |
82 | .active_mm = &init_mm, \ | 82 | .active_mm = &init_mm, \ |
83 | .run_list = LIST_HEAD_INIT(tsk.run_list), \ | 83 | .run_list = LIST_HEAD_INIT(tsk.run_list), \ |
84 | .ioprio = 0, \ | ||
84 | .time_slice = HZ, \ | 85 | .time_slice = HZ, \ |
85 | .tasks = LIST_HEAD_INIT(tsk.tasks), \ | 86 | .tasks = LIST_HEAD_INIT(tsk.tasks), \ |
86 | .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \ | 87 | .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \ |
@@ -110,6 +111,7 @@ extern struct group_info init_groups; | |||
110 | .proc_lock = SPIN_LOCK_UNLOCKED, \ | 111 | .proc_lock = SPIN_LOCK_UNLOCKED, \ |
111 | .journal_info = NULL, \ | 112 | .journal_info = NULL, \ |
112 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ | 113 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
114 | .fs_excl = ATOMIC_INIT(0), \ | ||
113 | } | 115 | } |
114 | 116 | ||
115 | 117 | ||
diff --git a/include/linux/input.h b/include/linux/input.h index 9d9598ed760d..b9cc0ac71f44 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -859,6 +859,10 @@ struct input_dev { | |||
859 | int (*erase_effect)(struct input_dev *dev, int effect_id); | 859 | int (*erase_effect)(struct input_dev *dev, int effect_id); |
860 | 860 | ||
861 | struct input_handle *grab; | 861 | struct input_handle *grab; |
862 | |||
863 | struct semaphore sem; /* serializes open and close operations */ | ||
864 | unsigned int users; | ||
865 | |||
862 | struct device *dev; | 866 | struct device *dev; |
863 | 867 | ||
864 | struct list_head h_list; | 868 | struct list_head h_list; |
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h new file mode 100644 index 000000000000..8a453a0b5e4b --- /dev/null +++ b/include/linux/ioprio.h | |||
@@ -0,0 +1,88 @@ | |||
1 | #ifndef IOPRIO_H | ||
2 | #define IOPRIO_H | ||
3 | |||
4 | #include <linux/sched.h> | ||
5 | |||
6 | /* | ||
7 | * Gives us 8 prio classes with 13-bits of data for each class | ||
8 | */ | ||
9 | #define IOPRIO_BITS (16) | ||
10 | #define IOPRIO_CLASS_SHIFT (13) | ||
11 | #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) | ||
12 | |||
13 | #define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT) | ||
14 | #define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) | ||
15 | #define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data) | ||
16 | |||
17 | #define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE) | ||
18 | |||
19 | /* | ||
20 | * These are the io priority groups as implemented by CFQ. RT is the realtime | ||
21 | * class, it always gets premium service. BE is the best-effort scheduling | ||
22 | * class, the default for any process. IDLE is the idle scheduling class, it | ||
23 | * is only served when no one else is using the disk. | ||
24 | */ | ||
25 | enum { | ||
26 | IOPRIO_CLASS_NONE, | ||
27 | IOPRIO_CLASS_RT, | ||
28 | IOPRIO_CLASS_BE, | ||
29 | IOPRIO_CLASS_IDLE, | ||
30 | }; | ||
31 | |||
32 | /* | ||
33 | * 8 best effort priority levels are supported | ||
34 | */ | ||
35 | #define IOPRIO_BE_NR (8) | ||
36 | |||
37 | asmlinkage int sys_ioprio_set(int, int, int); | ||
38 | asmlinkage int sys_ioprio_get(int, int); | ||
39 | |||
40 | enum { | ||
41 | IOPRIO_WHO_PROCESS = 1, | ||
42 | IOPRIO_WHO_PGRP, | ||
43 | IOPRIO_WHO_USER, | ||
44 | }; | ||
45 | |||
46 | /* | ||
47 | * if process has set io priority explicitly, use that. if not, convert | ||
48 | * the cpu scheduler nice value to an io priority | ||
49 | */ | ||
50 | #define IOPRIO_NORM (4) | ||
51 | static inline int task_ioprio(struct task_struct *task) | ||
52 | { | ||
53 | WARN_ON(!ioprio_valid(task->ioprio)); | ||
54 | return IOPRIO_PRIO_DATA(task->ioprio); | ||
55 | } | ||
56 | |||
57 | static inline int task_nice_ioprio(struct task_struct *task) | ||
58 | { | ||
59 | return (task_nice(task) + 20) / 5; | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * For inheritance, return the highest of the two given priorities | ||
64 | */ | ||
65 | static inline int ioprio_best(unsigned short aprio, unsigned short bprio) | ||
66 | { | ||
67 | unsigned short aclass = IOPRIO_PRIO_CLASS(aprio); | ||
68 | unsigned short bclass = IOPRIO_PRIO_CLASS(bprio); | ||
69 | |||
70 | if (!ioprio_valid(aprio)) | ||
71 | return bprio; | ||
72 | if (!ioprio_valid(bprio)) | ||
73 | return aprio; | ||
74 | |||
75 | if (aclass == IOPRIO_CLASS_NONE) | ||
76 | aclass = IOPRIO_CLASS_BE; | ||
77 | if (bclass == IOPRIO_CLASS_NONE) | ||
78 | bclass = IOPRIO_CLASS_BE; | ||
79 | |||
80 | if (aclass == bclass) | ||
81 | return min(aprio, bprio); | ||
82 | if (aclass > bclass) | ||
83 | return bprio; | ||
84 | else | ||
85 | return aprio; | ||
86 | } | ||
87 | |||
88 | #endif | ||
diff --git a/include/linux/joystick.h b/include/linux/joystick.h index b7e0ab622cd7..06b9af77eb7f 100644 --- a/include/linux/joystick.h +++ b/include/linux/joystick.h | |||
@@ -111,18 +111,35 @@ struct js_corr { | |||
111 | #define JS_SET_ALL 8 | 111 | #define JS_SET_ALL 8 |
112 | 112 | ||
113 | struct JS_DATA_TYPE { | 113 | struct JS_DATA_TYPE { |
114 | int buttons; | 114 | __s32 buttons; |
115 | int x; | 115 | __s32 x; |
116 | int y; | 116 | __s32 y; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | struct JS_DATA_SAVE_TYPE { | 119 | struct JS_DATA_SAVE_TYPE_32 { |
120 | int JS_TIMEOUT; | 120 | __s32 JS_TIMEOUT; |
121 | int BUSY; | 121 | __s32 BUSY; |
122 | long JS_EXPIRETIME; | 122 | __s32 JS_EXPIRETIME; |
123 | long JS_TIMELIMIT; | 123 | __s32 JS_TIMELIMIT; |
124 | struct JS_DATA_TYPE JS_SAVE; | 124 | struct JS_DATA_TYPE JS_SAVE; |
125 | struct JS_DATA_TYPE JS_CORR; | 125 | struct JS_DATA_TYPE JS_CORR; |
126 | }; | 126 | }; |
127 | 127 | ||
128 | struct JS_DATA_SAVE_TYPE_64 { | ||
129 | __s32 JS_TIMEOUT; | ||
130 | __s32 BUSY; | ||
131 | __s64 JS_EXPIRETIME; | ||
132 | __s64 JS_TIMELIMIT; | ||
133 | struct JS_DATA_TYPE JS_SAVE; | ||
134 | struct JS_DATA_TYPE JS_CORR; | ||
135 | }; | ||
136 | |||
137 | #if BITS_PER_LONG == 64 | ||
138 | #define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_64 | ||
139 | #elif BITS_PER_LONG == 32 | ||
140 | #define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_32 | ||
141 | #else | ||
142 | #error Unexpected BITS_PER_LONG | ||
143 | #endif | ||
144 | |||
128 | #endif /* _LINUX_JOYSTICK_H */ | 145 | #endif /* _LINUX_JOYSTICK_H */ |
diff --git a/include/linux/libps2.h b/include/linux/libps2.h index 923bdbc6d9e4..a710bddda4eb 100644 --- a/include/linux/libps2.h +++ b/include/linux/libps2.h | |||
@@ -41,6 +41,7 @@ struct ps2dev { | |||
41 | 41 | ||
42 | void ps2_init(struct ps2dev *ps2dev, struct serio *serio); | 42 | void ps2_init(struct ps2dev *ps2dev, struct serio *serio); |
43 | int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout); | 43 | int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout); |
44 | void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout); | ||
44 | int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command); | 45 | int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command); |
45 | int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int command); | 46 | int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int command); |
46 | int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data); | 47 | int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data); |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 9530b1903160..ff48815bd3a2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -608,6 +608,8 @@ struct task_struct { | |||
608 | struct list_head run_list; | 608 | struct list_head run_list; |
609 | prio_array_t *array; | 609 | prio_array_t *array; |
610 | 610 | ||
611 | unsigned short ioprio; | ||
612 | |||
611 | unsigned long sleep_avg; | 613 | unsigned long sleep_avg; |
612 | unsigned long long timestamp, last_ran; | 614 | unsigned long long timestamp, last_ran; |
613 | unsigned long long sched_time; /* sched_clock time spent running */ | 615 | unsigned long long sched_time; /* sched_clock time spent running */ |
@@ -763,6 +765,7 @@ struct task_struct { | |||
763 | nodemask_t mems_allowed; | 765 | nodemask_t mems_allowed; |
764 | int cpuset_mems_generation; | 766 | int cpuset_mems_generation; |
765 | #endif | 767 | #endif |
768 | atomic_t fs_excl; /* holding fs exclusive resources */ | ||
766 | }; | 769 | }; |
767 | 770 | ||
768 | static inline pid_t process_group(struct task_struct *tsk) | 771 | static inline pid_t process_group(struct task_struct *tsk) |
@@ -1112,7 +1115,8 @@ extern void unhash_process(struct task_struct *p); | |||
1112 | 1115 | ||
1113 | /* | 1116 | /* |
1114 | * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm, keyring | 1117 | * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm, keyring |
1115 | * subscriptions and synchronises with wait4(). Also used in procfs. | 1118 | * subscriptions and synchronises with wait4(). Also used in procfs. Also |
1119 | * pins the final release of task.io_context. | ||
1116 | * | 1120 | * |
1117 | * Nests both inside and outside of read_lock(&tasklist_lock). | 1121 | * Nests both inside and outside of read_lock(&tasklist_lock). |
1118 | * It must not be nested with write_lock_irq(&tasklist_lock), | 1122 | * It must not be nested with write_lock_irq(&tasklist_lock), |
diff --git a/include/linux/serio.h b/include/linux/serio.h index a2d3b9ae06f4..aa4d6493a034 100644 --- a/include/linux/serio.h +++ b/include/linux/serio.h | |||
@@ -83,6 +83,7 @@ static inline void serio_register_port(struct serio *serio) | |||
83 | } | 83 | } |
84 | 84 | ||
85 | void serio_unregister_port(struct serio *serio); | 85 | void serio_unregister_port(struct serio *serio); |
86 | void serio_unregister_child_port(struct serio *serio); | ||
86 | void __serio_unregister_port_delayed(struct serio *serio, struct module *owner); | 87 | void __serio_unregister_port_delayed(struct serio *serio, struct module *owner); |
87 | static inline void serio_unregister_port_delayed(struct serio *serio) | 88 | static inline void serio_unregister_port_delayed(struct serio *serio) |
88 | { | 89 | { |
@@ -153,6 +154,11 @@ static inline int serio_pin_driver(struct serio *serio) | |||
153 | return down_interruptible(&serio->drv_sem); | 154 | return down_interruptible(&serio->drv_sem); |
154 | } | 155 | } |
155 | 156 | ||
157 | static inline void serio_pin_driver_uninterruptible(struct serio *serio) | ||
158 | { | ||
159 | down(&serio->drv_sem); | ||
160 | } | ||
161 | |||
156 | static inline void serio_unpin_driver(struct serio *serio) | 162 | static inline void serio_unpin_driver(struct serio *serio) |
157 | { | 163 | { |
158 | up(&serio->drv_sem); | 164 | up(&serio->drv_sem); |
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 1262cb43c3ab..d5c3fe1bf33d 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
@@ -14,11 +14,13 @@ extern struct list_head inode_unused; | |||
14 | * Yes, writeback.h requires sched.h | 14 | * Yes, writeback.h requires sched.h |
15 | * No, sched.h is not included from here. | 15 | * No, sched.h is not included from here. |
16 | */ | 16 | */ |
17 | static inline int current_is_pdflush(void) | 17 | static inline int task_is_pdflush(struct task_struct *task) |
18 | { | 18 | { |
19 | return current->flags & PF_FLUSHER; | 19 | return task->flags & PF_FLUSHER; |
20 | } | 20 | } |
21 | 21 | ||
22 | #define current_is_pdflush() task_is_pdflush(current) | ||
23 | |||
22 | /* | 24 | /* |
23 | * fs/fs-writeback.c | 25 | * fs/fs-writeback.c |
24 | */ | 26 | */ |
diff --git a/kernel/exit.c b/kernel/exit.c index 3ebcd60a19c6..9d1b10ed0135 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -784,6 +784,8 @@ fastcall NORET_TYPE void do_exit(long code) | |||
784 | 784 | ||
785 | profile_task_exit(tsk); | 785 | profile_task_exit(tsk); |
786 | 786 | ||
787 | WARN_ON(atomic_read(&tsk->fs_excl)); | ||
788 | |||
787 | if (unlikely(in_interrupt())) | 789 | if (unlikely(in_interrupt())) |
788 | panic("Aiee, killing interrupt handler!"); | 790 | panic("Aiee, killing interrupt handler!"); |
789 | if (unlikely(!tsk->pid)) | 791 | if (unlikely(!tsk->pid)) |
diff --git a/kernel/fork.c b/kernel/fork.c index 2c7806873bfd..cdef6cea8900 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1090,6 +1090,11 @@ static task_t *copy_process(unsigned long clone_flags, | |||
1090 | spin_unlock(¤t->sighand->siglock); | 1090 | spin_unlock(¤t->sighand->siglock); |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | /* | ||
1094 | * inherit ioprio | ||
1095 | */ | ||
1096 | p->ioprio = current->ioprio; | ||
1097 | |||
1093 | SET_LINKS(p); | 1098 | SET_LINKS(p); |
1094 | if (unlikely(p->ptrace & PT_PTRACED)) | 1099 | if (unlikely(p->ptrace & PT_PTRACED)) |
1095 | __ptrace_link(p, current->parent); | 1100 | __ptrace_link(p, current->parent); |
diff --git a/kernel/sched.c b/kernel/sched.c index a07cff90d849..e2b0d3e4dd06 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -3448,15 +3448,7 @@ int task_nice(const task_t *p) | |||
3448 | { | 3448 | { |
3449 | return TASK_NICE(p); | 3449 | return TASK_NICE(p); |
3450 | } | 3450 | } |
3451 | |||
3452 | /* | ||
3453 | * The only users of task_nice are binfmt_elf and binfmt_elf32. | ||
3454 | * binfmt_elf is no longer modular, but binfmt_elf32 still is. | ||
3455 | * Therefore, task_nice is needed if there is a compat_mode. | ||
3456 | */ | ||
3457 | #ifdef CONFIG_COMPAT | ||
3458 | EXPORT_SYMBOL_GPL(task_nice); | 3451 | EXPORT_SYMBOL_GPL(task_nice); |
3459 | #endif | ||
3460 | 3452 | ||
3461 | /** | 3453 | /** |
3462 | * idle_cpu - is a given cpu idle currently? | 3454 | * idle_cpu - is a given cpu idle currently? |
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig index 3b1fafc8f4f5..7bd95ceab7cc 100644 --- a/sound/oss/Kconfig +++ b/sound/oss/Kconfig | |||
@@ -52,7 +52,7 @@ config SOUND_CMPCI_MIDI | |||
52 | 52 | ||
53 | config SOUND_CMPCI_JOYSTICK | 53 | config SOUND_CMPCI_JOYSTICK |
54 | bool "Enable joystick" | 54 | bool "Enable joystick" |
55 | depends on SOUND_CMPCI && X86 | 55 | depends on SOUND_CMPCI && X86 && (GAMEPORT=y || SOUND_CMPCI=GAMEPORT) |
56 | help | 56 | help |
57 | Say Y here in order to enable the joystick port on a sound card using | 57 | Say Y here in order to enable the joystick port on a sound card using |
58 | the CMI8338 or the CMI8738 chipset. You need to config the | 58 | the CMI8338 or the CMI8738 chipset. You need to config the |
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c index 886f61c1c34a..8538085086e7 100644 --- a/sound/oss/es1370.c +++ b/sound/oss/es1370.c | |||
@@ -162,6 +162,10 @@ | |||
162 | #include <asm/page.h> | 162 | #include <asm/page.h> |
163 | #include <asm/uaccess.h> | 163 | #include <asm/uaccess.h> |
164 | 164 | ||
165 | #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) | ||
166 | #define SUPPORT_JOYSTICK | ||
167 | #endif | ||
168 | |||
165 | /* --------------------------------------------------------------------- */ | 169 | /* --------------------------------------------------------------------- */ |
166 | 170 | ||
167 | #undef OSS_DOCUMENTED_MIXER_SEMANTICS | 171 | #undef OSS_DOCUMENTED_MIXER_SEMANTICS |
@@ -385,7 +389,10 @@ struct es1370_state { | |||
385 | unsigned char obuf[MIDIOUTBUF]; | 389 | unsigned char obuf[MIDIOUTBUF]; |
386 | } midi; | 390 | } midi; |
387 | 391 | ||
392 | #ifdef SUPPORT_JOYSTICK | ||
388 | struct gameport *gameport; | 393 | struct gameport *gameport; |
394 | #endif | ||
395 | |||
389 | struct semaphore sem; | 396 | struct semaphore sem; |
390 | }; | 397 | }; |
391 | 398 | ||
@@ -2554,10 +2561,55 @@ static struct initvol { | |||
2554 | { SOUND_MIXER_WRITE_OGAIN, 0x4040 } | 2561 | { SOUND_MIXER_WRITE_OGAIN, 0x4040 } |
2555 | }; | 2562 | }; |
2556 | 2563 | ||
2564 | #ifdef SUPPORT_JOYSTICK | ||
2565 | |||
2566 | static int __devinit es1370_register_gameport(struct es1370_state *s) | ||
2567 | { | ||
2568 | struct gameport *gp; | ||
2569 | |||
2570 | if (!request_region(0x200, JOY_EXTENT, "es1370")) { | ||
2571 | printk(KERN_ERR "es1370: joystick io port 0x200 in use\n"); | ||
2572 | return -EBUSY; | ||
2573 | } | ||
2574 | |||
2575 | s->gameport = gp = gameport_allocate_port(); | ||
2576 | if (!gp) { | ||
2577 | printk(KERN_ERR "es1370: can not allocate memory for gameport\n"); | ||
2578 | release_region(0x200, JOY_EXTENT); | ||
2579 | return -ENOMEM; | ||
2580 | } | ||
2581 | |||
2582 | gameport_set_name(gp, "ESS1370"); | ||
2583 | gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev)); | ||
2584 | gp->dev.parent = &s->dev->dev; | ||
2585 | gp->io = 0x200; | ||
2586 | |||
2587 | s->ctrl |= CTRL_JYSTK_EN; | ||
2588 | outl(s->ctrl, s->io + ES1370_REG_CONTROL); | ||
2589 | |||
2590 | gameport_register_port(gp); | ||
2591 | |||
2592 | return 0; | ||
2593 | } | ||
2594 | |||
2595 | static inline void es1370_unregister_gameport(struct es1370_state *s) | ||
2596 | { | ||
2597 | if (s->gameport) { | ||
2598 | int gpio = s->gameport->io; | ||
2599 | gameport_unregister_port(s->gameport); | ||
2600 | release_region(gpio, JOY_EXTENT); | ||
2601 | |||
2602 | } | ||
2603 | } | ||
2604 | |||
2605 | #else | ||
2606 | static inline int es1370_register_gameport(struct es1370_state *s) { return -ENOSYS; } | ||
2607 | static inline void es1370_unregister_gameport(struct es1370_state *s) { } | ||
2608 | #endif /* SUPPORT_JOYSTICK */ | ||
2609 | |||
2557 | static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) | 2610 | static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) |
2558 | { | 2611 | { |
2559 | struct es1370_state *s; | 2612 | struct es1370_state *s; |
2560 | struct gameport *gp = NULL; | ||
2561 | mm_segment_t fs; | 2613 | mm_segment_t fs; |
2562 | int i, val, ret; | 2614 | int i, val, ret; |
2563 | 2615 | ||
@@ -2606,28 +2658,14 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2606 | /* note: setting CTRL_SERR_DIS is reported to break | 2658 | /* note: setting CTRL_SERR_DIS is reported to break |
2607 | * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */ | 2659 | * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */ |
2608 | s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL); | 2660 | s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL); |
2609 | if (!request_region(0x200, JOY_EXTENT, "es1370")) { | ||
2610 | printk(KERN_ERR "es1370: joystick io port 0x200 in use\n"); | ||
2611 | } else if (!(s->gameport = gp = gameport_allocate_port())) { | ||
2612 | printk(KERN_ERR "es1370: can not allocate memory for gameport\n"); | ||
2613 | release_region(0x200, JOY_EXTENT); | ||
2614 | } else { | ||
2615 | gameport_set_name(gp, "ESS1370"); | ||
2616 | gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev)); | ||
2617 | gp->dev.parent = &s->dev->dev; | ||
2618 | gp->io = 0x200; | ||
2619 | s->ctrl |= CTRL_JYSTK_EN; | ||
2620 | } | ||
2621 | if (lineout[devindex]) | 2661 | if (lineout[devindex]) |
2622 | s->ctrl |= CTRL_XCTL0; | 2662 | s->ctrl |= CTRL_XCTL0; |
2623 | if (micbias[devindex]) | 2663 | if (micbias[devindex]) |
2624 | s->ctrl |= CTRL_XCTL1; | 2664 | s->ctrl |= CTRL_XCTL1; |
2625 | s->sctrl = 0; | 2665 | s->sctrl = 0; |
2626 | printk(KERN_INFO "es1370: found adapter at io %#lx irq %u\n" | 2666 | printk(KERN_INFO "es1370: adapter at io %#lx irq %u, line %s, mic impedance %s\n", |
2627 | KERN_INFO "es1370: features: joystick %s, line %s, mic impedance %s\n", | 2667 | s->io, s->irq, (s->ctrl & CTRL_XCTL0) ? "out" : "in", |
2628 | s->io, s->irq, (s->ctrl & CTRL_JYSTK_EN) ? "on" : "off", | 2668 | (s->ctrl & CTRL_XCTL1) ? "1" : "0"); |
2629 | (s->ctrl & CTRL_XCTL0) ? "out" : "in", | ||
2630 | (s->ctrl & CTRL_XCTL1) ? "1" : "0"); | ||
2631 | /* register devices */ | 2669 | /* register devices */ |
2632 | if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) { | 2670 | if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) { |
2633 | ret = s->dev_audio; | 2671 | ret = s->dev_audio; |
@@ -2673,9 +2711,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2673 | } | 2711 | } |
2674 | set_fs(fs); | 2712 | set_fs(fs); |
2675 | 2713 | ||
2676 | /* register gameport */ | 2714 | es1370_register_gameport(s); |
2677 | if (gp) | ||
2678 | gameport_register_port(gp); | ||
2679 | 2715 | ||
2680 | /* store it in the driver field */ | 2716 | /* store it in the driver field */ |
2681 | pci_set_drvdata(pcidev, s); | 2717 | pci_set_drvdata(pcidev, s); |
@@ -2697,10 +2733,6 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2697 | err_dev1: | 2733 | err_dev1: |
2698 | printk(KERN_ERR "es1370: cannot register misc device\n"); | 2734 | printk(KERN_ERR "es1370: cannot register misc device\n"); |
2699 | free_irq(s->irq, s); | 2735 | free_irq(s->irq, s); |
2700 | if (s->gameport) { | ||
2701 | release_region(s->gameport->io, JOY_EXTENT); | ||
2702 | gameport_free_port(s->gameport); | ||
2703 | } | ||
2704 | err_irq: | 2736 | err_irq: |
2705 | release_region(s->io, ES1370_EXTENT); | 2737 | release_region(s->io, ES1370_EXTENT); |
2706 | err_region: | 2738 | err_region: |
@@ -2719,11 +2751,7 @@ static void __devexit es1370_remove(struct pci_dev *dev) | |||
2719 | outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */ | 2751 | outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */ |
2720 | synchronize_irq(s->irq); | 2752 | synchronize_irq(s->irq); |
2721 | free_irq(s->irq, s); | 2753 | free_irq(s->irq, s); |
2722 | if (s->gameport) { | 2754 | es1370_unregister_gameport(s); |
2723 | int gpio = s->gameport->io; | ||
2724 | gameport_unregister_port(s->gameport); | ||
2725 | release_region(gpio, JOY_EXTENT); | ||
2726 | } | ||
2727 | release_region(s->io, ES1370_EXTENT); | 2755 | release_region(s->io, ES1370_EXTENT); |
2728 | unregister_sound_dsp(s->dev_audio); | 2756 | unregister_sound_dsp(s->dev_audio); |
2729 | unregister_sound_mixer(s->dev_mixer); | 2757 | unregister_sound_mixer(s->dev_mixer); |
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c index 9266b777387b..12a56d5ab498 100644 --- a/sound/oss/es1371.c +++ b/sound/oss/es1371.c | |||
@@ -134,6 +134,10 @@ | |||
134 | #include <asm/page.h> | 134 | #include <asm/page.h> |
135 | #include <asm/uaccess.h> | 135 | #include <asm/uaccess.h> |
136 | 136 | ||
137 | #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) | ||
138 | #define SUPPORT_JOYSTICK | ||
139 | #endif | ||
140 | |||
137 | /* --------------------------------------------------------------------- */ | 141 | /* --------------------------------------------------------------------- */ |
138 | 142 | ||
139 | #undef OSS_DOCUMENTED_MIXER_SEMANTICS | 143 | #undef OSS_DOCUMENTED_MIXER_SEMANTICS |
@@ -454,7 +458,10 @@ struct es1371_state { | |||
454 | unsigned char obuf[MIDIOUTBUF]; | 458 | unsigned char obuf[MIDIOUTBUF]; |
455 | } midi; | 459 | } midi; |
456 | 460 | ||
461 | #ifdef SUPPORT_JOYSTICK | ||
457 | struct gameport *gameport; | 462 | struct gameport *gameport; |
463 | #endif | ||
464 | |||
458 | struct semaphore sem; | 465 | struct semaphore sem; |
459 | }; | 466 | }; |
460 | 467 | ||
@@ -2787,12 +2794,63 @@ static struct | |||
2787 | { PCI_ANY_ID, PCI_ANY_ID } | 2794 | { PCI_ANY_ID, PCI_ANY_ID } |
2788 | }; | 2795 | }; |
2789 | 2796 | ||
2797 | #ifdef SUPPORT_JOYSTICK | ||
2798 | |||
2799 | static int __devinit es1371_register_gameport(struct es1371_state *s) | ||
2800 | { | ||
2801 | struct gameport *gp; | ||
2802 | int gpio; | ||
2803 | |||
2804 | for (gpio = 0x218; gpio >= 0x200; gpio -= 0x08) | ||
2805 | if (request_region(gpio, JOY_EXTENT, "es1371")) | ||
2806 | break; | ||
2807 | |||
2808 | if (gpio < 0x200) { | ||
2809 | printk(KERN_ERR PFX "no free joystick address found\n"); | ||
2810 | return -EBUSY; | ||
2811 | } | ||
2812 | |||
2813 | s->gameport = gp = gameport_allocate_port(); | ||
2814 | if (!gp) { | ||
2815 | printk(KERN_ERR PFX "can not allocate memory for gameport\n"); | ||
2816 | release_region(gpio, JOY_EXTENT); | ||
2817 | return -ENOMEM; | ||
2818 | } | ||
2819 | |||
2820 | gameport_set_name(gp, "ESS1371 Gameport"); | ||
2821 | gameport_set_phys(gp, "isa%04x/gameport0", gpio); | ||
2822 | gp->dev.parent = &s->dev->dev; | ||
2823 | gp->io = gpio; | ||
2824 | |||
2825 | s->ctrl |= CTRL_JYSTK_EN | (((gpio >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT); | ||
2826 | outl(s->ctrl, s->io + ES1371_REG_CONTROL); | ||
2827 | |||
2828 | gameport_register_port(gp); | ||
2829 | |||
2830 | return 0; | ||
2831 | } | ||
2832 | |||
2833 | static inline void es1371_unregister_gameport(struct es1371_state *s) | ||
2834 | { | ||
2835 | if (s->gameport) { | ||
2836 | int gpio = s->gameport->io; | ||
2837 | gameport_unregister_port(s->gameport); | ||
2838 | release_region(gpio, JOY_EXTENT); | ||
2839 | |||
2840 | } | ||
2841 | } | ||
2842 | |||
2843 | #else | ||
2844 | static inline int es1371_register_gameport(struct es1371_state *s) { return -ENOSYS; } | ||
2845 | static inline void es1371_unregister_gameport(struct es1371_state *s) { } | ||
2846 | #endif /* SUPPORT_JOYSTICK */ | ||
2847 | |||
2848 | |||
2790 | static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) | 2849 | static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) |
2791 | { | 2850 | { |
2792 | struct es1371_state *s; | 2851 | struct es1371_state *s; |
2793 | struct gameport *gp; | ||
2794 | mm_segment_t fs; | 2852 | mm_segment_t fs; |
2795 | int i, gpio, val, res = -1; | 2853 | int i, val, res = -1; |
2796 | int idx; | 2854 | int idx; |
2797 | unsigned long tmo; | 2855 | unsigned long tmo; |
2798 | signed long tmo2; | 2856 | signed long tmo2; |
@@ -2883,23 +2941,6 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2883 | } | 2941 | } |
2884 | } | 2942 | } |
2885 | 2943 | ||
2886 | for (gpio = 0x218; gpio >= 0x200; gpio -= 0x08) | ||
2887 | if (request_region(gpio, JOY_EXTENT, "es1371")) | ||
2888 | break; | ||
2889 | |||
2890 | if (gpio < 0x200) { | ||
2891 | printk(KERN_ERR PFX "no free joystick address found\n"); | ||
2892 | } else if (!(s->gameport = gp = gameport_allocate_port())) { | ||
2893 | printk(KERN_ERR PFX "can not allocate memory for gameport\n"); | ||
2894 | release_region(gpio, JOY_EXTENT); | ||
2895 | } else { | ||
2896 | gameport_set_name(gp, "ESS1371 Gameport"); | ||
2897 | gameport_set_phys(gp, "isa%04x/gameport0", gpio); | ||
2898 | gp->dev.parent = &s->dev->dev; | ||
2899 | gp->io = gpio; | ||
2900 | s->ctrl |= CTRL_JYSTK_EN | (((gpio >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT); | ||
2901 | } | ||
2902 | |||
2903 | s->sctrl = 0; | 2944 | s->sctrl = 0; |
2904 | cssr = 0; | 2945 | cssr = 0; |
2905 | s->spdif_volume = -1; | 2946 | s->spdif_volume = -1; |
@@ -2969,9 +3010,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2969 | /* turn on S/PDIF output driver if requested */ | 3010 | /* turn on S/PDIF output driver if requested */ |
2970 | outl(cssr, s->io+ES1371_REG_STATUS); | 3011 | outl(cssr, s->io+ES1371_REG_STATUS); |
2971 | 3012 | ||
2972 | /* register gameport */ | 3013 | es1371_register_gameport(s); |
2973 | if (s->gameport) | ||
2974 | gameport_register_port(s->gameport); | ||
2975 | 3014 | ||
2976 | /* store it in the driver field */ | 3015 | /* store it in the driver field */ |
2977 | pci_set_drvdata(pcidev, s); | 3016 | pci_set_drvdata(pcidev, s); |
@@ -2980,13 +3019,9 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2980 | /* increment devindex */ | 3019 | /* increment devindex */ |
2981 | if (devindex < NR_DEVICE-1) | 3020 | if (devindex < NR_DEVICE-1) |
2982 | devindex++; | 3021 | devindex++; |
2983 | return 0; | 3022 | return 0; |
2984 | 3023 | ||
2985 | err_gp: | 3024 | err_gp: |
2986 | if (s->gameport) { | ||
2987 | release_region(s->gameport->io, JOY_EXTENT); | ||
2988 | gameport_free_port(s->gameport); | ||
2989 | } | ||
2990 | #ifdef ES1371_DEBUG | 3025 | #ifdef ES1371_DEBUG |
2991 | if (s->ps) | 3026 | if (s->ps) |
2992 | remove_proc_entry("es1371", NULL); | 3027 | remove_proc_entry("es1371", NULL); |
@@ -3025,11 +3060,7 @@ static void __devexit es1371_remove(struct pci_dev *dev) | |||
3025 | outl(0, s->io+ES1371_REG_SERIAL_CONTROL); /* clear serial interrupts */ | 3060 | outl(0, s->io+ES1371_REG_SERIAL_CONTROL); /* clear serial interrupts */ |
3026 | synchronize_irq(s->irq); | 3061 | synchronize_irq(s->irq); |
3027 | free_irq(s->irq, s); | 3062 | free_irq(s->irq, s); |
3028 | if (s->gameport) { | 3063 | es1371_unregister_gameport(s); |
3029 | int gpio = s->gameport->io; | ||
3030 | gameport_unregister_port(s->gameport); | ||
3031 | release_region(gpio, JOY_EXTENT); | ||
3032 | } | ||
3033 | release_region(s->io, ES1371_EXTENT); | 3064 | release_region(s->io, ES1371_EXTENT); |
3034 | unregister_sound_dsp(s->dev_audio); | 3065 | unregister_sound_dsp(s->dev_audio); |
3035 | unregister_sound_mixer(s->codec->dev_mixer); | 3066 | unregister_sound_mixer(s->codec->dev_mixer); |
diff --git a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c index fb09065d07c8..a4ecab2f0522 100644 --- a/sound/oss/esssolo1.c +++ b/sound/oss/esssolo1.c | |||
@@ -150,6 +150,10 @@ | |||
150 | 150 | ||
151 | #define FMODE_DMFM 0x10 | 151 | #define FMODE_DMFM 0x10 |
152 | 152 | ||
153 | #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) | ||
154 | #define SUPPORT_JOYSTICK 1 | ||
155 | #endif | ||
156 | |||
153 | static struct pci_driver solo1_driver; | 157 | static struct pci_driver solo1_driver; |
154 | 158 | ||
155 | /* --------------------------------------------------------------------- */ | 159 | /* --------------------------------------------------------------------- */ |
@@ -227,7 +231,9 @@ struct solo1_state { | |||
227 | unsigned char obuf[MIDIOUTBUF]; | 231 | unsigned char obuf[MIDIOUTBUF]; |
228 | } midi; | 232 | } midi; |
229 | 233 | ||
234 | #if SUPPORT_JOYSTICK | ||
230 | struct gameport *gameport; | 235 | struct gameport *gameport; |
236 | #endif | ||
231 | }; | 237 | }; |
232 | 238 | ||
233 | /* --------------------------------------------------------------------- */ | 239 | /* --------------------------------------------------------------------- */ |
@@ -2281,6 +2287,7 @@ solo1_resume(struct pci_dev *pci_dev) { | |||
2281 | return 0; | 2287 | return 0; |
2282 | } | 2288 | } |
2283 | 2289 | ||
2290 | #ifdef SUPPORT_JOYSTICK | ||
2284 | static int __devinit solo1_register_gameport(struct solo1_state *s, int io_port) | 2291 | static int __devinit solo1_register_gameport(struct solo1_state *s, int io_port) |
2285 | { | 2292 | { |
2286 | struct gameport *gp; | 2293 | struct gameport *gp; |
@@ -2307,6 +2314,19 @@ static int __devinit solo1_register_gameport(struct solo1_state *s, int io_port) | |||
2307 | return 0; | 2314 | return 0; |
2308 | } | 2315 | } |
2309 | 2316 | ||
2317 | static inline void solo1_unregister_gameport(struct solo1_state *s) | ||
2318 | { | ||
2319 | if (s->gameport) { | ||
2320 | int gpio = s->gameport->io; | ||
2321 | gameport_unregister_port(s->gameport); | ||
2322 | release_region(gpio, GAMEPORT_EXTENT); | ||
2323 | } | ||
2324 | } | ||
2325 | #else | ||
2326 | static inline int solo1_register_gameport(struct solo1_state *s, int io_port) { return -ENOSYS; } | ||
2327 | static inline void solo1_unregister_gameport(struct solo1_state *s) { } | ||
2328 | #endif /* SUPPORT_JOYSTICK */ | ||
2329 | |||
2310 | static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) | 2330 | static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) |
2311 | { | 2331 | { |
2312 | struct solo1_state *s; | 2332 | struct solo1_state *s; |
@@ -2438,11 +2458,7 @@ static void __devexit solo1_remove(struct pci_dev *dev) | |||
2438 | synchronize_irq(s->irq); | 2458 | synchronize_irq(s->irq); |
2439 | pci_write_config_word(s->dev, 0x60, 0); /* turn off DDMA controller address space */ | 2459 | pci_write_config_word(s->dev, 0x60, 0); /* turn off DDMA controller address space */ |
2440 | free_irq(s->irq, s); | 2460 | free_irq(s->irq, s); |
2441 | if (s->gameport) { | 2461 | solo1_unregister_gameport(s); |
2442 | int gpio = s->gameport->io; | ||
2443 | gameport_unregister_port(s->gameport); | ||
2444 | release_region(gpio, GAMEPORT_EXTENT); | ||
2445 | } | ||
2446 | release_region(s->iobase, IOBASE_EXTENT); | 2462 | release_region(s->iobase, IOBASE_EXTENT); |
2447 | release_region(s->sbbase+FMSYNTH_EXTENT, SBBASE_EXTENT-FMSYNTH_EXTENT); | 2463 | release_region(s->sbbase+FMSYNTH_EXTENT, SBBASE_EXTENT-FMSYNTH_EXTENT); |
2448 | release_region(s->ddmabase, DDMABASE_EXTENT); | 2464 | release_region(s->ddmabase, DDMABASE_EXTENT); |
diff --git a/sound/oss/mad16.c b/sound/oss/mad16.c index a7067f169919..aa3c50db66c4 100644 --- a/sound/oss/mad16.c +++ b/sound/oss/mad16.c | |||
@@ -50,9 +50,12 @@ | |||
50 | #include "sb.h" | 50 | #include "sb.h" |
51 | #include "mpu401.h" | 51 | #include "mpu401.h" |
52 | 52 | ||
53 | #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) | ||
54 | #define SUPPORT_JOYSTICK 1 | ||
55 | #endif | ||
56 | |||
53 | static int mad16_conf; | 57 | static int mad16_conf; |
54 | static int mad16_cdsel; | 58 | static int mad16_cdsel; |
55 | static struct gameport *gameport; | ||
56 | static DEFINE_SPINLOCK(lock); | 59 | static DEFINE_SPINLOCK(lock); |
57 | 60 | ||
58 | #define C928 1 | 61 | #define C928 1 |
@@ -902,6 +905,10 @@ static int __initdata irq_map[16] = | |||
902 | -1, -1, -1, -1 | 905 | -1, -1, -1, -1 |
903 | }; | 906 | }; |
904 | 907 | ||
908 | #ifdef SUPPORT_JOYSTICK | ||
909 | |||
910 | static struct gameport *gameport; | ||
911 | |||
905 | static int __devinit mad16_register_gameport(int io_port) | 912 | static int __devinit mad16_register_gameport(int io_port) |
906 | { | 913 | { |
907 | if (!request_region(io_port, 1, "mad16 gameport")) { | 914 | if (!request_region(io_port, 1, "mad16 gameport")) { |
@@ -925,6 +932,20 @@ static int __devinit mad16_register_gameport(int io_port) | |||
925 | return 0; | 932 | return 0; |
926 | } | 933 | } |
927 | 934 | ||
935 | static inline void mad16_unregister_gameport(void) | ||
936 | { | ||
937 | if (gameport) { | ||
938 | /* the gameport was initialized so we must free it up */ | ||
939 | gameport_unregister_port(gameport); | ||
940 | gameport = NULL; | ||
941 | release_region(0x201, 1); | ||
942 | } | ||
943 | } | ||
944 | #else | ||
945 | static inline int mad16_register_gameport(int io_port) { return -ENOSYS; } | ||
946 | static inline void mad16_unregister_gameport(void) { } | ||
947 | #endif | ||
948 | |||
928 | static int __devinit init_mad16(void) | 949 | static int __devinit init_mad16(void) |
929 | { | 950 | { |
930 | int dmatype = 0; | 951 | int dmatype = 0; |
@@ -1060,12 +1081,7 @@ static void __exit cleanup_mad16(void) | |||
1060 | { | 1081 | { |
1061 | if (found_mpu) | 1082 | if (found_mpu) |
1062 | unload_mad16_mpu(&cfg_mpu); | 1083 | unload_mad16_mpu(&cfg_mpu); |
1063 | if (gameport) { | 1084 | mad16_unregister_gameport(); |
1064 | /* the gameport was initialized so we must free it up */ | ||
1065 | gameport_unregister_port(gameport); | ||
1066 | gameport = NULL; | ||
1067 | release_region(0x201, 1); | ||
1068 | } | ||
1069 | unload_mad16(&cfg); | 1085 | unload_mad16(&cfg); |
1070 | release_region(MC0_PORT, 12); | 1086 | release_region(MC0_PORT, 12); |
1071 | } | 1087 | } |
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c index 06047e7979af..17d0e461f8d8 100644 --- a/sound/oss/sonicvibes.c +++ b/sound/oss/sonicvibes.c | |||
@@ -122,6 +122,9 @@ | |||
122 | 122 | ||
123 | #include "dm.h" | 123 | #include "dm.h" |
124 | 124 | ||
125 | #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) | ||
126 | #define SUPPORT_JOYSTICK 1 | ||
127 | #endif | ||
125 | 128 | ||
126 | /* --------------------------------------------------------------------- */ | 129 | /* --------------------------------------------------------------------- */ |
127 | 130 | ||
@@ -365,7 +368,9 @@ struct sv_state { | |||
365 | unsigned char obuf[MIDIOUTBUF]; | 368 | unsigned char obuf[MIDIOUTBUF]; |
366 | } midi; | 369 | } midi; |
367 | 370 | ||
371 | #if SUPPORT_JOYSTICK | ||
368 | struct gameport *gameport; | 372 | struct gameport *gameport; |
373 | #endif | ||
369 | }; | 374 | }; |
370 | 375 | ||
371 | /* --------------------------------------------------------------------- */ | 376 | /* --------------------------------------------------------------------- */ |
@@ -2485,6 +2490,7 @@ static struct initvol { | |||
2485 | #define RSRCISIOREGION(dev,num) (pci_resource_start((dev), (num)) != 0 && \ | 2490 | #define RSRCISIOREGION(dev,num) (pci_resource_start((dev), (num)) != 0 && \ |
2486 | (pci_resource_flags((dev), (num)) & IORESOURCE_IO)) | 2491 | (pci_resource_flags((dev), (num)) & IORESOURCE_IO)) |
2487 | 2492 | ||
2493 | #ifdef SUPPORT_JOYSTICK | ||
2488 | static int __devinit sv_register_gameport(struct sv_state *s, int io_port) | 2494 | static int __devinit sv_register_gameport(struct sv_state *s, int io_port) |
2489 | { | 2495 | { |
2490 | struct gameport *gp; | 2496 | struct gameport *gp; |
@@ -2511,6 +2517,19 @@ static int __devinit sv_register_gameport(struct sv_state *s, int io_port) | |||
2511 | return 0; | 2517 | return 0; |
2512 | } | 2518 | } |
2513 | 2519 | ||
2520 | static inline void sv_unregister_gameport(struct sv_state *s) | ||
2521 | { | ||
2522 | if (s->gameport) { | ||
2523 | int gpio = s->gameport->io; | ||
2524 | gameport_unregister_port(s->gameport); | ||
2525 | release_region(gpio, SV_EXTENT_GAME); | ||
2526 | } | ||
2527 | } | ||
2528 | #else | ||
2529 | static inline int sv_register_gameport(struct sv_state *s, int io_port) { return -ENOSYS; } | ||
2530 | static inline void sv_unregister_gameport(struct sv_state *s) { } | ||
2531 | #endif /* SUPPORT_JOYSTICK */ | ||
2532 | |||
2514 | static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) | 2533 | static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) |
2515 | { | 2534 | { |
2516 | static char __devinitdata sv_ddma_name[] = "S3 Inc. SonicVibes DDMA Controller"; | 2535 | static char __devinitdata sv_ddma_name[] = "S3 Inc. SonicVibes DDMA Controller"; |
@@ -2711,11 +2730,7 @@ static void __devexit sv_remove(struct pci_dev *dev) | |||
2711 | /*outb(0, s->iodmaa + SV_DMA_RESET);*/ | 2730 | /*outb(0, s->iodmaa + SV_DMA_RESET);*/ |
2712 | /*outb(0, s->iodmac + SV_DMA_RESET);*/ | 2731 | /*outb(0, s->iodmac + SV_DMA_RESET);*/ |
2713 | free_irq(s->irq, s); | 2732 | free_irq(s->irq, s); |
2714 | if (s->gameport) { | 2733 | sv_unregister_gameport(s); |
2715 | int gpio = s->gameport->io; | ||
2716 | gameport_unregister_port(s->gameport); | ||
2717 | release_region(gpio, SV_EXTENT_GAME); | ||
2718 | } | ||
2719 | release_region(s->iodmac, SV_EXTENT_DMA); | 2734 | release_region(s->iodmac, SV_EXTENT_DMA); |
2720 | release_region(s->iodmaa, SV_EXTENT_DMA); | 2735 | release_region(s->iodmaa, SV_EXTENT_DMA); |
2721 | release_region(s->ioenh, SV_EXTENT_ENH); | 2736 | release_region(s->ioenh, SV_EXTENT_ENH); |
diff --git a/sound/oss/trident.c b/sound/oss/trident.c index 47537f0a5b05..5f0ad6bb43b9 100644 --- a/sound/oss/trident.c +++ b/sound/oss/trident.c | |||
@@ -228,6 +228,10 @@ | |||
228 | 228 | ||
229 | #define DRIVER_VERSION "0.14.10j-2.6" | 229 | #define DRIVER_VERSION "0.14.10j-2.6" |
230 | 230 | ||
231 | #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) | ||
232 | #define SUPPORT_JOYSTICK 1 | ||
233 | #endif | ||
234 | |||
231 | /* magic numbers to protect our data structures */ | 235 | /* magic numbers to protect our data structures */ |
232 | #define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */ | 236 | #define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */ |
233 | #define TRIDENT_STATE_MAGIC 0x63657373 /* "cess" */ | 237 | #define TRIDENT_STATE_MAGIC 0x63657373 /* "cess" */ |
@@ -4252,24 +4256,25 @@ trident_ac97_init(struct trident_card *card) | |||
4252 | return num_ac97 + 1; | 4256 | return num_ac97 + 1; |
4253 | } | 4257 | } |
4254 | 4258 | ||
4259 | #ifdef SUPPORT_JOYSTICK | ||
4255 | /* Gameport functions for the cards ADC gameport */ | 4260 | /* Gameport functions for the cards ADC gameport */ |
4256 | 4261 | ||
4257 | static unsigned char | 4262 | static unsigned char trident_game_read(struct gameport *gameport) |
4258 | trident_game_read(struct gameport *gameport) | ||
4259 | { | 4263 | { |
4260 | struct trident_card *card = gameport->port_data; | 4264 | struct trident_card *card = gameport->port_data; |
4265 | |||
4261 | return inb(TRID_REG(card, T4D_GAME_LEG)); | 4266 | return inb(TRID_REG(card, T4D_GAME_LEG)); |
4262 | } | 4267 | } |
4263 | 4268 | ||
4264 | static void | 4269 | static void trident_game_trigger(struct gameport *gameport) |
4265 | trident_game_trigger(struct gameport *gameport) | ||
4266 | { | 4270 | { |
4267 | struct trident_card *card = gameport->port_data; | 4271 | struct trident_card *card = gameport->port_data; |
4272 | |||
4268 | outb(0xff, TRID_REG(card, T4D_GAME_LEG)); | 4273 | outb(0xff, TRID_REG(card, T4D_GAME_LEG)); |
4269 | } | 4274 | } |
4270 | 4275 | ||
4271 | static int | 4276 | static int trident_game_cooked_read(struct gameport *gameport, |
4272 | trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons) | 4277 | int *axes, int *buttons) |
4273 | { | 4278 | { |
4274 | struct trident_card *card = gameport->port_data; | 4279 | struct trident_card *card = gameport->port_data; |
4275 | int i; | 4280 | int i; |
@@ -4285,8 +4290,7 @@ trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons) | |||
4285 | return 0; | 4290 | return 0; |
4286 | } | 4291 | } |
4287 | 4292 | ||
4288 | static int | 4293 | static int trident_game_open(struct gameport *gameport, int mode) |
4289 | trident_game_open(struct gameport *gameport, int mode) | ||
4290 | { | 4294 | { |
4291 | struct trident_card *card = gameport->port_data; | 4295 | struct trident_card *card = gameport->port_data; |
4292 | 4296 | ||
@@ -4305,8 +4309,7 @@ trident_game_open(struct gameport *gameport, int mode) | |||
4305 | return 0; | 4309 | return 0; |
4306 | } | 4310 | } |
4307 | 4311 | ||
4308 | static int __devinit | 4312 | static int __devinit trident_register_gameport(struct trident_card *card) |
4309 | trident_register_gameport(struct trident_card *card) | ||
4310 | { | 4313 | { |
4311 | struct gameport *gp; | 4314 | struct gameport *gp; |
4312 | 4315 | ||
@@ -4330,6 +4333,17 @@ trident_register_gameport(struct trident_card *card) | |||
4330 | return 0; | 4333 | return 0; |
4331 | } | 4334 | } |
4332 | 4335 | ||
4336 | static inline void trident_unregister_gameport(struct trident_card *card) | ||
4337 | { | ||
4338 | if (card->gameport) | ||
4339 | gameport_unregister_port(card->gameport); | ||
4340 | } | ||
4341 | |||
4342 | #else | ||
4343 | static inline int trident_register_gameport(struct trident_card *card) { return -ENOSYS; } | ||
4344 | static inline void trident_unregister_gameport(struct trident_card *card) { } | ||
4345 | #endif /* SUPPORT_JOYSTICK */ | ||
4346 | |||
4333 | /* install the driver, we do not allocate hardware channel nor DMA buffer */ | 4347 | /* install the driver, we do not allocate hardware channel nor DMA buffer */ |
4334 | /* now, they are defered until "ACCESS" time (in prog_dmabuf called by */ | 4348 | /* now, they are defered until "ACCESS" time (in prog_dmabuf called by */ |
4335 | /* open/read/write/ioctl/mmap) */ | 4349 | /* open/read/write/ioctl/mmap) */ |
@@ -4569,8 +4583,7 @@ trident_remove(struct pci_dev *pci_dev) | |||
4569 | } | 4583 | } |
4570 | 4584 | ||
4571 | /* Unregister gameport */ | 4585 | /* Unregister gameport */ |
4572 | if (card->gameport) | 4586 | trident_unregister_gameport(card); |
4573 | gameport_unregister_port(card->gameport); | ||
4574 | 4587 | ||
4575 | /* Kill interrupts, and SP/DIF */ | 4588 | /* Kill interrupts, and SP/DIF */ |
4576 | trident_disable_loop_interrupts(card); | 4589 | trident_disable_loop_interrupts(card); |
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index b6e1854e9389..eb3c52b03af3 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c | |||
@@ -1338,11 +1338,6 @@ static inline int snd_cs4281_create_gameport(cs4281_t *chip) { return -ENOSYS; } | |||
1338 | static inline void snd_cs4281_free_gameport(cs4281_t *chip) { } | 1338 | static inline void snd_cs4281_free_gameport(cs4281_t *chip) { } |
1339 | #endif /* CONFIG_GAMEPORT || (MODULE && CONFIG_GAMEPORT_MODULE) */ | 1339 | #endif /* CONFIG_GAMEPORT || (MODULE && CONFIG_GAMEPORT_MODULE) */ |
1340 | 1340 | ||
1341 | |||
1342 | /* | ||
1343 | |||
1344 | */ | ||
1345 | |||
1346 | static int snd_cs4281_free(cs4281_t *chip) | 1341 | static int snd_cs4281_free(cs4281_t *chip) |
1347 | { | 1342 | { |
1348 | snd_cs4281_free_gameport(chip); | 1343 | snd_cs4281_free_gameport(chip); |