From patchwork Mon Feb 25 10:31:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 2180601 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7910140079 for ; Mon, 25 Feb 2013 10:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932424Ab3BYKd1 (ORCPT ); Mon, 25 Feb 2013 05:33:27 -0500 Received: from mail-wi0-f171.google.com ([209.85.212.171]:50197 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932273Ab3BYKc7 (ORCPT ); Mon, 25 Feb 2013 05:32:59 -0500 Received: by mail-wi0-f171.google.com with SMTP id hn17so3175288wib.4 for ; Mon, 25 Feb 2013 02:32:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=BJS1Tz758WG4uz8f0Ltu4uWSlDVR1hnJNT4zNE4VRpQ=; b=yBw27eQ3VFC35H7mWkhgjCh0MSw3/VuQy9s2Hs+WgASYDZgtDm8obluCCplGaI+kPY Smjb4ThtNEixkZ3LCH4MK6PBPTg+vELW+ZLcoHBxUURjihyQ24Az2N2X9NBTU0+GS2UI 8aptdcN0uqB/Ma2ZzaIWGJ9US/fz5QPjG5Qp8FUo7+bpzH5T+PdMEfFRoRExfZk0huk4 VJhW+br9sa1Nses9SLzilXBRbZuDe/pRAFfU9EBE1ba53kCKvZx042XFjyo7HW/5u1Y/ 4iBHIaHaxs2MbvDXEjZXsuAC6SZ/DE7UyHW5I5x+JNinC0mgeMVUe3Q3qVulhotM43Yc 0blw== X-Received: by 10.180.82.33 with SMTP id f1mr10960140wiy.13.1361788378502; Mon, 25 Feb 2013 02:32:58 -0800 (PST) Received: from localhost.localdomain.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id fv2sm15624068wib.6.2013.02.25.02.32.56 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 25 Feb 2013 02:32:57 -0800 (PST) From: Benjamin Tissoires To: Benjamin Tissoires , Jiri Kosina , Stephane Chatty , Mika Westerberg , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] HID: i2c-hid: implement request() callback Date: Mon, 25 Feb 2013 11:31:50 +0100 Message-Id: <1361788310-6048-9-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361788310-6048-1-git-send-email-benjamin.tissoires@gmail.com> References: <1361788310-6048-1-git-send-email-benjamin.tissoires@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This allows HID drivers to also get/set reports through hid_hw_request(). Tested-by: Mika Westerberg Signed-off-by: Benjamin Tissoires Signed-off-by: Mika Westerberg --- drivers/hid/i2c-hid/i2c-hid.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index ec79302..935f387 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, return ret; } +static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep, + int reqtype) +{ + struct i2c_client *client = hid->driver_data; + struct i2c_hid *ihid = i2c_get_clientdata(client); + char *buf; + int ret; + + buf = kzalloc(ihid->bufsize, GFP_KERNEL); + if (!buf) + return; + + switch (reqtype) { + case HID_REQ_GET_REPORT: + ret = i2c_hid_get_raw_report(hid, rep->id, buf, ihid->bufsize, + 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, ihid->bufsize, rep->type); + break; + } + + kfree(buf); +} + static int i2c_hid_parse(struct hid_device *hid) { struct i2c_client *client = hid->driver_data; @@ -742,6 +773,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, };