From patchwork Tue Jul 5 11:45:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 944522 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 p65BjfU2002557 for ; Tue, 5 Jul 2011 11:45:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756091Ab1GELpk (ORCPT ); Tue, 5 Jul 2011 07:45:40 -0400 Received: from mail-fx0-f52.google.com ([209.85.161.52]:37593 "EHLO mail-fx0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755766Ab1GELpj (ORCPT ); Tue, 5 Jul 2011 07:45:39 -0400 Received: by mail-fx0-f52.google.com with SMTP id 18so6110868fxd.11 for ; Tue, 05 Jul 2011 04:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=JKF2+Kw7hVKYFxq4E5jSv1DvQJeXEkyH1O6r1RitEjw=; b=XBH3U6k3/KIqGyxOkH7nrCSZgoD4WBnLcOEyQNbSlqn3T8J8wkYPfuCVrMBdd3nlR8 LjkzODJ79ua1AOg9dy2JmE8QI4fHHWEvtIBoDlacHM/TSnzDlUegJcY6LiwcChFXEESi R5j+hVrvehKFAynMXlWrlcLbg362wdLqAjoOE= Received: by 10.223.14.139 with SMTP id g11mr2524762faa.82.1309866338275; Tue, 05 Jul 2011 04:45:38 -0700 (PDT) Received: from localhost.localdomain (u-084-c056.eap.uni-tuebingen.de [134.2.84.56]) by mx.google.com with ESMTPS id r10sm5238461fah.2.2011.07.05.04.45.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jul 2011 04:45:37 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, padovan@profusion.mobi, David Herrmann Subject: [PATCH 06/12] HID: wiimote: Add wiimote send function Date: Tue, 5 Jul 2011 13:45:13 +0200 Message-Id: <1309866319-12899-6-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1309866319-12899-1-git-send-email-dh.herrmann@googlemail.com> References: <1309866319-12899-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]); Tue, 05 Jul 2011 11:45:42 +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) {