From patchwork Fri Jun 17 14:49:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 891712 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 p5HEpSI1016548 for ; Fri, 17 Jun 2011 14:51:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759429Ab1FQOvY (ORCPT ); Fri, 17 Jun 2011 10:51:24 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:50835 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759237Ab1FQOuW (ORCPT ); Fri, 17 Jun 2011 10:50:22 -0400 Received: by fxm17 with SMTP id 17so1796157fxm.19 for ; Fri, 17 Jun 2011 07:50:20 -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=JfaO/RKwsMfzUJjmgAXCTUE+hGzYRmF1UA0gpU74WYk=; b=TTYxtFB+SKiuQEIM8Wh+Zs2OEV/RDXIbbhdnvhFQZFwYgqoaD3R97uZV7qDADubogm 9/Jtk7AAj0aTFsAyVL87ovdH0f9u9h3gmJexLBSd26u6RNQzp24yzn8e/7QbaJcxJZx4 B0uyEkBKWl+quBG5Zn/v/GiK7SFUi9hHm9RXI= 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=bqecceehf56AUA26/kdjoJRWQLjxipOk3v10EMA5CqqAFKAlCDzSukJuBtH3LBylna XRNKbIPxY2npnhSBW7ABsnP4yo4q2XiiUsmCEtIxbzQSqBqMy2oYhUFh1kfXv0I6zIUO eKPhVbdaiY35KSvUl9R073tosarswroUgzAzg= Received: by 10.223.27.18 with SMTP id g18mr2652367fac.52.1308322220876; Fri, 17 Jun 2011 07:50:20 -0700 (PDT) Received: from localhost.localdomain (stgt-4d039afc.pool.mediaWays.net [77.3.154.252]) by mx.google.com with ESMTPS id o10sm1378710fah.31.2011.06.17.07.50.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Jun 2011 07:50:20 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: padovan@profusion.mobi, jkosina@suse.cz, oliver@neukum.org, dh.herrmann@googlemail.com Subject: [PATCH 06/12 v2] HID: wiimote: Add wiimote send function Date: Fri, 17 Jun 2011 16:49:16 +0200 Message-Id: <1308322162-13953-6-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.5.2 In-Reply-To: <1308322162-13953-1-git-send-email-dh.herrmann@googlemail.com> References: <1308322162-13953-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]); Fri, 17 Jun 2011 14:51:28 +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 --- V2: Allocate new buffer for every packet that is sent out to comply to DMA constraints. 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 afae0e9..b6ae2a1 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) {