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 14:05:56 +0100 |
commit | e9d5da97a6a8da75f8a58b722bbd59ef474e0f47 (patch) | |
tree | 5d5a8915ba6a7cc7155098c0a4c80d12ad72dc3e /net | |
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>
Diffstat (limited to 'net')
-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 469e61b27dc..02670b30895 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -373,62 +373,25 @@ err: return ret; } -static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, - unsigned char report_type) +static int hidp_output_report(struct hid_device *hid, __u8 *data, size_t count) { struct hidp_session *session = hid->driver_data; - int ret; + return hidp_send_intr_message(session, + HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT, + data, count); +} + +static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, + size_t count, unsigned char report_type) +{ if (report_type == HID_OUTPUT_REPORT) { - report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; - return hidp_send_intr_message(session, report_type, - data, count); + return hidp_output_report(hid, data, count); } else if (report_type != HID_FEATURE_REPORT) { return -EINVAL; } - if (mutex_lock_interruptible(&session->report_mutex)) - return -ERESTARTSYS; - - /* Set up our wait, and send the report request to the device. */ - set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); - report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; - ret = hidp_send_ctrl_message(session, report_type, data, count); - if (ret) - goto err; - - /* Wait for the ACK from the device. */ - while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) && - !atomic_read(&session->terminate)) { - int res; - - res = wait_event_interruptible_timeout(session->report_queue, - !test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) - || atomic_read(&session->terminate), - 10*HZ); - if (res == 0) { - /* timeout */ - ret = -EIO; - goto err; - } - if (res < 0) { - /* signal */ - ret = -ERESTARTSYS; - goto err; - } - } - - if (!session->output_report_success) { - ret = -EIO; - goto err; - } - - ret = count; - -err: - clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); - mutex_unlock(&session->report_mutex); - return ret; + return hidp_set_raw_report(hid, data[0], data, count, report_type); } 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, } } -static int hidp_output_report(struct hid_device *hid, __u8 *data, size_t count) -{ - struct hidp_session *session = hid->driver_data; - - return hidp_send_intr_message(session, - HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT, - data, count); -} - static void hidp_idle_timeout(unsigned long arg) { struct hidp_session *session = (struct hidp_session *) arg; |