From patchwork Mon Jun 27 14:30:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 921042 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5REV8XU016430 for ; Mon, 27 Jun 2011 14:31:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752808Ab1F0ObA (ORCPT ); Mon, 27 Jun 2011 10:31:00 -0400 Received: from mail-fx0-f52.google.com ([209.85.161.52]:40385 "EHLO mail-fx0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752722Ab1F0Oa7 (ORCPT ); Mon, 27 Jun 2011 10:30:59 -0400 Received: by mail-fx0-f52.google.com with SMTP id 18so1868769fxd.11 for ; Mon, 27 Jun 2011 07:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=hIV4x3iq3SEibtfR6/i1/7PvyxU++v9mruLhA1GnBoc=; b=ds/lxCvVBSEkHJpTsribGQs/sTAI2dK2d2+2yDN5DkPwEOPkQ7iDgLyQVyI+z+g96Z 3D+E74cpIqbO/YElp6obxQ+FZKczHS3JoF8R3rXVDbDHZRkArhu6VT50avmqohZq1Mrb RbaSdvCoVbsz6pkhm0kOL+0CIEIvniC2bxnPE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=XUqcIstzfHgqYkDH03NF7StaUKV/AJbsPUOBW1sc+8CLtzlppWhmc4ntj+Ur6p7FQN 8XYN72ieaCAsm1svDfDlHM+5GnrSUYlpj4WXSd+egklgi3eHUlOk3lAqynwKivo/ZVxg 3f4YQWGDkdjVyPBTwiStYrgu3Wx+MARa/qx0U= Received: by 10.223.5.28 with SMTP id 28mr8998654fat.103.1309185058831; Mon, 27 Jun 2011 07:30:58 -0700 (PDT) Received: from localhost.localdomain (stgt-5f73b179.pool.mediaWays.net [95.115.177.121]) by mx.google.com with ESMTPS id f3sm3570523faa.6.2011.06.27.07.30.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Jun 2011 07:30:58 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: padovan@profusion.mobi, jkosina@suse.cz, oliver@neukum.org, David Herrmann Subject: [PATCH 06/12] HID: wiimote: Add wiimote send function Date: Mon, 27 Jun 2011 16:30:07 +0200 Message-Id: <1309185013-484-6-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.5.2 In-Reply-To: <1309185013-484-1-git-send-email-dh.herrmann@googlemail.com> References: <1309185013-484-1-git-send-email-dh.herrmann@googlemail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 27 Jun 2011 14:31:09 +0000 (UTC) The wiimote driver needs to send raw output reports to the wiimote device. Otherwise we could not manage the peripherals of the wiimote or perform memory operations on the wiimote. We cannot use hidinput_input_event of the lowlevel hid driver, since this does not accept raw input. Therefore, we need to use the same function that hidraw uses to send output. Side effect is, the raw output function is not buffered and can sleep. Signed-off-by: David Herrmann --- drivers/hid/hid-wiimote.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c index 3416f69..811ed89 100644 --- a/drivers/hid/hid-wiimote.c +++ b/drivers/hid/hid-wiimote.c @@ -26,6 +26,25 @@ struct wiimote_data { struct input_dev *input; }; +static ssize_t wiimote_hid_send(struct hid_device *hdev, __u8 *buffer, + size_t count) +{ + __u8 *buf; + ssize_t ret; + + if (!hdev->hid_output_raw_report) + return -ENODEV; + + buf = kmemdup(buffer, count, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + ret = hdev->hid_output_raw_report(hdev, buf, count, HID_OUTPUT_REPORT); + + kfree(buf); + return ret; +} + static int wiimote_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) {