Commit e9d5da97 authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina

HID: HIDp: remove duplicated coded

- Move hidp_output_report() above
- Removed duplicated code in hidp_output_raw_report()
Reviewed-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent b40272e4
...@@ -373,62 +373,25 @@ static int hidp_set_raw_report(struct hid_device *hid, unsigned char reportnum, ...@@ -373,62 +373,25 @@ static int hidp_set_raw_report(struct hid_device *hid, unsigned char reportnum,
return ret; return ret;
} }
static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, static int hidp_output_report(struct hid_device *hid, __u8 *data, size_t count)
unsigned char report_type)
{ {
struct hidp_session *session = hid->driver_data; struct hidp_session *session = hid->driver_data;
int ret;
if (report_type == HID_OUTPUT_REPORT) { return hidp_send_intr_message(session,
report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT,
return hidp_send_intr_message(session, report_type,
data, count); 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) {
return hidp_output_report(hid, data, count);
} else if (report_type != HID_FEATURE_REPORT) { } else if (report_type != HID_FEATURE_REPORT) {
return -EINVAL; return -EINVAL;
} }
if (mutex_lock_interruptible(&session->report_mutex)) return hidp_set_raw_report(hid, data[0], data, count, report_type);
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;
} }
static int hidp_raw_request(struct hid_device *hid, unsigned char reportnum, 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,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) static void hidp_idle_timeout(unsigned long arg)
{ {
struct hidp_session *session = (struct hidp_session *) arg; struct hidp_session *session = (struct hidp_session *) arg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment