~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/input/mouse/vsxxxaa.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 
87
87
#define DRIVER_DESC "Driver for DEC VSXXX-AA and -GA mice and VSXXX-AB tablet"
88
88
 
89
 
MODULE_AUTHOR ("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
90
 
MODULE_DESCRIPTION (DRIVER_DESC);
91
 
MODULE_LICENSE ("GPL");
 
89
MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
 
90
MODULE_DESCRIPTION(DRIVER_DESC);
 
91
MODULE_LICENSE("GPL");
92
92
 
93
93
#undef VSXXXAA_DEBUG
94
94
#ifdef VSXXXAA_DEBUG
95
 
#define DBG(x...) printk (x)
 
95
#define DBG(x...) printk(x)
96
96
#else
97
97
#define DBG(x...) do {} while (0)
98
98
#endif
99
99
 
100
100
#define VSXXXAA_INTRO_MASK      0x80
101
101
#define VSXXXAA_INTRO_HEAD      0x80
102
 
#define IS_HDR_BYTE(x)          (((x) & VSXXXAA_INTRO_MASK)     \
103
 
                                        == VSXXXAA_INTRO_HEAD)
 
102
#define IS_HDR_BYTE(x)                  \
 
103
        (((x) & VSXXXAA_INTRO_MASK) == VSXXXAA_INTRO_HEAD)
104
104
 
105
105
#define VSXXXAA_PACKET_MASK     0xe0
106
106
#define VSXXXAA_PACKET_REL      0x80
107
107
#define VSXXXAA_PACKET_ABS      0xc0
108
108
#define VSXXXAA_PACKET_POR      0xa0
109
 
#define MATCH_PACKET_TYPE(data, type)   (((data) & VSXXXAA_PACKET_MASK) == (type))
 
109
#define MATCH_PACKET_TYPE(data, type)   \
 
110
        (((data) & VSXXXAA_PACKET_MASK) == (type))
110
111
 
111
112
 
112
113
 
123
124
        char phys[32];
124
125
};
125
126
 
126
 
static void
127
 
vsxxxaa_drop_bytes (struct vsxxxaa *mouse, int num)
 
