diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-05-16 05:49:15 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2008-10-14 17:50:48 -0400 |
commit | 85cdaf524b7ddab627e7d15405693f2511ef7505 (patch) | |
tree | a85fb7c801df07842301c27dc57cf2eb5092f6ed /drivers/hid/usbhid | |
parent | e8c84f9a5f06912c94c38961096c994da3890a2e (diff) |
HID: make a bus from hid code
Make a bus from hid core. This is the first step for converting all the
quirks and separate almost-drivers into real drivers attached to this bus.
It's implemented to change behaviour in very tiny manner, so that no driver
needs to be changed this time.
Also add generic drivers for both usb and bt into usbhid or hidp
respectively which will bind all non-blacklisted device. Those blacklisted
will be either grabbed by special drivers or by nobody if they are broken at
the very rude base.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 44 | ||||
-rw-r--r-- | drivers/hid/usbhid/usbhid.h | 2 |
2 files changed, 36 insertions, 10 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 27fe4d8912cb..5955d05ae542 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -770,8 +770,15 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
770 | dbg_hid_line(" %02x", (unsigned char) rdesc[n]); | 770 | dbg_hid_line(" %02x", (unsigned char) rdesc[n]); |
771 | dbg_hid_line("\n"); | 771 | dbg_hid_line("\n"); |
772 | 772 | ||
773 | if (!(hid = hid_parse_report(rdesc, n))) { | 773 | hid = hid_allocate_device(); |
774 | if (IS_ERR(hid)) { | ||
775 | kfree(rdesc); | ||
776 | return NULL; | ||
777 | } | ||
778 | |||
779 | if (hid_parse_report(hid, rdesc, n)) { | ||
774 | dbg_hid("parsing report descriptor failed\n"); | 780 | dbg_hid("parsing report descriptor failed\n"); |
781 | hid_destroy_device(hid); | ||
775 | kfree(rdesc); | 782 | kfree(rdesc); |
776 | return NULL; | 783 | return NULL; |
777 | } | 784 | } |
@@ -798,10 +805,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
798 | if (insize > HID_MAX_BUFFER_SIZE) | 805 | if (insize > HID_MAX_BUFFER_SIZE) |
799 | insize = HID_MAX_BUFFER_SIZE; | 806 | insize = HID_MAX_BUFFER_SIZE; |
800 | 807 | ||
801 | if (hid_alloc_buffers(dev, hid)) { | 808 | if (hid_alloc_buffers(dev, hid)) |
802 | hid_free_buffers(dev, hid); | ||
803 | goto fail; | 809 | goto fail; |
804 | } | ||
805 | 810 | ||
806 | hid->name[0] = 0; | 811 | hid->name[0] = 0; |
807 | 812 | ||
@@ -881,7 +886,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
881 | 886 | ||
882 | hid->version = le16_to_cpu(hdesc->bcdHID); | 887 | hid->version = le16_to_cpu(hdesc->bcdHID); |
883 | hid->country = hdesc->bCountryCode; | 888 | hid->country = hdesc->bCountryCode; |
884 | hid->dev = &intf->dev; | 889 | hid->dev.parent = &intf->dev; |
885 | usbhid->intf = intf; | 890 | usbhid->intf = intf; |
886 | usbhid->ifnum = interface->desc.bInterfaceNumber; | 891 | usbhid->ifnum = interface->desc.bInterfaceNumber; |
887 | 892 | ||
@@ -925,7 +930,7 @@ fail: | |||
925 | hid_free_buffers(dev, hid); | 930 | hid_free_buffers(dev, hid); |
926 | kfree(usbhid); | 931 | kfree(usbhid); |
927 | fail_no_usbhid: | 932 | fail_no_usbhid: |
928 | hid_free_device(hid); | 933 | hid_destroy_device(hid); |
929 | 934 | ||
930 | return NULL; | 935 | return NULL; |
931 | } | 936 | } |
@@ -964,14 +969,14 @@ static void hid_disconnect(struct usb_interface *intf) | |||
964 | 969 | ||
965 | hid_free_buffers(hid_to_usb_dev(hid), hid); | 970 | hid_free_buffers(hid_to_usb_dev(hid), hid); |
966 | kfree(usbhid); | 971 | kfree(usbhid); |
967 | hid_free_device(hid); | 972 | hid_destroy_device(hid); |
968 | } | 973 | } |
969 | 974 | ||
970 | static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | 975 | static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) |
971 | { | 976 | { |
972 | struct hid_device *hid; | 977 | struct hid_device *hid; |
973 | char path[64]; | 978 | char path[64]; |
974 | int i; | 979 | int i, ret; |
975 | char *c; | 980 | char *c; |
976 | 981 | ||
977 | dbg_hid("HID probe called for ifnum %d\n", | 982 | dbg_hid("HID probe called for ifnum %d\n", |
@@ -1037,7 +1042,12 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1037 | printk(": USB HID v%x.%02x %s [%s] on %s\n", | 1042 | printk(": USB HID v%x.%02x %s [%s] on %s\n", |
1038 | hid->version >> 8, hid->version & 0xff, c, hid->name, path); | 1043 | hid->version >> 8, hid->version & 0xff, c, hid->name, path); |
1039 | 1044 | ||
1040 | return 0; | 1045 | ret = hid_add_device(hid); |
1046 | if (ret) { | ||
1047 | dev_err(&intf->dev, "can't add hid device: %d\n", ret); | ||
1048 | hid_disconnect(intf); | ||
1049 | } | ||
1050 | return ret; | ||
1041 | } | 1051 | } |
1042 | 1052 | ||
1043 | static int hid_suspend(struct usb_interface *intf, pm_message_t message) | 1053 | static int hid_suspend(struct usb_interface *intf, pm_message_t message) |
@@ -1107,9 +1117,22 @@ static struct usb_driver hid_driver = { | |||
1107 | .supports_autosuspend = 1, | 1117 | .supports_autosuspend = 1, |
1108 | }; | 1118 | }; |
1109 | 1119 | ||
1120 | static const struct hid_device_id hid_usb_table[] = { | ||
1121 | { HID_USB_DEVICE(HID_ANY_ID, HID_ANY_ID) }, | ||
1122 | { } | ||
1123 | }; | ||
1124 | |||
1125 | static struct hid_driver hid_usb_driver = { | ||
1126 | .name = "generic-usb", | ||
1127 | .id_table = hid_usb_table, | ||
1128 | }; | ||
1129 | |||
1110 | static int __init hid_init(void) | 1130 | static int __init hid_init(void) |
1111 | { | 1131 | { |
1112 | int retval; | 1132 | int retval; |
1133 | retval = hid_register_driver(&hid_usb_driver); | ||
1134 | if (retval) | ||
1135 | goto hid_register_fail; | ||
1113 | retval = usbhid_quirks_init(quirks_param); | 1136 | retval = usbhid_quirks_init(quirks_param); |
1114 | if (retval) | 1137 | if (retval) |
1115 | goto usbhid_quirks_init_fail; | 1138 | goto usbhid_quirks_init_fail; |
@@ -1127,6 +1150,8 @@ usb_register_fail: | |||
1127 | hiddev_init_fail: | 1150 | hiddev_init_fail: |
1128 | usbhid_quirks_exit(); | 1151 | usbhid_quirks_exit(); |
1129 | usbhid_quirks_init_fail: | 1152 | usbhid_quirks_init_fail: |
1153 | hid_unregister_driver(&hid_usb_driver); | ||
1154 | hid_register_fail: | ||
1130 | return retval; | 1155 | return retval; |
1131 | } | 1156 | } |
1132 | 1157 | ||
@@ -1135,6 +1160,7 @@ static void __exit hid_exit(void) | |||
1135 | usb_deregister(&hid_driver); | 1160 | usb_deregister(&hid_driver); |
1136 | hiddev_exit(); | 1161 | hiddev_exit(); |
1137 | usbhid_quirks_exit(); | 1162 | usbhid_quirks_exit(); |
1163 | hid_unregister_driver(&hid_usb_driver); | ||
1138 | } | 1164 | } |
1139 | 1165 | ||
1140 | module_init(hid_init); | 1166 | module_init(hid_init); |
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h index 62d2d7c925bd..b47f991867e9 100644 --- a/drivers/hid/usbhid/usbhid.h +++ b/drivers/hid/usbhid/usbhid.h | |||
@@ -82,7 +82,7 @@ struct usbhid_device { | |||
82 | }; | 82 | }; |
83 | 83 | ||
84 | #define hid_to_usb_dev(hid_dev) \ | 84 | #define hid_to_usb_dev(hid_dev) \ |
85 | container_of(hid_dev->dev->parent, struct usb_device, dev) | 85 | container_of(hid_dev->dev.parent->parent, struct usb_device, dev) |
86 | 86 | ||
87 | #endif | 87 | #endif |
88 | 88 | ||