diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2014-02-05 16:33:20 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-02-17 08:05:56 -0500 |
commit | e9d5da97a6a8da75f8a58b722bbd59ef474e0f47 (patch) | |
tree | 5d5a8915ba6a7cc7155098c0a4c80d12ad72dc3e | |
parent | b40272e4d0e6d07a0bf9409e5f95d622422cd73d (diff) |
HID: HIDp: remove duplicated coded
- Move hidp_output_report() above
- Removed duplicated code in hidp_output_raw_report()
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | net/bluetooth/hidp/core.c | 68 |
1 files changed, 11 insertions, 57 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 469e61b27dcf..02670b30895a 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -373,62 +373,25 @@ err: | |||
373 | return ret; | 373 | return ret; |
374 | } | 374 | } |
375 | 375 | ||
376 | static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, | 376 | static int hidp_output_report(struct hid_device *hid, __u8 *data, size_t count) |
377 | unsigned char report_type) | ||
378 | { | 377 | { |
379 | struct hidp_session *session = hid->driver_data; | 378 | struct hidp_session *session = hid->driver_data; |
380 | int ret; | ||
381 | 379 | ||
380 | return hidp_send_intr_message(session, | ||
381 | HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT, | ||
382 | data, count); | ||
383 | } | ||
384 | |||
385 | static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, | ||
386 | size_t count, unsigned char report_type) | ||
387 | { | ||
382 | if (report_type == HID_OUTPUT_REPORT) { | 388 | if (report_type == HID_OUTPUT_REPORT) { |
383 | report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; | 389 | return hidp_output_report(hid, data, count); |
384 | return hidp_send_intr_message(session, report_type, | ||
385 | data, count); | ||
386 | } else if (report_type != HID_FEATURE_REPORT) { | 390 | } else if (report_type != HID_FEATURE_REPORT) { |
387 | return -EINVAL; | 391 | return -EINVAL; |
388 | } | 392 | } |
389 | 393 | ||
390 | if (mutex_lock_interruptible(&session->report_mutex)) | 394 | return hidp_set_raw_report(hid, data[0], data, count, report_type); |
391 | return -ERESTARTSYS; | ||
392 | |||
393 | /* Set up our wait, and send the report request to the device. */ | ||
394 | set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); | ||
395 | report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; | ||
396 | ret = hidp_send_ctrl_message(session, report_type, data, count); | ||
397 | if (ret) | ||
398 | goto err; | ||
399 | |||
400 | /* Wait for the ACK from the device. */ | ||
401 | while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) && | ||
402 | !atomic_read(&session->terminate)) { | ||
403 | int res; | ||
404 | |||
405 | res = wait_event_interruptible_timeout(session->report_queue, | ||
406 | !test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) | ||
407 | || atomic_read(&session->terminate), | ||
408 | 10*HZ); | ||
409 | if (res == 0) { | ||
410 | /* timeout */ | ||
411 | ret = -EIO; | ||
412 | goto err; | ||
413 | } | ||
414 | if (res < 0) { | ||
415 | /* signal */ | ||
416 | ret = -ERESTARTSYS; | ||
417 | goto err; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | if (!session->output_report_success) { | ||
422 | ret = -EIO; | ||
423 | goto err; | ||
424 | } | ||
425 | |||
426 | ret = count; | ||
427 | |||
428 | err: | ||
429 | clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); | ||
430 | mutex_unlock(&session->report_mutex); | ||
431 | return ret; | ||
432 | } | 395 | } |
433 | 396 | ||
434 | static int hidp_raw_request(struct hid_device *hid, unsigned char reportnum, | 397 | static int hidp_raw_request(struct hid_device *hid, unsigned char reportnum, |
@@ -445,15 +408,6 @@ static int hidp_raw_request(struct hid_device *hid, unsigned char reportnum, | |||
445 | } | 408 | } |
446 | } | 409 | } |
447 | 410 | ||
448 | static int hidp_output_report(struct hid_device *hid, __u8 *data, size_t count) | ||
449 | { | ||
450 | struct hidp_session *session = hid->driver_data; | ||
451 | |||
452 | return hidp_send_intr_message(session, | ||
453 | HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT, | ||
454 | data, count); | ||
455 | } | ||
456 | |||
457 | static void hidp_idle_timeout(unsigned long arg) | 411 | static void hidp_idle_timeout(unsigned long arg) |
458 | { | 412 | { |
459 | struct hidp_session *session = (struct hidp_session *) arg; | 413 | struct hidp_session *session = (struct hidp_session *) arg; |