diff options
author | Helge Deller <deller@parisc-linux.org> | 2006-03-26 09:41:55 -0500 |
---|---|---|
committer | Kyle McMartin <kyle@hera.kernel.org> | 2006-03-30 12:48:53 -0500 |
commit | 102c8c76f787add0790406d5c47e03cb6f8765c2 (patch) | |
tree | fc61e0f94c48b051bd12590abd085e12d14e8ef1 /drivers/input/mouse | |
parent | 10267cdd0c2dee46a3f59d93fbfac7229d416dba (diff) |
[PARISC] Convert HIL drivers to use input_allocate_device
Convert HIL drivers to use input_allocate_device() - avoids crashes.
Signed-off-by: Helge Deller <deller@parisc-linux.org>
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r-- | drivers/input/mouse/hil_ptr.c | 91 |
1 files changed, 48 insertions, 43 deletions
diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c index c2bf2ed07dc6..a648f9fe3d95 100644 --- a/drivers/input/mouse/hil_ptr.c +++ b/drivers/input/mouse/hil_ptr.c | |||
@@ -55,7 +55,7 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
55 | #define HIL_PTR_MAX_LENGTH 16 | 55 | #define HIL_PTR_MAX_LENGTH 16 |
56 | 56 | ||
57 | struct hil_ptr { | 57 | struct hil_ptr { |
58 | struct input_dev dev; | 58 | struct input_dev *dev; |
59 | struct serio *serio; | 59 | struct serio *serio; |
60 | 60 | ||
61 | /* Input buffer and index for packets from HIL bus. */ | 61 | /* Input buffer and index for packets from HIL bus. */ |
@@ -79,7 +79,7 @@ struct hil_ptr { | |||
79 | /* Process a complete packet after transfer from the HIL */ | 79 | /* Process a complete packet after transfer from the HIL */ |
80 | static void hil_ptr_process_record(struct hil_ptr *ptr) | 80 | static void hil_ptr_process_record(struct hil_ptr *ptr) |
81 | { | 81 | { |
82 | struct input_dev *dev = &ptr->dev; | 82 | struct input_dev *dev = ptr->dev; |
83 | hil_packet *data = ptr->data; | 83 | hil_packet *data = ptr->data; |
84 | hil_packet p; | 84 | hil_packet p; |
85 | int idx, i, cnt, laxis; | 85 | int idx, i, cnt, laxis; |
@@ -148,12 +148,12 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) | |||
148 | if (absdev) { | 148 | if (absdev) { |
149 | val = lo + (hi<<8); | 149 | val = lo + (hi<<8); |
150 | #ifdef TABLET_AUTOADJUST | 150 | #ifdef TABLET_AUTOADJUST |
151 | if (val < ptr->dev.absmin[ABS_X + i]) | 151 | if (val < dev->absmin[ABS_X + i]) |
152 | ptr->dev.absmin[ABS_X + i] = val; | 152 | dev->absmin[ABS_X + i] = val; |
153 | if (val > ptr->dev.absmax[ABS_X + i]) | 153 | if (val > dev->absmax[ABS_X + i]) |
154 | ptr->dev.absmax[ABS_X + i] = val; | 154 | dev->absmax[ABS_X + i] = val; |
155 | #endif | 155 | #endif |
156 | if (i%3) val = ptr->dev.absmax[ABS_X + i] - val; | 156 | if (i%3) val = dev->absmax[ABS_X + i] - val; |
157 | input_report_abs(dev, ABS_X + i, val); | 157 | input_report_abs(dev, ABS_X + i, val); |
158 | } else { | 158 | } else { |
159 | val = (int) (((int8_t)lo) | ((int8_t)hi<<8)); | 159 | val = (int) (((int8_t)lo) | ((int8_t)hi<<8)); |
@@ -233,26 +233,30 @@ static void hil_ptr_disconnect(struct serio *serio) | |||
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | 235 | ||
236 | input_unregister_device(&ptr->dev); | 236 | input_unregister_device(ptr->dev); |
237 | serio_close(serio); | 237 | serio_close(serio); |
238 | input_free_device(ptr->dev); | ||
238 | kfree(ptr); | 239 | kfree(ptr); |
239 | } | 240 | } |
240 | 241 | ||
241 | static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | 242 | static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) |
242 | { | 243 | { |
243 | struct hil_ptr *ptr; | 244 | struct hil_ptr *ptr; |
244 | char *txt; | 245 | char *txt; |
245 | unsigned int i, naxsets, btntype; | 246 | unsigned int i, naxsets, btntype; |
246 | uint8_t did, *idd; | 247 | uint8_t did, *idd; |
247 | 248 | ||
248 | if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return -ENOMEM; | 249 | if (!(ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL))) |
249 | memset(ptr, 0, sizeof(struct hil_ptr)); | 250 | return -ENOMEM; |
250 | 251 | ||
251 | if (serio_open(serio, driver)) goto bail0; | 252 | ptr->dev = input_allocate_device(); |
253 | if (!ptr->dev) goto bail0; | ||
254 | ptr->dev->private = ptr; | ||
255 | |||
256 | if (serio_open(serio, driver)) goto bail1; | ||
252 | 257 | ||
253 | serio_set_drvdata(serio, ptr); | 258 | serio_set_drvdata(serio, ptr); |
254 | ptr->serio = serio; | 259 | ptr->serio = serio; |
255 | ptr->dev.private = ptr; | ||
256 | 260 | ||
257 | init_MUTEX_LOCKED(&(ptr->sem)); | 261 | init_MUTEX_LOCKED(&(ptr->sem)); |
258 | 262 | ||
@@ -283,25 +287,24 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | |||
283 | 287 | ||
284 | up(&(ptr->sem)); | 288 | up(&(ptr->sem)); |
285 | 289 | ||
286 | init_input_dev(&ptr->dev); | ||
287 | did = ptr->idd[0]; | 290 | did = ptr->idd[0]; |
288 | idd = ptr->idd + 1; | 291 | idd = ptr->idd + 1; |
289 | txt = "unknown"; | 292 | txt = "unknown"; |
290 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { | 293 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { |
291 | ptr->dev.evbit[0] = BIT(EV_REL); | 294 | ptr->dev->evbit[0] = BIT(EV_REL); |
292 | txt = "relative"; | 295 | txt = "relative"; |
293 | } | 296 | } |
294 | 297 | ||
295 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) { | 298 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) { |
296 | ptr->dev.evbit[0] = BIT(EV_ABS); | 299 | ptr->dev->evbit[0] = BIT(EV_ABS); |
297 | txt = "absolute"; | 300 | txt = "absolute"; |
298 | } | 301 | } |
299 | if (!ptr->dev.evbit[0]) { | 302 | if (!ptr->dev->evbit[0]) { |
300 | goto bail1; | 303 | goto bail2; |
301 | } | 304 | } |
302 | 305 | ||
303 | ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); | 306 | ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); |
304 | if (ptr->nbtn) ptr->dev.evbit[0] |= BIT(EV_KEY); | 307 | if (ptr->nbtn) ptr->dev->evbit[0] |= BIT(EV_KEY); |
305 | 308 | ||
306 | naxsets = HIL_IDD_NUM_AXSETS(*idd); | 309 | naxsets = HIL_IDD_NUM_AXSETS(*idd); |
307 | ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); | 310 | ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); |
@@ -325,7 +328,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | |||
325 | btntype = BTN_MOUSE; | 328 | btntype = BTN_MOUSE; |
326 | 329 | ||
327 | for (i = 0; i < ptr->nbtn; i++) { | 330 | for (i = 0; i < ptr->nbtn; i++) { |
328 | set_bit(btntype | i, ptr->dev.keybit); | 331 | set_bit(btntype | i, ptr->dev->keybit); |
329 | ptr->btnmap[i] = btntype | i; | 332 | ptr->btnmap[i] = btntype | i; |
330 | } | 333 | } |
331 | 334 | ||
@@ -337,50 +340,52 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | |||
337 | 340 | ||
338 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { | 341 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { |
339 | for (i = 0; i < ptr->naxes; i++) { | 342 | for (i = 0; i < ptr->naxes; i++) { |
340 | set_bit(REL_X + i, ptr->dev.relbit); | 343 | set_bit(REL_X + i, ptr->dev->relbit); |
341 | } | 344 | } |
342 | for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) { | 345 | for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) { |
343 | set_bit(REL_X + i, ptr->dev.relbit); | 346 | set_bit(REL_X + i, ptr->dev->relbit); |
344 | } | 347 | } |
345 | } else { | 348 | } else { |
346 | for (i = 0; i < ptr->naxes; i++) { | 349 | for (i = 0; i < ptr->naxes; i++) { |
347 | set_bit(ABS_X + i, ptr->dev.absbit); | 350 | set_bit(ABS_X + i, ptr->dev->absbit); |
348 | ptr->dev.absmin[ABS_X + i] = 0; | 351 | ptr->dev->absmin[ABS_X + i] = 0; |
349 | ptr->dev.absmax[ABS_X + i] = | 352 | ptr->dev->absmax[ABS_X + i] = |
350 | HIL_IDD_AXIS_MAX((ptr->idd + 1), i); | 353 | HIL_IDD_AXIS_MAX((ptr->idd + 1), i); |
351 | } | 354 | } |
352 | for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) { | 355 | for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) { |
353 | set_bit(ABS_X + i, ptr->dev.absbit); | 356 | set_bit(ABS_X + i, ptr->dev->absbit); |
354 | ptr->dev.absmin[ABS_X + i] = 0; | 357 | ptr->dev->absmin[ABS_X + i] = 0; |
355 | ptr->dev.absmax[ABS_X + i] = | 358 | ptr->dev->absmax[ABS_X + i] = |
356 | HIL_IDD_AXIS_MAX((ptr->idd + 1), (i - 3)); | 359 | HIL_IDD_AXIS_MAX((ptr->idd + 1), (i - 3)); |
357 | } | 360 | } |
358 | #ifdef TABLET_AUTOADJUST | 361 | #ifdef TABLET_AUTOADJUST |
359 | for (i = 0; i < ABS_MAX; i++) { | 362 | for (i = 0; i < ABS_MAX; i++) { |
360 | int diff = ptr->dev.absmax[ABS_X + i] / 10; | 363 | int diff = ptr->dev->absmax[ABS_X + i] / 10; |
361 | ptr->dev.absmin[ABS_X + i] += diff; | 364 | ptr->dev->absmin[ABS_X + i] += diff; |
362 | ptr->dev.absmax[ABS_X + i] -= diff; | 365 | ptr->dev->absmax[ABS_X + i] -= diff; |
363 | } | 366 | } |
364 | #endif | 367 | #endif |
365 | } | 368 | } |
366 | 369 | ||
367 | ptr->dev.name = strlen(ptr->rnm) ? ptr->rnm : HIL_GENERIC_NAME; | 370 | ptr->dev->name = strlen(ptr->rnm) ? ptr->rnm : HIL_GENERIC_NAME; |
368 | 371 | ||
369 | ptr->dev.id.bustype = BUS_HIL; | 372 | ptr->dev->id.bustype = BUS_HIL; |
370 | ptr->dev.id.vendor = PCI_VENDOR_ID_HP; | 373 | ptr->dev->id.vendor = PCI_VENDOR_ID_HP; |
371 | ptr->dev.id.product = 0x0001; /* TODO: get from ptr->rsc */ | 374 | ptr->dev->id.product = 0x0001; /* TODO: get from ptr->rsc */ |
372 | ptr->dev.id.version = 0x0100; /* TODO: get from ptr->rsc */ | 375 | ptr->dev->id.version = 0x0100; /* TODO: get from ptr->rsc */ |
373 | ptr->dev.dev = &serio->dev; | 376 | ptr->dev->dev = &serio->dev; |
374 | 377 | ||
375 | input_register_device(&ptr->dev); | 378 | input_register_device(ptr->dev); |
376 | printk(KERN_INFO "input: %s (%s), ID: %d\n", | 379 | printk(KERN_INFO "input: %s (%s), ID: %d\n", |
377 | ptr->dev.name, | 380 | ptr->dev->name, |
378 | (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", | 381 | (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", |
379 | did); | 382 | did); |
380 | 383 | ||
381 | return 0; | 384 | return 0; |
382 | bail1: | 385 | bail2: |
383 | serio_close(serio); | 386 | serio_close(serio); |
387 | bail1: | ||
388 | input_free_device(ptr->dev); | ||
384 | bail0: | 389 | bail0: |
385 | kfree(ptr); | 390 | kfree(ptr); |
386 | serio_set_drvdata(serio, NULL); | 391 | serio_set_drvdata(serio, NULL); |