diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2016-06-21 21:48:46 +0200 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2016-06-23 08:47:40 +0200 |
commit | 4374573008df08a3a7a84cd827ed8f1ceee9901b (patch) | |
tree | e5eef598c1e25a6aafe8315c54bbfce827db6b88 /drivers/hid/hid-led.c | |
parent | HID: hid-led: add support for devices with multiple independent LEDs (diff) | |
download | linux-4374573008df08a3a7a84cd827ed8f1ceee9901b.tar.xz linux-4374573008df08a3a7a84cd827ed8f1ceee9901b.zip |
HID: hid-led: add support for reading from LED devices
Add support for reading data from LED devices.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-led.c')
-rw-r--r-- | drivers/hid/hid-led.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/hid/hid-led.c b/drivers/hid/hid-led.c index d5d8d941c4b0..4075f095c2a2 100644 --- a/drivers/hid/hid-led.c +++ b/drivers/hid/hid-led.c @@ -115,6 +115,35 @@ static int hidled_send(struct hidled_device *ldev, __u8 *buf) return ret == ldev->config->report_size ? 0 : -EMSGSIZE; } +/* reading data is supported for report type RAW_REQUEST only */ +static int hidled_recv(struct hidled_device *ldev, __u8 *buf) +{ + int ret; + + if (ldev->config->report_type != RAW_REQUEST) + return -EINVAL; + + buf[0] = ldev->config->report_id; + + mutex_lock(&ldev->lock); + + ret = hid_hw_raw_request(ldev->hdev, buf[0], buf, + ldev->config->report_size, + HID_FEATURE_REPORT, + HID_REQ_SET_REPORT); + if (ret < 0) + goto err; + + ret = hid_hw_raw_request(ldev->hdev, buf[0], buf, + ldev->config->report_size, + HID_FEATURE_REPORT, + HID_REQ_GET_REPORT); +err: + mutex_unlock(&ldev->lock); + + return ret < 0 ? ret : 0; +} + static u8 riso_kagaku_index(struct hidled_rgb *rgb) { enum led_brightness r, g, b; |