aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2014-04-01 13:05:09 -0400
committerJiri Kosina <jkosina@suse.cz>2014-04-01 13:05:09 -0400
commitad295b6d5739ab24880a31be403bbc8fab62e177 (patch)
treecd760a18bcfa6e59b8b63fc71e333ba394b1cd9c /net
parentba04a57b4acd05a764471b2accd02000f6641881 (diff)
parentc3d77fab51f40821de91a744e4b514e9e4e76a7c (diff)
Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-linus
Conflicts: drivers/hid/hid-ids.h drivers/hid/hid-sony.c drivers/hid/i2c-hid/i2c-hid.c
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hidp/core.c118
1 files changed, 7 insertions, 111 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 450a0b999614..8181ea4bc2f2 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -223,51 +223,6 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
223 input_sync(dev); 223 input_sync(dev);
224} 224}
225 225
226static int hidp_send_report(struct hidp_session *session, struct hid_report *report)
227{
228 unsigned char hdr;
229 u8 *buf;
230 int rsize, ret;
231
232 buf = hid_alloc_report_buf(report, GFP_ATOMIC);
233 if (!buf)
234 return -EIO;
235
236 hid_output_report(report, buf);
237 hdr = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
238
239 rsize = ((report->size - 1) >> 3) + 1 + (report->id > 0);
240 ret = hidp_send_intr_message(session, hdr, buf, rsize);
241
242 kfree(buf);
243 return ret;
244}
245
246static int hidp_hidinput_event(struct input_dev *dev, unsigned int type,
247 unsigned int code, int value)
248{
249 struct hid_device *hid = input_get_drvdata(dev);
250 struct hidp_session *session = hid->driver_data;
251 struct hid_field *field;
252 int offset;
253
254 BT_DBG("session %p type %d code %d value %d",
255 session, type, code, value);
256
257 if (type != EV_LED)
258 return -1;
259
260 offset = hidinput_find_field(hid, type, code, &field);
261 if (offset == -1) {
262 hid_warn(dev, "event field not found\n");
263 return -1;
264 }
265
266 hid_set_field(field, offset, value);
267
268 return hidp_send_report(session, field->report);
269}
270
271static int hidp_get_raw_report(struct hid_device *hid, 226static int hidp_get_raw_report(struct hid_device *hid,
272 unsigned char report_number, 227 unsigned char report_number,
273 unsigned char *data, size_t count, 228 unsigned char *data, size_t count,
@@ -418,62 +373,13 @@ err:
418 return ret; 373 return ret;
419} 374}
420 375
421static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, 376static int hidp_output_report(struct hid_device *hid, __u8 *data, size_t count)
422 unsigned char report_type)
423{ 377{
424 struct hidp_session *session = hid->driver_data; 378 struct hidp_session *session = hid->driver_data;
425 int ret;
426
427 if (report_type == HID_OUTPUT_REPORT) {
428 report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
429 return hidp_send_intr_message(session, report_type,
430 data, count);
431 } else if (report_type != HID_FEATURE_REPORT) {
432 return -EINVAL;
433 }
434
435 if (mutex_lock_interruptible(&session->report_mutex))
436 return -ERESTARTSYS;
437 379
438 /* Set up our wait, and send the report request to the device. */ 380 return hidp_send_intr_message(session,
439 set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); 381 HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT,
440 report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; 382 data, count);
441 ret = hidp_send_ctrl_message(session, report_type, data, count);
442 if (ret)
443 goto err;
444
445 /* Wait for the ACK from the device. */
446 while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) &&
447 !atomic_read(&session->terminate)) {
448 int res;
449
450 res = wait_event_interruptible_timeout(session->report_queue,
451 !test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)
452 || atomic_read(&session->terminate),
453 10*HZ);
454 if (res == 0) {
455 /* timeout */
456 ret = -EIO;
457 goto err;
458 }
459 if (res < 0) {
460 /* signal */
461 ret = -ERESTARTSYS;
462 goto err;
463 }
464 }
465
466 if (!session->output_report_success) {
467 ret = -EIO;
468 goto err;
469 }
470
471 ret = count;
472
473err:
474 clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags);
475 mutex_unlock(&session->report_mutex);
476 return ret;
477} 383}
478 384
479static int hidp_raw_request(struct hid_device *hid, unsigned char reportnum, 385static int hidp_raw_request(struct hid_device *hid, unsigned char reportnum,
@@ -490,15 +396,6 @@ static int hidp_raw_request(struct hid_device *hid, unsigned char reportnum,
490 } 396 }
491} 397}
492 398
493static int hidp_output_report(struct hid_device *hid, __u8 *data, size_t count)
494{
495 struct hidp_session *session = hid->driver_data;
496
497 return hidp_send_intr_message(session,
498 HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT,
499 data, count);
500}
501
502static void hidp_idle_timeout(unsigned long arg) 399static void hidp_idle_timeout(unsigned long arg)
503{ 400{
504 struct hidp_session *session = (struct hidp_session *) arg; 401 struct hidp_session *session = (struct hidp_session *) arg;
@@ -829,7 +726,6 @@ static struct hid_ll_driver hidp_hid_driver = {
829 .close = hidp_close, 726 .close = hidp_close,
830 .raw_request = hidp_raw_request, 727 .raw_request = hidp_raw_request,
831 .output_report = hidp_output_report, 728 .output_report = hidp_output_report,
832 .hidinput_input_event = hidp_hidinput_event,
833}; 729};
834 730
835/* This function sets up the hid device. It does not add it 731/* This function sets up the hid device. It does not add it
@@ -871,15 +767,15 @@ static int hidp_setup_hid(struct hidp_session *session,
871 snprintf(hid->phys, sizeof(hid->phys), "%pMR", 767 snprintf(hid->phys, sizeof(hid->phys), "%pMR",
872 &l2cap_pi(session->ctrl_sock->sk)->chan->src); 768 &l2cap_pi(session->ctrl_sock->sk)->chan->src);
873 769
770 /* NOTE: Some device modules depend on the dst address being stored in
771 * uniq. Please be aware of this before making changes to this behavior.
772 */
874 snprintf(hid->uniq, sizeof(hid->uniq), "%pMR", 773 snprintf(hid->uniq, sizeof(hid->uniq), "%pMR",
875 &l2cap_pi(session->ctrl_sock->sk)->chan->dst); 774 &l2cap_pi(session->ctrl_sock->sk)->chan->dst);
876 775
877 hid->dev.parent = &session->conn->hcon->dev; 776 hid->dev.parent = &session->conn->hcon->dev;
878 hid->ll_driver = &hidp_hid_driver; 777 hid->ll_driver = &hidp_hid_driver;
879 778
880 hid->hid_get_raw_report = hidp_get_raw_report;
881 hid->hid_output_raw_report = hidp_output_raw_report;
882
883 /* True if device is blacklisted in drivers/hid/hid-core.c */ 779 /* True if device is blacklisted in drivers/hid/hid-core.c */
884 if (hid_ignore(hid)) { 780 if (hid_ignore(hid)) {
885 hid_destroy_device(session->hid); 781 hid_destroy_device(session->hid);