127
static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num)
128
128
{
129
 
        if (num >= mouse->count)
 
129
        if (num >= mouse->count) {
130
130
                mouse->count = 0;
131
 
        else {
132
 
                memmove (mouse->buf, mouse->buf + num - 1, BUFLEN - num);
 
131
        } else {
 
132
                memmove(mouse->buf, mouse->buf + num - 1, BUFLEN - num);
133
133
                mouse->count -= num;
134
134
        }
135
135
}
136
136
 
137
 
static void
138
 
vsxxxaa_queue_byte (struct vsxxxaa *mouse, unsigned char byte)
 
137
static void vsxxxaa_queue_byte(struct vsxxxaa *mouse, unsigned char byte)
139
138
{
140
139
        if (mouse->count == BUFLEN) {
141
 
                printk (KERN_ERR "%s on %s: Dropping a byte of full buffer.\n",
142
 
                                mouse->name, mouse->phys);
143
 
                vsxxxaa_drop_bytes (mouse, 1);
 
140
                printk(KERN_ERR "%s on %s: Dropping a byte of full buffer.\n",
 
141
                        mouse->name, mouse->phys);
 
142
                vsxxxaa_drop_bytes(mouse, 1);
144
143
        }
145
 
        DBG (KERN_INFO "Queueing byte 0x%02x\n", byte);
 
144
 
 
145
        DBG(KERN_INFO "Queueing byte 0x%02x\n", byte);
146
146
 
147
147
        mouse->buf[mouse->count++] = byte;
148
148
}
149
149
 
150
 
static void
151
 
vsxxxaa_detection_done (struct vsxxxaa *mouse)
 
150
static void vsxxxaa_detection_done(struct vsxxxaa *mouse)
152
151
{
153
152
        switch (mouse->type) {
154
 
                case 0x02:
155
 
                        strlcpy (mouse->name, "DEC VSXXX-AA/-GA mouse",
156
 
                                 sizeof (mouse->name));
157
 
                        break;
158
 
 
159
 
                case 0x04:
160
 
                        strlcpy (mouse->name, "DEC VSXXX-AB digitizer",
161
 
                                 sizeof (mouse->name));
162
 
                        break;
163
 
 
164
 
                default:
165
 
                        snprintf (mouse->name, sizeof (mouse->name),
166
 
                                  "unknown DEC pointer device (type = 0x%02x)",
167
 
                                  mouse->type);
168
 
                        break;
 
153
        case 0x02:
 
154
                strlcpy(mouse->name, "DEC VSXXX-AA/-GA mouse",
 
155
                        sizeof(mouse->name));
 
156
                break;
 
157
 
 
158
        case 0x04:
 
159
                strlcpy(mouse->name, "DEC VSXXX-AB digitizer",
 
160
                        sizeof(mouse->name));
 
161
                break;
 
162
 
 
163
        default:
 
164
                snprintf(mouse->name, sizeof(mouse->name),
 
165
                         "unknown DEC pointer device (type = 0x%02x)",
 
166
                         mouse->type);
 
167
                break;
169
168
        }
170
169
 
171
 
        printk (KERN_INFO
 
170
        printk(KERN_INFO
172
171
                "Found %s version 0x%02x from country 0x%02x on port %s\n",
173
172
                mouse->name, mouse->version, mouse->country, mouse->phys);
174
173
}
176
175
/*
177
176
 * Returns number of bytes to be dropped, 0 if packet is okay.
178
177
 */
179
 
static int
180
 
vsxxxaa_check_packet (struct vsxxxaa *mouse, int packet_len)
 
178
static int vsxxxaa_check_packet(struct vsxxxaa *mouse, int packet_len)
181
179
{
182
180
        int i;
183
181
 
184
182
        /* First byte must be a header byte */
185
 
        if (!IS_HDR_BYTE (mouse->buf[0])) {
186
 
                DBG ("vsck: len=%d, 1st=0x%02x\n", packet_len, mouse->buf[0]);
 
183
        if (!IS_HDR_BYTE(mouse->buf[0])) {
 
184
                DBG("vsck: len=%d, 1st=0x%02x\n", packet_len, mouse->buf[0]);
187
185
                return 1;
188
186
        }
189
187
 
190
188
        /* Check all following bytes */
191
 
        if (packet_len > 1) {
192
 
                for (i = 1; i < packet_len; i++) {
193
 
                        if (IS_HDR_BYTE (mouse->buf[i])) {
194
 
                                printk (KERN_ERR "Need to drop %d bytes "
195
 
                                                "of a broken packet.\n",
196
 
                                                i - 1);
197
 
                                DBG (KERN_INFO "check: len=%d, b[%d]=0x%02x\n",
198
 
                                                packet_len, i, mouse->buf[i]);
199
 
                                return i - 1;
200
 
                        }
 
189
        for (i = 1; i < packet_len; i++) {
 
190
                if (IS_HDR_BYTE(mouse->buf[i])) {
 
191
                        printk(KERN_ERR
 
192
                                "Need to drop %d bytes of a broken packet.\n",
 
193
                                i - 1);
 
194
                        DBG(KERN_INFO "check: len=%d, b[%d]=0x%02x\n",
 
195
                            packet_len, i, mouse->buf[i]);
 
196
                        return i - 1;
201
197
                }
202
198
        }
203
199
 
204
200
        return 0;
205
201
}
206
202
 
207
 
static __inline__ int
208
 
vsxxxaa_smells_like_packet (struct vsxxxaa *mouse, unsigned char type, size_t len)
 
203
static inline int vsxxxaa_smells_like_packet(struct vsxxxaa *mouse,
 
204
                                             unsigned char type, size_t len)
209
205
{
210
 
        return (mouse->count >= len) && MATCH_PACKET_TYPE (mouse->buf[0], type);
 
206
        return mouse->count >= len && MATCH_PACKET_TYPE(mouse->buf[0], type);
211
207
}
212
208
 
213
 
static void
214
 
vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse)
 
209
static void vsxxxaa_handle_REL_packet(struct vsxxxaa *mouse)
215
210
{
216
211
        struct input_dev *dev = mouse->dev;
217
212
        unsigned char *buf = mouse->buf;
232
227
         * 0, bit 4 of byte 0 is direction.
233
228
         */
234
229
        dx = buf[1] & 0x7f;
235
 
        dx *= ((buf[0] >> 4) & 0x01)? 1: -1;
 
230
        dx *= ((buf[0] >> 4) & 0x01) ? 1 : -1;
236
231
 
237
232
        /*
238
233
         * Low 7 bit of byte 2 are abs(dy), bit 7 is
239
234
         * 0, bit 3 of byte 0 is direction.
240
235
         */
241
236
        dy = buf[2] & 0x7f;
242
 
        dy *= ((buf[0] >> 3) & 0x01)? -1: 1;
 
237
        dy *= ((buf[0] >> 3) & 0x01) ? -1 : 1;
243
238
 
244
239
        /*
245
240
         * Get button state. It's the low three bits
246
241
         * (for three buttons) of byte 0.
247
242
         */
248
 
        left    = (buf[0] & 0x04)? 1: 0;
249
 
        middle  = (buf[0] & 0x02)? 1: 0;
250
 
        right   = (buf[0] & 0x01)? 1: 0;
251
 
 
252
 
        vsxxxaa_drop_bytes (mouse, 3);
253
 
 
254
 
        DBG (KERN_INFO "%s on %s: dx=%d, dy=%d, buttons=%s%s%s\n",
255
 
                        mouse->name, mouse->phys, dx, dy,
256
 
                        left? "L": "l", middle? "M": "m", right? "R": "r");
 
243
        left    = buf[0] & 0x04;
 
244
        middle  = buf[0] & 0x02;
 
245
        right   = buf[0] & 0x01;
 
246
 
 
247
        vsxxxaa_drop_bytes(mouse, 3);
 
248
 
 
249
        DBG(KERN_INFO "%s on %s: dx=%d, dy=%d, buttons=%s%s%s\n",
 
250
            mouse->name, mouse->phys, dx, dy,
 
251
            left ? "L" : "l", middle ? "M" : "m", right ? "R" : "r");
257
252
 
258
253
        /*
259
254
         * Report what we've found so far...
260
255
         */
261
 
        input_report_key (dev, BTN_LEFT, left);
262
 
        input_report_key (dev, BTN_MIDDLE, middle);
263
 
        input_report_key (dev, BTN_RIGHT, right);
264
 
        input_report_key (dev, BTN_TOUCH, 0);
265
 
        input_report_rel (dev, REL_X, dx);
266
 
        input_report_rel (dev, REL_Y, dy);
267
 
        input_sync (dev);
 
256
        input_report_key(dev, BTN_LEFT, left);
 
257
        input_report_key(dev, BTN_MIDDLE, middle);
 
258
        input_report_key(dev, BTN_RIGHT, right);
 
259
        input_report_key(dev, BTN_TOUCH, 0);
 
260
        input_report_rel(dev, REL_X, dx);
 
261
        input_report_rel(dev, REL_Y, dy);
 
262
        input_sync(dev);
268
263
}
269
264
 
270
 
static void
271
 
vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse)
 
265
static void vsxxxaa_handle_ABS_packet(struct vsxxxaa *mouse)
272
266
{
273
267
        struct input_dev *dev = mouse->dev;
274
268
        unsigned char *buf = mouse->buf;
296
290
        /*
297
291
         * Get button state. It's bits <4..1> of byte 0.
298
292
         */
299
 
        left    = (buf[0] & 0x02)? 1: 0;
300
 
        middle  = (buf[0] & 0x04)? 1: 0;
301
 
        right   = (buf[0] & 0x08)? 1: 0;
302
 
        touch   = (buf[0] & 0x10)? 1: 0;
303
 
 
304
 
        vsxxxaa_drop_bytes (mouse, 5);
305
 
 
306
 
        DBG (KERN_INFO "%s on %s: x=%d, y=%d, buttons=%s%s%s%s\n",
307
 
                        mouse->name, mouse->phys, x, y,
308
 
                        left? "L": "l", middle? "M": "m",
309
 
                        right? "R": "r", touch? "T": "t");
 
293
        left    = buf[0] & 0x02;
 
294
        middle  = buf[0] & 0x04;
 
295
        right   = buf[0] & 0x08;
 
296
        touch   = buf[0] & 0x10;
 
297
 
 
298
        vsxxxaa_drop_bytes(mouse, 5);
 
299
 
 
300
        DBG(KERN_INFO "%s on %s: x=%d, y=%d, buttons=%s%s%s%s\n",
 
301
            mouse->name, mouse->phys, x, y,
 
302
            left ? "L" : "l", middle ? "M" : "m",
 
303
            right ? "R" : "r", touch ? "T" : "t");
310
304
 
311
305
        /*
312
306
         * Report what we've found so far...
313
307
         */
314
 
        input_report_key (dev, BTN_LEFT, left);
315
 
        input_report_key (dev, BTN_MIDDLE, middle);
316
 
        input_report_key (dev, BTN_RIGHT, right);
317
 
        input_report_key (dev, BTN_TOUCH, touch);
318
 
        input_report_abs (dev, ABS_X, x);
319
 
        input_report_abs (dev, ABS_Y, y);
320
 
        input_sync (dev);
 
308
        input_report_key(dev, BTN_LEFT, left);
 
309
        input_report_key(dev, BTN_MIDDLE, middle);
 
310
        input_report_key(dev, BTN_RIGHT, right);
 
311
        input_report_key(dev, BTN_TOUCH, touch);
 
312
        input_report_abs(dev, ABS_X, x);
 
313
        input_report_abs(dev, ABS_Y, y);
 
314
        input_sync(dev);
321
315
}
322
316
 
323
 
static void
324
 
vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
 
317
static void vsxxxaa_handle_POR_packet(struct vsxxxaa *mouse)
325
318
{
326
319
        struct input_dev *dev = mouse->dev;
327
320
        unsigned char *buf = mouse->buf;
356
349
         * (for three buttons) of byte 0. Maybe even the bit <3>
357
350
         * has some meaning if a tablet is attached.
358
351
         */
359
 
        left    = (buf[0] & 0x04)? 1: 0;
360
 
        middle  = (buf[0] & 0x02)? 1: 0;
361
 
        right   = (buf[0] & 0x01)? 1: 0;
 
352
        left    = buf[0] & 0x04;
 
353
        middle  = buf[0] & 0x02;
 
354
        right   = buf[0] & 0x01;
362
355
 
363
 
        vsxxxaa_drop_bytes (mouse, 4);
364
 
        vsxxxaa_detection_done (mouse);
 
356
        vsxxxaa_drop_bytes(mouse, 4);
 
357
        vsxxxaa_detection_done(mouse);
365
358
 
366
359
        if (error <= 0x1f) {
367
360
                /* No (serious) error. Report buttons */
368
 
                input_report_key (dev, BTN_LEFT, left);
369
 
                input_report_key (dev, BTN_MIDDLE, middle);
370
 
                input_report_key (dev, BTN_RIGHT, right);
371
 
                input_report_key (dev, BTN_TOUCH, 0);
372
 
                input_sync (dev);
 
361
                input_report_key(dev, BTN_LEFT, left);
 
362
                input_report_key(dev, BTN_MIDDLE, middle);
 
363
                input_report_key(dev, BTN_RIGHT, right);
 
364
                input_report_key(dev, BTN_TOUCH, 0);
 
365
                input_sync(dev);
373
366
 
374
367
                if (error != 0)
375
 
                        printk (KERN_INFO "Your %s on %s reports error=0x%02x\n",
376
 
                                        mouse->name, mouse->phys, error);
 
368
                        printk(KERN_INFO "Your %s on %s reports error=0x%02x\n",
 
369
                                mouse->name, mouse->phys, error);
377
370
 
378
371
        }
379
372
 
381
374
         * If the mouse was hot-plugged, we need to force differential mode
382
375
         * now... However, give it a second to recover from it's reset.
383
376
         */
384
 
        printk (KERN_NOTICE "%s on %s: Forceing standard packet format, "
385
 
                        "incremental streaming mode and 72 samples/sec\n",
386
 
                        mouse->name, mouse->phys);
387
 
        serio_write (mouse->serio, 'S');        /* Standard format */
388
 
        mdelay (50);
389
 
        serio_write (mouse->serio, 'R');        /* Incremental */
390
 
        mdelay (50);
391
 
        serio_write (mouse->serio, 'L');        /* 72 samples/sec */
 
377
        printk(KERN_NOTICE
 
378
                "%s on %s: Forcing standard packet format, "
 
379
                "incremental streaming mode and 72 samples/sec\n",
 
380
                mouse->name, mouse->phys);
 
381
        serio_write(mouse->serio, 'S'); /* Standard format */
 
382
        mdelay(50);
 
383
        serio_write(mouse->serio, 'R'); /* Incremental */
 
384
        mdelay(50);
 
385
        serio_write(mouse->serio, 'L'); /* 72 samples/sec */
392
386
}
393
387
 
394
 
static void
395
 
vsxxxaa_parse_buffer (struct vsxxxaa *mouse)
 
388
static void vsxxxaa_parse_buffer(struct vsxxxaa *mouse)
396
389
{
397
390
        unsigned char *buf = mouse->buf;
398
391
        int stray_bytes;
409
402
                 * activity on the mouse.
410
403
                 */
411
404
                while (mouse->count > 0 && !IS_HDR_BYTE(buf[0])) {
412
 
                        printk (KERN_ERR "%s on %s: Dropping a byte to regain "
413
 
                                        "sync with mouse data stream...\n",
414
 
                                        mouse->name, mouse->phys);
415
 
                        vsxxxaa_drop_bytes (mouse, 1);
 
405
                        printk(KERN_ERR "%s on %s: Dropping a byte to regain "
 
406
                                "sync with mouse data stream...\n",
 
407
                                mouse->name, mouse->phys);
 
408
                        vsxxxaa_drop_bytes(mouse, 1);
416
409
                }
417
410
 
418
411
                /*
419
412
                 * Check for packets we know about.
420
413
                 */
421
414
 
422
 
                if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_REL, 3)) {
423
 
                        /* Check for broken packet */
424
 
                        stray_bytes = vsxxxaa_check_packet (mouse, 3);
425
 
                        if (stray_bytes > 0) {
426
 
                                printk (KERN_ERR "Dropping %d bytes now...\n",
427
 
                                                stray_bytes);
428
 
                                vsxxxaa_drop_bytes (mouse, stray_bytes);
429
 
                                continue;
430
 
                        }
431
 
 
432
 
                        vsxxxaa_handle_REL_packet (mouse);
433
 
                        continue; /* More to parse? */
434
 
                }
435
 
 
436
 
                if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_ABS, 5)) {
437
 
                        /* Check for broken packet */
438
 
                        stray_bytes = vsxxxaa_check_packet (mouse, 5);
439
 
                        if (stray_bytes > 0) {
440
 
                                printk (KERN_ERR "Dropping %d bytes now...\n",
441
 
                                                stray_bytes);
442
 
                                vsxxxaa_drop_bytes (mouse, stray_bytes);
443
 
                                continue;
444
 
                        }
445
 
 
446
 
                        vsxxxaa_handle_ABS_packet (mouse);
447
 
                        continue; /* More to parse? */
448
 
                }
