aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>2013-02-25 05:31:50 -0500
committerJiri Kosina <jkosina@suse.cz>2013-02-25 07:26:42 -0500
commit545bef681088cbf49c9c11d63872698b81eac7eb (patch)
tree64a544caaa337f97465dd575fb9ecf86e3748b7e /drivers/hid
parentb0a7868181be0a28fc35231d7435c1fb360eb675 (diff)
HID: i2c-hid: implement request() callback
This allows HID drivers to also get/set reports through hid_hw_request(). Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index ec7930217a6d..935f387be95a 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -563,6 +563,37 @@ static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf,
563 return ret; 563 return ret;
564} 564}
565 565
566static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep,
567 int reqtype)
568{
569 struct i2c_client *client = hid->driver_data;
570 struct i2c_hid *ihid = i2c_get_clientdata(client);
571 char *buf;
572 int ret;
573
574 buf = kzalloc(ihid->bufsize, GFP_KERNEL);
575 if (!buf)
576 return;
577
578 switch (reqtype) {
579 case HID_REQ_GET_REPORT:
580 ret = i2c_hid_get_raw_report(hid, rep->id, buf, ihid->bufsize,
581 rep->type);
582 if (ret < 0)
583 dev_err(&client->dev, "%s: unable to get report: %d\n",
584 __func__, ret);
585 else
586 hid_input_report(hid, rep->type, buf, ret, 0);
587 break;
588 case HID_REQ_SET_REPORT:
589 hid_output_report(rep, buf);
590 i2c_hid_output_raw_report(hid, buf, ihid->bufsize, rep->type);
591 break;
592 }
593
594 kfree(buf);
595}
596
566static int i2c_hid_parse(struct hid_device *hid) 597static int i2c_hid_parse(struct hid_device *hid)
567{ 598{
568 struct i2c_client *client = hid->driver_data; 599 struct i2c_client *client = hid->driver_data;
@@ -742,6 +773,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = {
742 .open = i2c_hid_open, 773 .open = i2c_hid_open,
743 .close = i2c_hid_close, 774 .close = i2c_hid_close,
744 .power = i2c_hid_power, 775 .power = i2c_hid_power,
776 .request = i2c_hid_request,
745 .hidinput_input_event = i2c_hid_hidinput_input_event, 777 .hidinput_input_event = i2c_hid_hidinput_input_event,
746}; 778};
747 779