From patchwork Sat Dec 1 19:07:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1829661 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 47E6ADF264 for ; Sat, 1 Dec 2012 19:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752783Ab2LATHn (ORCPT ); Sat, 1 Dec 2012 14:07:43 -0500 Received: from mail-vc0-f174.google.com ([209.85.220.174]:34342 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297Ab2LATHn (ORCPT ); Sat, 1 Dec 2012 14:07:43 -0500 Received: by mail-vc0-f174.google.com with SMTP id d16so688953vcd.19 for ; Sat, 01 Dec 2012 11:07:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=8n1P4mm6ItDcorFN606mniKDElQvOLPw6hhtbwICgWA=; b=apbrj3xZvl3nQoLI6v/kNao9CuifLdSNQmC23gw08zz9/E5HPjBAWgVPPwDv1jUIcQ Vt0CZQqpVysS+BjwZEurOTw98v3roB8vp8q+xx0UiM5H+Rox1E4HllLmTP7bbwi7aPBw YuTXyXnpIEX5o4WNaIeUp8G0YKdqAtsXzzT0UNDJSADVO1M7vDqn9z3Spz8mmXC3fV8z pnAvSA4FZSRa3NpzR3cXxOtSYac+TdHv6h4P4KVkicH54Hyz5UxGKRdCe5UjtBBP+Ed6 nt5TBj8JarB44YzYg/KKN2/oMQh/70HXJ3PKxL+8yZJq3Hkn7eunuTnTX7XgHG+2BBzU TElw== Received: by 10.220.153.201 with SMTP id l9mr4417124vcw.33.1354388862858; Sat, 01 Dec 2012 11:07:42 -0800 (PST) Received: from localhost.localdomain ([177.134.152.163]) by mx.google.com with ESMTPS id g5sm2912702vez.6.2012.12.01.11.07.40 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 01 Dec 2012 11:07:42 -0800 (PST) From: Andre Guedes To: linux-input@vger.kernel.org Cc: dh.herrmann@googlemail.com Subject: [RFC v2 2/4] HID: uhid: Handle LED input events Date: Sat, 1 Dec 2012 16:07:19 -0300 Message-Id: <1354388841-23854-3-git-send-email-andre.guedes@openbossa.org> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1354388841-23854-1-git-send-email-andre.guedes@openbossa.org> References: <1354388841-23854-1-git-send-email-andre.guedes@openbossa.org> X-Gm-Message-State: ALoCoQnGzoGyNEQtIgyOJcMSsk8vOn2x+4mXdcPxgThIJnVPBBMa6vjkwyMf8zAq1aSgLterHXUI Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This patch adds support for handling LED input events in uhid driver. Others input events are sent to userspace as UHID_OUTPUT_EV events. Signed-off-by: Andre Guedes --- drivers/hid/uhid.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 714cd8c..a5cf905 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -122,21 +122,31 @@ static int uhid_hid_input(struct input_dev *input, unsigned int type, struct uhid_device *uhid = hid->driver_data; unsigned long flags; struct uhid_event *ev; + int ret; - ev = kzalloc(sizeof(*ev), GFP_ATOMIC); - if (!ev) - return -ENOMEM; + switch (type) { + case EV_LED: + ret = hidinput_led_output_report(hid, code, value); + break; - ev->type = UHID_OUTPUT_EV; - ev->u.output_ev.type = type; - ev->u.output_ev.code = code; - ev->u.output_ev.value = value; + default: + ev = kzalloc(sizeof(*ev), GFP_ATOMIC); + if (!ev) + return -ENOMEM; - spin_lock_irqsave(&uhid->qlock, flags); - uhid_queue(uhid, ev); - spin_unlock_irqrestore(&uhid->qlock, flags); + ev->type = UHID_OUTPUT_EV; + ev->u.output_ev.type = type; + ev->u.output_ev.code = code; + ev->u.output_ev.value = value; - return 0; + spin_lock_irqsave(&uhid->qlock, flags); + uhid_queue(uhid, ev); + spin_unlock_irqrestore(&uhid->qlock, flags); + + ret = 0; + } + + return ret; } static int uhid_hid_parse(struct hid_device *hid)