diff options
| -rw-r--r-- | drivers/hid/hid-lenovo-tpkbd.c | 2 | ||||
| -rw-r--r-- | drivers/hid/hid-logitech-dj.c | 45 | ||||
| -rw-r--r-- | drivers/hid/hid-logitech-dj.h | 1 |
3 files changed, 48 insertions, 0 deletions
diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c index 77d2df04c97b..60c4e1e85913 100644 --- a/drivers/hid/hid-lenovo-tpkbd.c +++ b/drivers/hid/hid-lenovo-tpkbd.c | |||
| @@ -519,6 +519,8 @@ static void tpkbd_remove_tp(struct hid_device *hdev) | |||
| 519 | led_classdev_unregister(&data_pointer->led_mute); | 519 | led_classdev_unregister(&data_pointer->led_mute); |
| 520 | 520 | ||
| 521 | hid_set_drvdata(hdev, NULL); | 521 | hid_set_drvdata(hdev, NULL); |
| 522 | kfree(data_pointer->led_micmute.name); | ||
| 523 | kfree(data_pointer->led_mute.name); | ||
| 522 | kfree(data_pointer); | 524 | kfree(data_pointer); |
| 523 | } | 525 | } |
| 524 | 526 | ||
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index 4d524b5f52f5..9500f2f3f8fe 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c | |||
| @@ -193,6 +193,7 @@ static struct hid_ll_driver logi_dj_ll_driver; | |||
| 193 | static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf, | 193 | static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf, |
| 194 | size_t count, | 194 | size_t count, |
| 195 | unsigned char report_type); | 195 | unsigned char report_type); |
| 196 | static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev); | ||
| 196 | 197 | ||
| 197 | static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev, | 198 | static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev, |
| 198 | struct dj_report *dj_report) | 199 | struct dj_report *dj_report) |
| @@ -233,6 +234,7 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev, | |||
| 233 | if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] & | 234 | if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] & |
| 234 | SPFUNCTION_DEVICE_LIST_EMPTY) { | 235 | SPFUNCTION_DEVICE_LIST_EMPTY) { |
| 235 | dbg_hid("%s: device list is empty\n", __func__); | 236 | dbg_hid("%s: device list is empty\n", __func__); |
| 237 | djrcv_dev->querying_devices = false; | ||
| 236 | return; | 238 | return; |
| 237 | } | 239 | } |
| 238 | 240 | ||
| @@ -243,6 +245,12 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev, | |||
| 243 | return; | 245 | return; |
| 244 | } | 246 | } |
| 245 | 247 | ||
| 248 | if (djrcv_dev->paired_dj_devices[dj_report->device_index]) { | ||
| 249 | /* The device is already known. No need to reallocate it. */ | ||
| 250 | dbg_hid("%s: device is already known\n", __func__); | ||
| 251 | return; | ||
| 252 | } | ||
| 253 | |||
| 246 | dj_hiddev = hid_allocate_device(); | 254 | dj_hiddev = hid_allocate_device(); |
| 247 | if (IS_ERR(dj_hiddev)) { | 255 | if (IS_ERR(dj_hiddev)) { |
| 248 | dev_err(&djrcv_hdev->dev, "%s: hid_allocate_device failed\n", | 256 | dev_err(&djrcv_hdev->dev, "%s: hid_allocate_device failed\n", |
| @@ -306,6 +314,7 @@ static void delayedwork_callback(struct work_struct *work) | |||
| 306 | struct dj_report dj_report; | 314 | struct dj_report dj_report; |
| 307 | unsigned long flags; | 315 | unsigned long flags; |
| 308 | int count; | 316 | int count; |
| 317 | int retval; | ||
| 309 | 318 | ||
| 310 | dbg_hid("%s\n", __func__); | 319 | dbg_hid("%s\n", __func__); |
| 311 | 320 | ||
| @@ -338,6 +347,25 @@ static void delayedwork_callback(struct work_struct *work) | |||
| 338 | logi_dj_recv_destroy_djhid_device(djrcv_dev, &dj_report); | 347 | logi_dj_recv_destroy_djhid_device(djrcv_dev, &dj_report); |
| 339 | break; | 348 | break; |
| 340 | default: | 349 | default: |
| 350 | /* A normal report (i. e. not belonging to a pair/unpair notification) | ||
| 351 | * arriving here, means that the report arrived but we did not have a | ||
| 352 | * paired dj_device associated to the report's device_index, this | ||
| 353 | * means that the original "device paired" notification corresponding | ||
| 354 | * to this dj_device never arrived to this driver. The reason is that | ||
| 355 | * hid-core discards all packets coming from a device while probe() is | ||
| 356 | * executing. */ | ||
| 357 | if (!djrcv_dev->paired_dj_devices[dj_report.device_index]) { | ||
| 358 | /* ok, we don't know the device, just re-ask the | ||
| 359 | * receiver for the list of connected devices. */ | ||
| 360 | retval = logi_dj_recv_query_paired_devices(djrcv_dev); | ||
| 361 | if (!retval) { | ||
| 362 | /* everything went fine, so just leave */ | ||
| 363 | break; | ||
| 364 | } | ||
| 365 | dev_err(&djrcv_dev->hdev->dev, | ||
| 366 | "%s:logi_dj_recv_query_paired_devices " | ||
| 367 | "error:%d\n", __func__, retval); | ||
| 368 | } | ||
| 341 | dbg_hid("%s: unexpected report type\n", __func__); | 369 | dbg_hid("%s: unexpected report type\n", __func__); |
| 342 | } | 370 | } |
| 343 | } | 371 | } |
| @@ -368,6 +396,12 @@ static void logi_dj_recv_forward_null_report(struct dj_receiver_dev *djrcv_dev, | |||
| 368 | if (!djdev) { | 396 | if (!djdev) { |
| 369 | dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" | 397 | dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" |
| 370 | " is NULL, index %d\n", dj_report->device_index); | 398 | " is NULL, index %d\n", dj_report->device_index); |
| 399 | kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report)); | ||
| 400 | |||
| 401 | if (schedule_work(&djrcv_dev->work) == 0) { | ||
| 402 | dbg_hid("%s: did not schedule the work item, was already " | ||
| 403 | "queued\n", __func__); | ||
| 404 | } | ||
| 371 | return; | 405 | return; |
| 372 | } | 406 | } |
| 373 | 407 | ||
| @@ -398,6 +432,12 @@ static void logi_dj_recv_forward_report(struct dj_receiver_dev *djrcv_dev, | |||
| 398 | if (dj_device == NULL) { | 432 | if (dj_device == NULL) { |
| 399 | dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" | 433 | dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" |
| 400 | " is NULL, index %d\n", dj_report->device_index); | 434 | " is NULL, index %d\n", dj_report->device_index); |
| 435 | kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report)); | ||
| 436 | |||
| 437 | if (schedule_work(&djrcv_dev->work) == 0) { | ||
| 438 | dbg_hid("%s: did not schedule the work item, was already " | ||
| 439 | "queued\n", __func__); | ||
| 440 | } | ||
| 401 | return; | 441 | return; |
| 402 | } | 442 | } |
| 403 | 443 | ||
| @@ -439,6 +479,10 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev) | |||
| 439 | struct dj_report *dj_report; | 479 | struct dj_report *dj_report; |
| 440 | int retval; | 480 | int retval; |
| 441 | 481 | ||
| 482 | /* no need to protect djrcv_dev->querying_devices */ | ||
| 483 | if (djrcv_dev->querying_devices) | ||
| 484 | return 0; | ||
| 485 | |||
| 442 | dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); | 486 | dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); |
| 443 | if (!dj_report) | 487 | if (!dj_report) |
| 444 | return -ENOMEM; | 488 | return -ENOMEM; |
| @@ -450,6 +494,7 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev) | |||
| 450 | return retval; | 494 | return retval; |
| 451 | } | 495 | } |
| 452 | 496 | ||
| 497 | |||
| 453 | static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, | 498 | static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, |
| 454 | unsigned timeout) | 499 | unsigned timeout) |
| 455 | { | 500 | { |
diff --git a/drivers/hid/hid-logitech-dj.h b/drivers/hid/hid-logitech-dj.h index fd28a5e0ca3b..4a4000340ce1 100644 --- a/drivers/hid/hid-logitech-dj.h +++ b/drivers/hid/hid-logitech-dj.h | |||
| @@ -101,6 +101,7 @@ struct dj_receiver_dev { | |||
| 101 | struct work_struct work; | 101 | struct work_struct work; |
| 102 | struct kfifo notif_fifo; | 102 | struct kfifo notif_fifo; |
| 103 | spinlock_t lock; | 103 | spinlock_t lock; |
| 104 | bool querying_devices; | ||
| 104 | }; | 105 | }; |
| 105 | 106 | ||
| 106 | struct dj_device { | 107 | struct dj_device { |
