aboutsummaryrefslogtreecommitdiff
path: root/drivers/hid/i2c-hid/i2c-hid.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/i2c-hid/i2c-hid.c')
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index ec7930217a6d..2b1799a3b212 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -563,6 +563,36 @@ static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf,
return ret;
}
+static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep,
+ int reqtype)
+{
+ struct i2c_client *client = hid->driver_data;
+ char *buf;
+ int ret;
+ int len = i2c_hid_get_report_length(rep) - 2;
+
+ buf = kzalloc(len, GFP_KERNEL);
+ if (!buf)
+ return;
+
+ switch (reqtype) {
+ case HID_REQ_GET_REPORT:
+ ret = i2c_hid_get_raw_report(hid, rep->id, buf, len, rep->type);
+ if (ret < 0)
+ dev_err(&client->dev, "%s: unable to get report: %d\n",
+ __func__, ret);
+ else
+ hid_input_report(hid, rep->type, buf, ret, 0);
+ break;
+ case HID_REQ_SET_REPORT:
+ hid_output_report(rep, buf);
+ i2c_hid_output_raw_report(hid, buf, len, rep->type);
+ break;
+ }
+
+ kfree(buf);
+}
+
static int i2c_hid_parse(struct hid_device *hid)
{
struct i2c_client *client = hid->driver_data;
@@ -742,6 +772,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = {
.open = i2c_hid_open,
.close = i2c_hid_close,
.power = i2c_hid_power,
+ .request = i2c_hid_request,
.hidinput_input_event = i2c_hid_hidinput_input_event,
};