aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c76
1 files changed, 75 insertions, 1 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ea5f8bc900e0..699547ce257f 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1113,6 +1113,80 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
1113} 1113}
1114EXPORT_SYMBOL_GPL(hid_input_report); 1114EXPORT_SYMBOL_GPL(hid_input_report);
1115 1115
1116int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1117{
1118 static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
1119 "Joystick", "Gamepad", "Keyboard", "Keypad",
1120 "Multi-Axis Controller"
1121 };
1122 const char *type, *bus;
1123 char buf[64];
1124 unsigned int i;
1125 int len;
1126
1127 if (hdev->bus != BUS_USB)
1128 connect_mask &= ~HID_CONNECT_HIDDEV;
1129
1130 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev,
1131 connect_mask & HID_CONNECT_HIDINPUT_FORCE))
1132 hdev->claimed |= HID_CLAIMED_INPUT;
1133 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
1134 !hdev->hiddev_connect(hdev,
1135 connect_mask & HID_CONNECT_HIDDEV_FORCE))
1136 hdev->claimed |= HID_CLAIMED_HIDDEV;
1137 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev))
1138 hdev->claimed |= HID_CLAIMED_HIDRAW;
1139
1140 if (!hdev->claimed) {
1141 dev_err(&hdev->dev, "claimed by neither input, hiddev nor "
1142 "hidraw\n");
1143 return -ENODEV;
1144 }
1145
1146 if ((hdev->claimed & HID_CLAIMED_INPUT) &&
1147 (connect_mask & HID_CONNECT_FF) && hdev->ff_init)
1148 hdev->ff_init(hdev);
1149
1150 len = 0;
1151 if (hdev->claimed & HID_CLAIMED_INPUT)
1152 len += sprintf(buf + len, "input");
1153 if (hdev->claimed & HID_CLAIMED_HIDDEV)
1154 len += sprintf(buf + len, "%shiddev%d", len ? "," : "",
1155 hdev->minor);
1156 if (hdev->claimed & HID_CLAIMED_HIDRAW)
1157 len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
1158 ((struct hidraw *)hdev->hidraw)->minor);
1159
1160 type = "Device";
1161 for (i = 0; i < hdev->maxcollection; i++) {
1162 struct hid_collection *col = &hdev->collection[i];
1163 if (col->type == HID_COLLECTION_APPLICATION &&
1164 (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK &&
1165 (col->usage & 0xffff) < ARRAY_SIZE(types)) {
1166 type = types[col->usage & 0xffff];
1167 break;
1168 }
1169 }
1170
1171 switch (hdev->bus) {
1172 case BUS_USB:
1173 bus = "USB";
1174 break;
1175 case BUS_BLUETOOTH:
1176 bus = "BLUETOOTH";
1177 break;
1178 default:
1179 bus = "<UNKNOWN>";
1180 }
1181
1182 dev_info(&hdev->dev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
1183 buf, bus, hdev->version >> 8, hdev->version & 0xff,
1184 type, hdev->name, hdev->phys);
1185
1186 return 0;
1187}
1188EXPORT_SYMBOL_GPL(hid_connect);
1189
1116static bool hid_match_one_id(struct hid_device *hdev, 1190static bool hid_match_one_id(struct hid_device *hdev,
1117 const struct hid_device_id *id) 1191 const struct hid_device_id *id)
1118{ 1192{
@@ -1238,7 +1312,7 @@ static int hid_device_probe(struct device *dev)
1238 } else { /* default probe */ 1312 } else { /* default probe */
1239 ret = hid_parse(hdev); 1313 ret = hid_parse(hdev);
1240 if (!ret) 1314 if (!ret)
1241 ret = hid_hw_start(hdev); 1315 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
1242 } 1316 }
1243 if (ret) 1317 if (ret)
1244 hdev->driver = NULL; 1318 hdev->driver = NULL;