aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2006-12-08 12:40:53 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-08 13:43:12 -0500
commit229695e51efc4ed5e04ab471c82591d0f432909d (patch)
tree9e333780589010c61224f185a4a83323305e7d8d /drivers/hid/hid-core.c
parentdde5845a529ff753364a6d1aea61180946270bfa (diff)
[PATCH] Generic HID layer - API
- fixed generic API (added neccessary EXPORT_SYMBOL, fixed hid.h to provide correct prototypes) - extended hid_device with open/close/event function pointers to driver-specific functions - added driver specific driver_data to hid_device Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 689ae16adf33..8474a7923322 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * USB HID support for Linux 2 * HID support for Linux
3 * 3 *
4 * Copyright (c) 1999 Andreas Gal 4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
@@ -31,8 +31,6 @@
31#undef DEBUG 31#undef DEBUG
32#undef DEBUG_DATA 32#undef DEBUG_DATA
33 33
34#include <linux/usb.h>
35
36#include <linux/hid.h> 34#include <linux/hid.h>
37#include <linux/hiddev.h> 35#include <linux/hiddev.h>
38 36
@@ -538,7 +536,7 @@ static void hid_free_report(struct hid_report *report)
538 * Free a device structure, all reports, and all fields. 536 * Free a device structure, all reports, and all fields.
539 */ 537 */
540 538
541static void hid_free_device(struct hid_device *device) 539void hid_free_device(struct hid_device *device)
542{ 540{
543 unsigned i,j; 541 unsigned i,j;
544 542
@@ -555,6 +553,7 @@ static void hid_free_device(struct hid_device *device)
555 kfree(device->rdesc); 553 kfree(device->rdesc);
556 kfree(device); 554 kfree(device);
557} 555}
556EXPORT_SYMBOL_GPL(hid_free_device);
558 557
559/* 558/*
560 * Fetch a report description item from the data stream. We support long 559 * Fetch a report description item from the data stream. We support long
@@ -629,7 +628,7 @@ static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
629 * enumerated, fields are attached to these reports. 628 * enumerated, fields are attached to these reports.
630 */ 629 */
631 630
632static struct hid_device *hid_parse_report(__u8 *start, unsigned size) 631struct hid_device *hid_parse_report(__u8 *start, unsigned size)
633{ 632{
634 struct hid_device *device; 633 struct hid_device *device;
635 struct hid_parser *parser; 634 struct hid_parser *parser;
@@ -719,6 +718,7 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
719 kfree(parser); 718 kfree(parser);
720 return NULL; 719 return NULL;
721} 720}
721EXPORT_SYMBOL_GPL(hid_parse_report);
722 722
723/* 723/*
724 * Convert a signed n-bit integer to signed 32-bit integer. Common 724 * Convert a signed n-bit integer to signed 32-bit integer. Common
@@ -767,10 +767,10 @@ static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
767 WARN_ON(n > 32); 767 WARN_ON(n > 32);
768 768
769 report += offset >> 3; /* adjust byte index */ 769 report += offset >> 3; /* adjust byte index */
770 offset &= 7; /* now only need bit offset into one byte */ 770 offset &= 7; /* now only need bit offset into one byte */
771 x = get_unaligned((u64 *) report); 771 x = get_unaligned((u64 *) report);
772 x = le64_to_cpu(x); 772 x = le64_to_cpu(x);
773 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 773 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
774 return (u32) x; 774 return (u32) x;
775} 775}
776 776
@@ -829,7 +829,7 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s
829 * reporting to the layer). 829 * reporting to the layer).
830 */ 830 */
831 831
832static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt) 832void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt)
833{ 833{
834 unsigned n; 834 unsigned n;
835 unsigned count = field->report_count; 835 unsigned count = field->report_count;
@@ -875,7 +875,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u
875exit: 875exit:
876 kfree(value); 876 kfree(value);
877} 877}
878 878EXPORT_SYMBOL_GPL(hid_input_field);
879 879
880/* 880/*
881 * Output the field into the report. 881 * Output the field into the report.
@@ -900,7 +900,7 @@ static void hid_output_field(struct hid_field *field, __u8 *data)
900 * Create a report. 900 * Create a report.
901 */ 901 */
902 902
903static void hid_output_report(struct hid_report *report, __u8 *data) 903void hid_output_report(struct hid_report *report, __u8 *data)
904{ 904{
905 unsigned n; 905 unsigned n;
906 906
@@ -910,6 +910,7 @@ static void hid_output_report(struct hid_report *report, __u8 *data)
910 for (n = 0; n < report->maxfield; n++) 910 for (n = 0; n < report->maxfield; n++)
911 hid_output_field(report->field[n], data); 911 hid_output_field(report->field[n], data);
912} 912}
913EXPORT_SYMBOL_GPL(hid_output_report);
913 914
914/* 915/*
915 * Set a field value. The report this field belongs to has to be 916 * Set a field value. The report this field belongs to has to be
@@ -937,4 +938,5 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
937 field->value[offset] = value; 938 field->value[offset] = value;
938 return 0; 939 return 0;
939} 940}
941EXPORT_SYMBOL_GPL(hid_set_field);
940 942