449
 
 
450
 
                if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_POR, 4)) {
451
 
                        /* Check for broken packet */
452
 
                        stray_bytes = vsxxxaa_check_packet (mouse, 4);
453
 
                        if (stray_bytes > 0) {
454
 
                                printk (KERN_ERR "Dropping %d bytes now...\n",
455
 
                                                stray_bytes);
456
 
                                vsxxxaa_drop_bytes (mouse, stray_bytes);
457
 
                                continue;
458
 
                        }
459
 
 
460
 
                        vsxxxaa_handle_POR_packet (mouse);
461
 
                        continue; /* More to parse? */
462
 
                }
463
 
 
464
 
                break; /* No REL, ABS or POR packet found */
 
415
                if (vsxxxaa_smells_like_packet(mouse, VSXXXAA_PACKET_REL, 3)) {
 
416
                        /* Check for broken packet */
 
417
                        stray_bytes = vsxxxaa_check_packet(mouse, 3);
 
418
                        if (!stray_bytes)
 
419
                                vsxxxaa_handle_REL_packet(mouse);
 
420
 
 
421
                } else if (vsxxxaa_smells_like_packet(mouse,
 
422
                                                      VSXXXAA_PACKET_ABS, 5)) {
 
423
                        /* Check for broken packet */
 
424
                        stray_bytes = vsxxxaa_check_packet(mouse, 5);
 
425
                        if (!stray_bytes)
 
426
                                vsxxxaa_handle_ABS_packet(mouse);
 
427
 
 
428
                } else if (vsxxxaa_smells_like_packet(mouse,
 
429
                                                      VSXXXAA_PACKET_POR, 4)) {
 
430
                        /* Check for broken packet */
 
431
                        stray_bytes = vsxxxaa_check_packet(mouse, 4);
 
432
                        if (!stray_bytes)
 
433
                                vsxxxaa_handle_POR_packet(mouse);
 
434
 
 
435
                } else {
 
436
                        break; /* No REL, ABS or POR packet found */
 
437
                }
 
