diff options
Diffstat (limited to 'drivers/usb/input/hid-input.c')
-rw-r--r-- | drivers/usb/input/hid-input.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 0b6452248a39..9ff25eb520a6 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c | |||
@@ -76,8 +76,8 @@ static struct { | |||
76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
77 | struct hid_usage *usage) | 77 | struct hid_usage *usage) |
78 | { | 78 | { |
79 | struct input_dev *input = &hidinput->input; | 79 | struct input_dev *input = hidinput->input; |
80 | struct hid_device *device = hidinput->input.private; | 80 | struct hid_device *device = input->private; |
81 | int max = 0, code; | 81 | int max = 0, code; |
82 | unsigned long *bit = NULL; | 82 | unsigned long *bit = NULL; |
83 | 83 | ||
@@ -461,7 +461,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
461 | 461 | ||
462 | if (!field->hidinput) | 462 | if (!field->hidinput) |
463 | return; | 463 | return; |
464 | input = &field->hidinput->input; | 464 | |
465 | input = field->hidinput->input; | ||
465 | 466 | ||
466 | input_regs(input, regs); | 467 | input_regs(input, regs); |
467 | 468 | ||
@@ -533,13 +534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
533 | 534 | ||
534 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) | 535 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) |
535 | { | 536 | { |
536 | struct list_head *lh; | ||
537 | struct hid_input *hidinput; | 537 | struct hid_input *hidinput; |
538 | 538 | ||
539 | list_for_each (lh, &hid->inputs) { | 539 | list_for_each_entry(hidinput, &hid->inputs, list) |
540 | hidinput = list_entry(lh, struct hid_input, list); | 540 | input_sync(hidinput->input); |
541 | input_sync(&hidinput->input); | ||
542 | } | ||
543 | } | 541 | } |
544 | 542 | ||
545 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) | 543 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) |
@@ -604,6 +602,7 @@ int hidinput_connect(struct hid_device *hid) | |||
604 | struct usb_device *dev = hid->dev; | 602 | struct usb_device *dev = hid->dev; |
605 | struct hid_report *report; | 603 | struct hid_report *report; |
606 | struct hid_input *hidinput = NULL; | 604 | struct hid_input *hidinput = NULL; |
605 | struct input_dev *input_dev; | ||
607 | int i, j, k; | 606 | int i, j, k; |
608 | 607 | ||
609 | INIT_LIST_HEAD(&hid->inputs); | 608 | INIT_LIST_HEAD(&hid->inputs); |
@@ -624,25 +623,28 @@ int hidinput_connect(struct hid_device *hid) | |||
624 | continue; | 623 | continue; |
625 | 624 | ||
626 | if (!hidinput) { | 625 | if (!hidinput) { |
627 | hidinput = kmalloc(sizeof(*hidinput), GFP_KERNEL); | 626 | hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); |
628 | if (!hidinput) { | 627 | input_dev = input_allocate_device(); |
628 | if (!hidinput || !input_dev) { | ||
629 | kfree(hidinput); | ||
630 | input_free_device(input_dev); | ||
629 | err("Out of memory during hid input probe"); | 631 | err("Out of memory during hid input probe"); |
630 | return -1; | 632 | return -1; |
631 | } | 633 | } |
632 | memset(hidinput, 0, sizeof(*hidinput)); | ||
633 | 634 | ||
634 | list_add_tail(&hidinput->list, &hid->inputs); | 635 | input_dev->private = hid; |
636 | input_dev->event = hidinput_input_event; | ||
637 | input_dev->open = hidinput_open; | ||
638 | input_dev->close = hidinput_close; | ||
635 | 639 | ||
636 | hidinput->input.private = hid; | 640 | input_dev->name = hid->name; |
637 | hidinput->input.event = hidinput_input_event; | 641 | input_dev->phys = hid->phys; |
638 | hidinput->input.open = hidinput_open; | 642 | input_dev->uniq = hid->uniq; |
639 | hidinput->input.close = hidinput_close; | 643 | usb_to_input_id(dev, &input_dev->id); |
644 | input_dev->cdev.dev = &hid->intf->dev; | ||
640 | 645 | ||
641 | hidinput->input.name = hid->name; | 646 | hidinput->input = input_dev; |
642 | hidinput->input.phys = hid->phys; | 647 | list_add_tail(&hidinput->list, &hid->inputs); |
643 | hidinput->input.uniq = hid->uniq; | ||
644 | usb_to_input_id(dev, &hidinput->input.id); | ||
645 | hidinput->input.dev = &hid->intf->dev; | ||
646 | } | 648 | } |
647 | 649 | ||
648 | for (i = 0; i < report->maxfield; i++) | 650 | for (i = 0; i < report->maxfield; i++) |
@@ -657,7 +659,7 @@ int hidinput_connect(struct hid_device *hid) | |||
657 | * UGCI) cram a lot of unrelated inputs into the | 659 | * UGCI) cram a lot of unrelated inputs into the |
658 | * same interface. */ | 660 | * same interface. */ |
659 | hidinput->report = report; | 661 | hidinput->report = report; |
660 | input_register_device(&hidinput->input); | 662 | input_register_device(hidinput->input); |
661 | hidinput = NULL; | 663 | hidinput = NULL; |
662 | } | 664 | } |
663 | } | 665 | } |
@@ -667,7 +669,7 @@ int hidinput_connect(struct hid_device *hid) | |||
667 | * only useful in this case, and not for multi-input quirks. */ | 669 | * only useful in this case, and not for multi-input quirks. */ |
668 | if (hidinput) { | 670 | if (hidinput) { |
669 | hid_ff_init(hid); | 671 | hid_ff_init(hid); |
670 | input_register_device(&hidinput->input); | 672 | input_register_device(hidinput->input); |
671 | } | 673 | } |
672 | 674 | ||
673 | return 0; | 675 | return 0; |
@@ -675,13 +677,11 @@ int hidinput_connect(struct hid_device *hid) | |||
675 | 677 | ||
676 | void hidinput_disconnect(struct hid_device *hid) | 678 | void hidinput_disconnect(struct hid_device *hid) |
677 | { | 679 | { |
678 | struct list_head *lh, *next; | 680 | struct hid_input *hidinput, *next; |
679 | struct hid_input *hidinput; | ||
680 | 681 | ||
681 | list_for_each_safe(lh, next, &hid->inputs) { | 682 | list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { |
682 | hidinput = list_entry(lh, struct hid_input, list); | ||
683 | input_unregister_device(&hidinput->input); | ||
684 | list_del(&hidinput->list); | 683 | list_del(&hidinput->list); |
684 | input_unregister_device(hidinput->input); | ||
685 | kfree(hidinput); | 685 | kfree(hidinput); |
686 | } | 686 | } |
687 | } | 687 | } |