438
 
 
439
                if (stray_bytes > 0) {
 
440
                        printk(KERN_ERR "Dropping %d bytes now...\n",
 
441
                                stray_bytes);
 
442
                        vsxxxaa_drop_bytes(mouse, stray_bytes);
 
443
                }
 
444
 
465
445
        } while (1);
466
446
}
467
447
 
468
 
static irqreturn_t
469
 
vsxxxaa_interrupt (struct serio *serio, unsigned char data, unsigned int flags)
 
448
static irqreturn_t vsxxxaa_interrupt(struct serio *serio,
 
449
                                     unsigned char data, unsigned int flags)
470
450
{
471
 
        struct vsxxxaa *mouse = serio_get_drvdata (serio);
 
451
        struct vsxxxaa *mouse = serio_get_drvdata(serio);
472
452
 
473
 
        vsxxxaa_queue_byte (mouse, data);
474
 
        vsxxxaa_parse_buffer (mouse);
 
453
        vsxxxaa_queue_byte(mouse, data);
 
454
        vsxxxaa_parse_buffer(mouse);
475
455
 
476
456
        return IRQ_HANDLED;
477
457
}
478
458
 
479
 
static void
480
 
vsxxxaa_disconnect (struct serio *serio)
 
459
static void vsxxxaa_disconnect(struct serio *serio)
481
460
{
482
 
        struct vsxxxaa *mouse = serio_get_drvdata (serio);
 
461
        struct vsxxxaa *mouse = serio_get_drvdata(serio);
483
462
 
484
 
        serio_close (serio);
485
 
        serio_set_drvdata (serio, NULL);
486
 
        input_unregister_device (mouse->dev);
487
 
        kfree (mouse);
 
463
        serio_close(serio);
 
464
        serio_set_drvdata(serio, NULL);
 
465
        input_unregister_device(mouse->dev);
 
466
        kfree(mouse);
488
467
}
489
468
 
490
 
static int
491
 
vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
 
469
static int vsxxxaa_connect(struct serio *serio, struct serio_driver *drv)
492
470
{
493
471
        struct vsxxxaa *mouse;
494
472
        struct input_dev *input_dev;
495
473
        int err = -ENOMEM;
496
474
 
497
 
        mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL);
498
 
        input_dev = input_allocate_device ();
 
475
        mouse = kzalloc(sizeof(struct vsxxxaa), GFP_KERNEL);
 
476
        input_dev = input_allocate_device();
499
477
        if (!mouse || !input_dev)
500
478
                goto fail1;
501
479
 
502
480
        mouse->dev = input_dev;
503
481
        mouse->serio = serio;
504
 
        strlcat (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer",
505
 
                 sizeof (mouse->name));
506
 
        snprintf (mouse->phys, sizeof (mouse->phys), "%s/input0", serio->phys);
 
482
        strlcat(mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer",
 
483
                 sizeof(mouse->name));
 
484
        snprintf(mouse->phys, sizeof(mouse->phys), "%s/input0", serio->phys);
507
485
 
508
486
        input_dev->name = mouse->name;
509
487
        input_dev->phys = mouse->phys;
510
488
        input_dev->id.bustype = BUS_RS232;
511
489
        input_dev->dev.parent = &serio->dev;
512
490
 
513
 
        set_bit (EV_KEY, input_dev->evbit);             /* We have buttons */
514
 
        set_bit (EV_REL, input_dev->evbit);
515
 
        set_bit (EV_ABS, input_dev->evbit);
516
 
        set_bit (BTN_LEFT, input_dev->keybit);          /* We have 3 buttons */
517
 
        set_bit (BTN_MIDDLE, input_dev->keybit);
518
 
        set_bit (BTN_RIGHT, input_dev->keybit);
519
 
        set_bit (BTN_TOUCH, input_dev->keybit);         /* ...and Tablet */
520
 
        set_bit (REL_X, input_dev->relbit);
521
 
        set_bit (REL_Y, input_dev->relbit);
522
 
        input_set_abs_params (input_dev, ABS_X, 0, 1023, 0, 0);
523
 
        input_set_abs_params (input_dev, ABS_Y, 0, 1023, 0, 0);
524
 
 
525
 
        serio_set_drvdata (serio, mouse);
526
 
 
527
 
        err = serio_open (serio, drv);
 
491
        __set_bit(EV_KEY, input_dev->evbit);            /* We have buttons */
 
492
        __set_bit(EV_REL, input_dev->evbit);
 
493
        __set_bit(EV_ABS, input_dev->evbit);
 
494
        __set_bit(BTN_LEFT, input_dev->keybit);         /* We have 3 buttons */
 
495
        __set_bit(BTN_MIDDLE, input_dev->keybit);
 
496
        __set_bit(BTN_RIGHT, input_dev->keybit);
 
497
        __set_bit(BTN_TOUCH, input_dev->keybit);        /* ...and Tablet */
 
498
        __set_bit(REL_X, input_dev->relbit);
 
499
        __set_bit(REL_Y, input_dev->relbit);
 
500
        input_set_abs_params(input_dev, ABS_X, 0, 1023, 0, 0);
 
501
        input_set_abs_params(input_dev, ABS_Y, 0, 1023, 0, 0);
 
502
 
 
503
        serio_set_drvdata(serio, mouse);
 
504
 
 
505
        err = serio_open(serio, drv);
528
506
        if (err)
529
507
                goto fail2;
530
508
 
532
510
         * Request selftest. Standard packet format and differential
533
511
         * mode will be requested after the device ID'ed successfully.
534
512
         */
535
 
        serio_write (serio, 'T'); /* Test */
 
513
        serio_write(serio, 'T'); /* Test */
536
514
 
537
 
        err = input_register_device (input_dev);
 
515
        err = input_register_device(input_dev);
538
516
        if (err)
539
517
                goto fail3;
540
518
 
541
519
        return 0;
542
520
 
543
 
 fail3: serio_close (serio);
544
 
 fail2: serio_set_drvdata (serio, NULL);
545
 
 fail1: input_free_device (input_dev);
546
 
        kfree (mouse);
 
521
 fail3: serio_close(serio);
 
522
 fail2: serio_set_drvdata(serio, NULL);
 
523
 fail1: input_free_device(input_dev);
 
524
        kfree(mouse);
547
525
        return err;
548
526
}
549
527
 
570
548
        .disconnect     = vsxxxaa_disconnect,
571
549
};
572
550
 
573
 
static int __init
574
 
vsxxxaa_init (void)
 
551
static int __init vsxxxaa_init(void)
575
552
{
576
553
        return serio_register_driver(&vsxxxaa_drv);
577
554
}
578
555
 
579
 
static void __exit
580
 
vsxxxaa_exit (void)
 
556
static void __exit vsxxxaa_exit(void)
581
557
{
582
558
        serio_unregister_driver(&vsxxxaa_drv);
583
559
}
584
560
 
585
 
module_init (vsxxxaa_init);
586
 
module_exit (vsxxxaa_exit);
 
561
module_init(vsxxxaa_init);
 
562
module_exit(vsxxxaa_exit);
587
563